Class IndexImpl

  • All Implemented Interfaces:
    Index, ModelElement

    public class IndexImpl
    extends java.lang.Object
    implements Index
    Index descriptor.
    Author:
    harald
    • Constructor Detail

      • IndexImpl

        public IndexImpl​(EntityFactoryImpl factory,
                         Entity entity,
                         SourceInfo sourceInfo)
        Creates an index.
        Parameters:
        factory - the factory to create indexes
        entity - the entity this index belongs to
        sourceInfo - the source info
    • Method Detail

      • getEntity

        public Entity getEntity()
        Description copied from interface: Index
        Gets the entity this index belongs to.
        Specified by:
        getEntity in interface Index
        Returns:
        the entity
      • getSourceInfo

        public SourceInfo getSourceInfo()
        Description copied from interface: ModelElement
        Gets the information about the source where this element is defined.
        Specified by:
        getSourceInfo in interface ModelElement
        Returns:
        the source info
      • getOrdinal

        public int getOrdinal()
        Description copied from interface: ModelElement
        Gets the ordinal along the inheritance path.
        Specified by:
        getOrdinal in interface ModelElement
        Returns:
        the ordinal, starting at 0
      • setOrdinal

        public void setOrdinal​(int ordinal)
      • parse

        public void parse​(Entity entity)
                   throws ModelException
        Parses a configuration line.
        Parameters:
        entity - the entity
        Throws:
        ModelException - if parsing the model failed
      • getName

        public java.lang.String getName()
        Description copied from interface: ModelElement
        Gets the name of the element.
        Specified by:
        getName in interface ModelElement
        Returns:
        the name
      • createDatabaseIndexName

        public java.lang.String createDatabaseIndexName​(Entity entity)
        Description copied from interface: Index
        Creates the database index name for given entity.
        Specified by:
        createDatabaseIndexName in interface Index
        Parameters:
        entity - the entity
        Returns:
        the effective sql name
      • getComment

        public java.lang.String getComment()
        Description copied from interface: Index
        Gets the comment.
        Specified by:
        getComment in interface Index
        Returns:
        the comment
      • isUnique

        public boolean isUnique()
        Description copied from interface: Index
        Returns whether the index is unique.
        Specified by:
        isUnique in interface Index
        Returns:
        true if unique, else non-unique
      • getFilterCondition

        public java.lang.String getFilterCondition()
        Description copied from interface: Index
        Gets the optional filter condition.
        Specified by:
        getFilterCondition in interface Index
        Returns:
        the condition, null if none
      • getAttributes

        public java.util.List<IndexAttribute> getAttributes()
        Description copied from interface: Index
        Gets the index attributes.
        Specified by:
        getAttributes in interface Index
        Returns:
        the attributes
      • setName

        public void setName​(java.lang.String name)
      • setComment

        public void setComment​(java.lang.String comment)
      • setUnique

        public void setUnique​(boolean unique)
      • setFilterCondition

        public void setFilterCondition​(java.lang.String filterCondition)
      • setParsed

        public void setParsed​(boolean parsed)
        Sets the index to be parsed.
        Only necessary for model converters if the properties are set explicitly to prevent parsing.
        Parameters:
        parsed - true if don't parse anymore
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isParsed

        public boolean isParsed()
        Returns whether index is already parsed.
        Indexes are parsed delayed because some attributes may be added later when the whole model is known.
        Returns:
        true if parsed
      • getSourceLine

        public ConfigurationLine getSourceLine()
        Gets the source line.
        Returns:
        the line
      • setSourceLine

        public void setSourceLine​(ConfigurationLine sourceLine)
        Sets the source line.
        Parameters:
        sourceLine - the line
      • createModelException

        public ModelException createModelException​(java.lang.String message)
        Creates a model exception.

        Refers to the source line if set, otherwise just the message.

        Parameters:
        message - the message
        Returns:
        the exception
      • sqlCreateIndex

        public java.lang.String sqlCreateIndex​(org.tentackle.sql.Backend backend,
                                               Entity entity)
        Description copied from interface: Index
        Creates the index creation sql code.
        Specified by:
        sqlCreateIndex in interface Index
        Parameters:
        backend - the backend to create sql code for
        entity - the entity to create the index for
        Returns:
        the SQL code