
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. Suppose that we should decide whether an instance of an Item is valid: class Item(val amount: Float, val name: String) To build enterprise applications with Kotlin, we need to meet these differences. It’s language design and paradigm differ, and that creates a few problems for usage within Java EE containers. The syntax is different, that is obvious, but that is not the real issue. Here we present only the idea while the complete code is available in our repository on Github. Java and Kotlin are somewhat different languages. In order to demonstrate how we can process annotations, let’s create a simple validator.
