All Implemented Interfaces:
DataExceptionContributor, JsonSerializable, RecordSerializable, XmlSerializable, SchemaProblemsSupplier, JavaCodeGenerator, Serializable, Cloneable

public class SchemaDef extends SchemaPart implements Cloneable, SchemaProblemsSupplier
The metadata model containing a set of related entities.
See Also:
  • Constructor Details

    • SchemaDef

      public SchemaDef()
    • SchemaDef

      public SchemaDef(String name)
  • Method Details

    • getSchemaProblems

      public void getSchemaProblems(List<SchemaProblem> problems, boolean includeChildren)
      Description copied from interface: SchemaProblemsSupplier
      Adds this element's problems to the list, plus those of its children when includeChildren is true; the default adds none.
      Specified by:
      getSchemaProblems in interface SchemaProblemsSupplier
    • clone

      public SchemaDef clone()
      Overrides:
      clone in class FoundationObject
    • generateJavaCode

      public void generateJavaCode(JavaCodeBuilder code)
      Description copied from interface: JavaCodeGenerator
      Appends Java source code representing this object to the given builder.
      Specified by:
      generateJavaCode in interface JavaCodeGenerator
    • getSchemaDef

      public SchemaDef getSchemaDef()
      Description copied from class: SchemaPart
      Returns the schema containing this part (itself for a SchemaDef) or null if the part is not in a schema.
      Specified by:
      getSchemaDef in class SchemaPart
    • getSchemaPartContainer

      public SchemaPart getSchemaPartContainer()
      Description copied from class: SchemaPart
      Returns the schema part containing this one or null if there is none.
      Specified by:
      getSchemaPartContainer in class SchemaPart
    • getSchemaPartType

      public SchemaPartType getSchemaPartType()
      Description copied from class: SchemaPart
      Returns the kind of part this is, such as SchemaPartType.ENTITY.
      Specified by:
      getSchemaPartType in class SchemaPart
    • getSchemaPartName

      public String getSchemaPartName()
      Description copied from class: SchemaPart
      Returns the name identifying this part, such as an entity's name or an index field's field name.
      Specified by:
      getSchemaPartName in class SchemaPart
    • getName

      public String getName()
      The human-readable text identifier for this schema.
    • setName

      public SchemaDef setName(String name)
    • getDescription

      public String getDescription()
      The human-readable summary of this schema.
    • setDescription

      public SchemaDef setDescription(String description)
    • getEntityCount

      public int getEntityCount()
    • getEntityNames

      public List<String> getEntityNames()
    • getEntities

      public List<EntityDef> getEntities(boolean create)
      Returns the entities, creating the list if it is null and create is true.
    • getEntities

      public List<EntityDef> getEntities()
      Returns the entities in this schema or null if none were added.
    • setEntities

      public SchemaDef setEntities(List<EntityDef> entities)
      Replaces the entities with the given list (not copied) and makes this schema their parent.
    • addEntity

      public SchemaDef addEntity(EntityDef entity)
      Appends the entity and makes this schema its parent.
    • indexOfEntity

      public int indexOfEntity(String name)
      Returns the zero-based position of the EntityDef with the specified name or -1 if it is not found.
    • containsEntity

      public boolean containsEntity(String name)
      Returns true if this schema contains an EntityDef with the specified name.
    • getEntity

      public EntityDef getEntity(String name)
      Returns the EntityDef that matches the specified name.
    • getEntities

      public List<EntityDef> getEntities(String name)
      Returns all entities whose name matches the given name, ignoring case; empty if none match or the name is empty.
    • indexOfEntityRelationship

      public int indexOfEntityRelationship(String name)
      Returns the zero-based position of the EntityRelationshipDef with the specified name or -1 if it is not found.
    • containsEntityRelationship

      public boolean containsEntityRelationship(String name)
      Returns true if this schema contains an EntityRelationshipDef with the specified name.
    • getEntityRelationshipCount

      public int getEntityRelationshipCount()
      Returns the number of entity relationships in this schema.
    • getEntityRelationshipNames

      public List<String> getEntityRelationshipNames()
      Returns the names of all entity relationships in this schema.
    • getEntityRelationships

      public List<EntityRelationshipDef> getEntityRelationships(boolean create)
      Returns the entity relationships, creating the list if it is null and create is true.
    • getEntityRelationship

      public EntityRelationshipDef getEntityRelationship(String name)
      Returns the EntityRelationshipDef that matches the specified name.
    • getEntityRelationships

      public List<EntityRelationshipDef> getEntityRelationships()
      Returns the entity relationships in this schema or null if none were added.
    • getEntityRelationshipByForeignKeyName

      public EntityRelationshipDef getEntityRelationshipByForeignKeyName(String foreignKeyName)
      Returns a relationship whose name matches the given foreign key name, ignoring case, or null if there is none.
    • getEntityRelationshipsByForeignKeyName

      public List<EntityRelationshipDef> getEntityRelationshipsByForeignKeyName(String foreignKeyName)
    • setEntityRelationships

      public SchemaDef setEntityRelationships(List<EntityRelationshipDef> entityRelationships)
      Replaces the entity relationships with the given list (not copied) and makes this schema their parent.
    • addEntityRelationship

      public SchemaDef addEntityRelationship(EntityRelationshipDef entityRelationship)
      Appends the entity relationship and makes this schema its parent.
    • getPrimaryEntityRelationships

      public List<EntityRelationshipDef> getPrimaryEntityRelationships(EntityDef primaryEntity)
      Returns the relationships whose primary entity is the given entity, which must belong to this schema.
    • getForeignEntityRelationships

      public List<EntityRelationshipDef> getForeignEntityRelationships(EntityDef foreignEntity)
      Returns the relationships whose foreign entity is the given entity, which must belong to this schema.
    • getAttributes

      public Attributes getAttributes()
      User-defined key-value pairs to attached arbitrary metadata to this schema.
    • setAttributes

      public SchemaDef setAttributes(Attributes attributes)
      Sets the user-defined key-value pairs attached to this schema (null is treated as empty).
    • getTags

      public Tags getTags()
      The set of labels used to organize, filter, and classify this schema.
    • setTags

      public SchemaDef setTags(Tags tags)
      Sets the labels used to organize, filter, and classify this schema (null is treated as empty).
    • toJson

      public String toJson()
      Specified by:
      toJson in interface JsonSerializable
      Specified by:
      toJson in interface RecordSerializable
    • toRecord

      public Record toRecord()
      Description copied from interface: RecordSerializable
      Converts this object's state to a record that RecordSerializable.fromRecord(Record) can load.
      Specified by:
      toRecord in interface RecordSerializable
      Overrides:
      toRecord in class Bean
    • fromRecord

      public SchemaDef fromRecord(Record source)
      Description copied from interface: RecordSerializable
      Loads this instance's state from a record and returns this (for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.
      Specified by:
      fromRecord in interface RecordSerializable
      Overrides:
      fromRecord in class Bean
      Parameters:
      source -
      Returns:
      this instance.
    • fromJson

      public SchemaDef fromJson(String jsonString)
      Description copied from interface: JsonSerializable
      Loads this object's state from the given JSON text.
      Specified by:
      fromJson in interface JsonSerializable
      Specified by:
      fromJson in interface RecordSerializable
    • fromJson

      public SchemaDef fromJson(InputStream inputStream)
      Description copied from interface: JsonSerializable
      Loads this object's state from the UTF-8 encoded JSON in the stream.
      Specified by:
      fromJson in interface JsonSerializable
      Specified by:
      fromJson in interface RecordSerializable
    • fromXml

      public SchemaDef fromXml(InputStream inputStream)
      Description copied from interface: XmlSerializable
      Parses the XML in the stream and loads this object's state from its root element.
      Specified by:
      fromXml in interface XmlSerializable
    • fromXml

      public SchemaDef fromXml(String xml)
      Specified by:
      fromXml in interface XmlSerializable
    • toXmlElement

      public Element toXmlElement(Document document)
      Description copied from interface: XmlSerializable
      Returns an element, created with document, describing this object; the default implementation throws a DataException.
      Specified by:
      toXmlElement in interface XmlSerializable
    • fromXmlElement

      public SchemaDef fromXmlElement(Element schemaElement)
      Specified by:
      fromXmlElement in interface XmlSerializable
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object