The next code is an adaptation of my code and I hope it can help you.
Order.java
public class Order {
...
private Map<Integer, Item> items = new LinkedHashMap<Integer, Item>();
...
}
Item.java
public abstract class Item {
public abstract Object getValue();
public abstract void setValue(Object value);
}
ItemInt.java
public class ItemInt extends Item {
private Integer number;
@Override
public Integer getValue() {
return number;
}
@Override
public void setValue(Object value) {
number = (Integer) value;
}
}
ItemFloat.java
public class ItemFloat extends Item {
private Float number;
@Override
public Float getValue() {
return number;
}
@Override
public void setValue(Object value) {
number = (Float) value;
}
}
I'm trying to get the property type with the next string "items[2].value"
and it doesn't work. How can I make it? The results would be int
or float
.
Order order = ...;
....
final Class<?> clazz = new PropertyUtilsBean().getPropertyType(order, "items[2].value");
Aucun commentaire:
Enregistrer un commentaire