@Table(name = "SAMPLE_ORDER")
@Entity(name = "sample_Order")
public class Order extends StandardEntity {
private static final long serialVersionUID = -8651639140562527033L;
@Column(name = "QUANTITY")
private Integer quantity;
@Column(name = "PRICE")
private Integer price;
//...
@ModelProperty(related = {"quantity", "price"})
public Integer getTotalAmount() {
return (quantity != null && price != null) ?
quantity * price :
0;
}
}
Properties quantity and price are related to the totalAmount. We have a method in MetadataTools to get related properties:
metadataTools.getRelatedProperties(Order.class, "totalAmount") //will return "quantity" and "price"
Things are getting worse when we need to find which fields depends on quantity. When the field with quantity property is modified on the screen we need to update the totalAmount value. In this case it is hard to name the relation between the quantity and the totalAmount.
Another argument for renaming is that "related" has too wide meaning. Maybe it can be changed to dependsOn:
Suppose we have an entity:
Properties
quantity
andprice
are related to thetotalAmount
. We have a method inMetadataTools
to get related properties:Things are getting worse when we need to find which fields depends on quantity. When the field with quantity property is modified on the screen we need to update the totalAmount value. In this case it is hard to name the relation between the quantity and the totalAmount.
Another argument for renaming is that "related" has too wide meaning. Maybe it can be changed to dependsOn:
Then methods for finding related properties may be as follows: