Class TableDef


  • public class TableDef
    extends Object
    Table definition.

    One table structure, that allows to create this table in any kind of database, with key and indices or without them.

    In addition, this struct can be serialized into a plane text and deserialized, and should allow deserialization from old versions.

    This class contains static data only and never interacts with database connections.

    Value object.

    See Also:
    SchemaDef
    • Constructor Detail

      • TableDef

        public TableDef​(@NotNull
                        String name,
                        boolean dictionary,
                        boolean temporary,
                        boolean deprecated,
                        @NotNull
                        Collection<TableFieldDef> fields,
                        @NotNull
                        Collection<TableKeyDef> keys)
        Trivial constructor.
        Parameters:
        name - table name.
        dictionary -
        temporary - table is temporary.
        deprecated -
        fields - fields in correct order.
        keys - keys and indices in correct order.
    • Method Detail

      • getName

        @NotNull
        public String getName()
      • isDictionary

        public boolean isDictionary()
        Means this table is a dictionary.
        Returns:
        whether this table is a dictionary.
        Since:
        9.0
      • isTemporary

        public boolean isTemporary()
      • isDeprecated

        public boolean isDeprecated()
      • getFields

        @NotNull
        public com.google.common.collect.ImmutableList<TableFieldDef> getFields()
      • getField

        @Nullable
        public TableFieldDef getField​(@NotNull
                                      String name)
        Looks for a filed with the given name.
        Parameters:
        name - name, case insensitive.
        Returns:
        found field, or null if not found.
      • getField

        @Nullable
        public TableFieldDef getField​(int index)
        Returns the filed by index.
        Parameters:
        index - the index of the field, starts with zero.
        Returns:
        the field.
        Throws:
        IndexOutOfBoundsException - if the index is incorrect.
        Since:
        9.0
      • indexOfField

        public int indexOfField​(@NotNull
                                String name)
        Looks for a field with the given name, and returns an index of this field.
        Parameters:
        name - name, case insensitive.
        Returns:
        index of the found field, starting with zero, or Integer.MIN_VALUE if not found.
        Since:
        9.0
      • indexOfField

        public int indexOfField​(@NotNull
                                TableFieldDef field)
        Looks for a given field and returns an index of this field.
        Parameters:
        field - the filed to look for.
        Returns:
        index of the found field, starting with zero, or Integer.MIN_VALUE if not found.
        Since:
        9.0
      • getFieldNames

        @NotNull
        public String[] getFieldNames()
      • getFieldNamesCommaDelimited

        @NotNull
        public String getFieldNamesCommaDelimited()
      • getSerialField

        @Nullable
        public TableFieldDef getSerialField()
        Returns the serial field if exists, or null if not exist.
        Returns:
        the serial filed or null.
      • getKeys

        @NotNull
        public com.google.common.collect.ImmutableList<TableKeyDef> getKeys()
      • getPrimaryKey

        @Nullable
        public TableKeyDef getPrimaryKey()
      • isFieldPrimary

        public boolean isFieldPrimary​(TableFieldDef field)
        Checks whether the specified field is in the primary key.
        Parameters:
        field - field to check.
        Returns:
        is primary.
      • isFieldPartOfKey

        public boolean isFieldPartOfKey​(TableFieldDef field,
                                        boolean includeAlternativeKeys)
      • getStableKey

        @Nullable
        public TableKeyDef getStableKey()
      • getKeyFieldsIndices

        @NotNull
        public int[] getKeyFieldsIndices​(@NotNull
                                         TableKeyDef key)