Trying to get the POJO property name in Micronaut application. I have the below POJO class
@Introspected
public class Product {
@BsonProperty("_id")
@BsonId
private ObjectId id;
private String name;
private float price;
private String description;
// Getter and setter
}
I know we can get the property using Introspected
The below code gives me all the property in an array form.
final BeanIntrospection<Product> introspection = BeanIntrospection.getIntrospection(Product.class);
var product = introspection.getPropertyNames();
Now the product holds string of property names,
[0] name
[1] price
[2] description
I need to get the individual property as below instead of foreach on the product
Instead of getting through the array, is there any way to access it directly similar to Lombok as below
var desc = Product.Fields.description
var name = Product.Fields.name
var price = Product.Fields.price
Is there any way to achieve this?
Instead of getting through the array, is there any way to access it directly similar to Lombok as below:
var desc = Product.Fields.description
var name = Product.Fields.name
var price = Product.Fields.price
No. There is no such API to support a syntax like that.