I am modeling a domain model in my application. Obviously, some of the object relationships are associations, but these associations also have attributes. For instance:
Foo can have one-to-many bars. However, an association has attributes such as a date range, how long the association has been valid. So, the way I did this is as follows:
public interface Association<S, T> {
public S getSource();
public T getTarget();
}
Then for something like the above:
public class FooToBarAssociation implements Association<Foo, Bar> {
public Foo getSource();
public Bar getTarget();
public Date getFromDate();
public Date getToDate();
}
Then the class Foo has:
private List<FooToBarAssociation> associations;
My questions:
Is this a suitable way to model attribute relationships?
- / Foo? FooToBarAssociation -, , FooService, setAssociations, . , .