public boolean contains(final String name) { for (final CategoryItem child : children) { if (child.getName().equals(name)) { return true; } } return false; }
public void removeChildren(final String name) { for (int i = 0; i < children.size(); i++) { final CategoryItem child = children.get(i); if (child.getName().equals(name)) { children.remove(i); break; } } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } CategoryItem that = (CategoryItem) o; if (children != null ? !children.equals(that.children) : that.children != null) { return false; } if (description != null ? !description.equals(that.description) : that.description != null) { return false; } if (name != null ? !name.equals(that.name) : that.name != null) { return false; } if (parent != null ? !parent.equals(that.parent) : that.parent != null) { return false; } return true; }
@Override public int hashCode() { int result = parent != null ? parent.hashCode() : 0; result = ~~result; result = 31 * result + (children != null ? children.hashCode() : 0); result = ~~result; result = 31 * result + (name != null ? name.hashCode() : 0); result = ~~result; result = 31 * result + (description != null ? description.hashCode() : 0); result = ~~result; return result; }