In order to find the ones with which we have decorated Item‘s properties. In our naive implementation, we just get the Item‘s properties: val fields = item::Īnd iterate over all annotations of each property: for (annotation in field.annotations) To this end, let’s decorate the properties of the Item class with our custom annotations: Positive and AllowedNames: class val amount: "Bob"]) val name: String) We assume that an Item instance is valid if the value of the amount is positive and the value of the name is either Alice or Bob. Nevertheless, if you already know Java and just are interesting only in learning Spring I suggest you use Java for this. Kotlin is mostly sought for Android development, on which Spring is not recommended. Suppose that we should decide whether an instance of an Item is valid: class Item(val amount: Float, val name: String) In general, Java has a much bigger market specially for big companies which move slow and are afraid of changes. Here we present only the idea while the complete code is available in our repository on Github. It offers multiple features which makes a preferred choice among the open-source developers: It is open-source and is distributed under the Apache License v2. Introduction Kotlin is a statically typed language. In order to demonstrate how we can process annotations, let’s create a simple validator. In this tutorial, we will create a simple hello world Spring Boot application in Kotlin.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |