/** * Checks to see if this AttributeType is the ancestor of another * attributeType. * * @param descendant the perspective descendant to check * @return true if the descendant is truly a derived from this AttributeType */ public boolean isAncestorOf( AttributeType descendant ) { if ( ( descendant == null ) || this.equals( descendant ) ) { return false; } return isAncestorOrEqual( this, descendant ); }
/** * Checks to see if this AttributeType is the descendant of another * attributeType. * * @param ancestor the perspective ancestor to check * @return true if this AttributeType truly descends from the ancestor */ public boolean isDescendantOf( AttributeType ancestor ) { if ( ( ancestor == null ) || equals( ancestor ) ) { return false; } return isAncestorOrEqual( ancestor, this ); }
/** * Recursive method which checks to see if a descendant is really an ancestor or if the two * are equal. * * @param ancestor the possible ancestor of the descendant * @param descendant the possible descendant of the ancestor * @return true if the ancestor equals the descendant or if the descendant is really * a subtype of the ancestor. otherwise false */ private boolean isAncestorOrEqual( AttributeType ancestor, AttributeType descendant ) { if ( ( ancestor == null ) || ( descendant == null ) ) { return false; } if ( ancestor.equals( descendant ) ) { return true; } return isAncestorOrEqual( ancestor, descendant.getSuperior() ); }