emmanuel wrote:
can you show the code in addView and removeView
Sure can
public class ContentType
{
private String id=null;
private Set views=new HashSet();
public void setId(String _id){
id=_id;
}
public String getId() {return id;}
public Set getViews() {
return views;
}
public void setViews(Set views) {
this.views = views;
}
public void addView(View view) {
view.setContentType(this);
views.add(view);
}
public void removeView(View view) {
views.remove(view);
}
public boolean equals(Object o) {
if(o == this) {
return true;
}
if(!(o instanceof ContentType)) {
return false;
}
ContentType p = (ContentType)o;
return p.getId().equals(this.id) ;
}
public int hashCode() {
int result = 17;
result = 37*result + id.hashCode();
return result;
}
}
public class View implements java.io.Serializable {
private String viewName;
private ContentType contentType;
public String getViewName() {
return viewName;
}
public void setViewName(String viewName) {
this.viewName = viewName;
}
public ContentType getContentType() {
return contentType;
}
public void setContentType(ContentType contentType) {
this.contentType = contentType;
}
public boolean equals(Object o) {
if(o == this) {
return true;
}
if(!(o instanceof View)) {
return false;
}
View view = (View)o;
return view.getViewName().equals(this.getViewName()) &&
view.getContentType().equals(this.getContentType());
}
public int hashCode() {
int result = 17;
result = 37*result + viewName.hashCode();
if(contentType != null)
result = 37*result + contentType.hashCode();
return result;
}