@Override public TabContents createTab() { List sections = new ArrayList(getSectionDescriptors().size()); for (Iterator iter = getSectionDescriptors().iterator(); iter.hasNext();) { ISectionDescriptor descriptor = (ISectionDescriptor) iter.next(); ISection section = descriptor.getSectionClass(); sections.add(section); } TabContents tab = new TabContents(); tab.setSections((ISection[]) sections.toArray(new ISection[sections .size()])); return tab; }
@Override public int hashCode() { int hashCode = getCategory().hashCode(); hashCode ^= getId().hashCode(); Iterator i = this.getSectionDescriptors().iterator(); while (i.hasNext()) { ISectionDescriptor section = (ISectionDescriptor) i.next(); hashCode ^= section.getId().hashCode(); } return hashCode; }
@Override public boolean equals(Object object) { if (this == object) { return true; } if (this.getClass() == object.getClass()) { AbstractTabDescriptor descriptor = (AbstractTabDescriptor) object; if (this.getCategory().equals(descriptor.getCategory()) && this.getId().equals(descriptor.getId()) && this.getSectionDescriptors().size() == descriptor .getSectionDescriptors().size()) { Iterator i = this.getSectionDescriptors().iterator(); Iterator j = descriptor.getSectionDescriptors().iterator(); // the order is important here - so as long as the sizes of the // lists are the same and id of the section at the same // positions are the same - the lists are the same while (i.hasNext()) { ISectionDescriptor source = (ISectionDescriptor) i.next(); ISectionDescriptor target = (ISectionDescriptor) j.next(); if (!source.getId().equals(target.getId())) { return false; } } return true; } } return false; }