public void setParent(Object parent) { if (parent != null && !(parent instanceof Entity)) { throw new IllegalArgumentException("Expected null or Entity, got: " + parent); } setSourceEntity((Entity) parent); }
public void setParent(Object parent) { if (parent != null && !(parent instanceof Entity)) { throw new IllegalArgumentException("Expected null or Entity, got: " + parent); } setSourceEntity((Entity) parent); }
/** Adds new relationship to the entity. */ public void addRelationship(Relationship relationship) { if (relationship.getName() == null) { throw new IllegalArgumentException("Attempt to insert unnamed relationship."); } // block overrides // TODO: change method signature to return replaced attribute and make sure the // Modeler handles it... Object existingRelationship = relationships.get(relationship.getName()); if (existingRelationship != null) { if (existingRelationship == relationship) { return; } else { throw new IllegalArgumentException( "An attempt to override relationship '" + relationship.getName()); } } // Check that there aren't any attributes with the same name as the given relationship. Object existingAttribute = attributes.get(relationship.getName()); if (existingAttribute != null) { throw new IllegalArgumentException("Relationship name conflict with existing attribute '" + relationship.getName()); } relationships.put(relationship.getName(), relationship); relationship.setSourceEntity(this); }
/** * Adds new relationship to the entity. */ public void addRelationship(Relationship relationship) { if (relationship.getName() == null) { throw new IllegalArgumentException("Attempt to insert unnamed relationship."); } // block overrides // TODO: change method signature to return replaced attribute and make sure the // Modeler handles it... Object existingRelationship = relationships.get(relationship.getName()); if (existingRelationship != null) { if (existingRelationship == relationship) { return; } else { throw new IllegalArgumentException( "An attempt to override relationship '" + relationship.getName() + "'"); } } // Check that there aren't any attributes with the same name as the given // relationship. Object existingAttribute = attributes.get(relationship.getName()); if (existingAttribute != null) { throw new IllegalArgumentException( "Relationship name conflict with existing attribute '" + relationship.getName() + "'"); } relationships.put(relationship.getName(), relationship); relationship.setSourceEntity(this); }