org.qi4j.index.sql.support.common

## Class QNameInfo

- java.lang.Object
- - org.qi4j.index.sql.support.common.QNameInfo

-     public final class QNameInfo
      extends Object

  A helper interface to encapsulate information about qualified name and how it appears in database.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `QNameInfo.QNameType` Currently all possible types of qualified names: `QNameInfo.QNameType.PROPERTY` for properties, `QNameInfo.QNameType.ASSOCIATION` for associations, and `QNameInfo.QNameType.MANY_ASSOCIATION` for many-associations.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static QNameInfo` | `fromAssociation(QualifiedName qName, String tableName, AssociationDescriptor assoDescriptor)` Creates information about specified qualified name which represents an association.
    `static QNameInfo` | `fromManyAssociation(QualifiedName qName, String tableName, AssociationDescriptor manyAssoDescriptor)` Creates information about specified qualified name which represents a many-association.
    `static QNameInfo` | `fromProperty(QualifiedName qName, String tableName, PropertyDescriptor propertyDescriptor)` Creates information about specified qualified name which represents a property.
    `AssociationDescriptor` | `getAssociationDescriptor()` Returns `AssociationDescriptor` associated with this association, if this qualified name info represents an association.
    `Integer` | `getCollectionDepth()` If qualified name represented by this interface is a property with collection as type, returns the `amount of nested collections + 1`.
    `Type` | `getFinalType()` Returns the non-collection type of this qualified name.
    `AssociationDescriptor` | `getManyAssociationDescriptor()` Returns `AssociationDescriptor` associated with this many-association, if this qualified name info represents a many-association.
    `PropertyDescriptor` | `getPropertyDescriptor()` Returns `PropertyDescriptor` associated with this property, if this qualified name info represents a property.
    `QualifiedName` | `getQName()` Gets the qualified name this interface represents.
    `QNameInfo.QNameType` | `getQNameType()` Gets the type of represented qualified name: either `QNameInfo.QNameType.PROPERTY` for properties, `QNameInfo.QNameType.ASSOCIATION` for associations, or `QNameInfo.QNameType.MANY_ASSOCIATION` for many-associations.
    `String` | `getTableName()` Gets the table name in database, used to store values of the qualified name this interface represents.
    `Boolean` | `isFinalTypePrimitive()` Returns whether the final (non-collection) type of this qualified name is not seen as value composite.
    `void` | `setTableName(String tableName)` Sets the previously undecided table name to some specific one.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Method Detail

    - #### getCollectionDepth

          public Integer getCollectionDepth()

      If qualified name represented by this interface is a property with collection as type, returns the `amount of nested collections + 1`. That is, assuming `X` is not a collection, for type `Property<Set<X>>` this returns `1`, for `Property<Set<Set<X>>>` this returns `2`, etc. If qualified name represented by this interface is not a property or a property with no collection type, this method returns `0`.
      Returns:
        The collection depth (`> 0`) of qualified name, if this interface represents qualified name with collection property; `0` otherwise.

    - #### getFinalType

          public Type getFinalType()

      Returns the non-collection type of this qualified name. That is, for `Property<X>` this returns `X` if `X` is not a collection type, and for `Property<Set<Y>>` this returns `Y` if `Y` is not a collection type.
      Returns:
        The non-collection type of this qualified name.

    - #### getQName

          public QualifiedName getQName()

      Gets the qualified name this interface represents.
      Returns:
        The qualified name this interface represents.
      See Also:
        `QualifiedName`

    - #### getTableName

          public String getTableName()

      Gets the table name in database, used to store values of the qualified name this interface represents.
      Returns:
        The table name in database, used to store values of the qualified name this interface represents. May be `null` if it is not yet decided.

    - #### setTableName

          public void setTableName(String tableName)

      Sets the previously undecided table name to some specific one. This method only works when argument is `non-null` and current table name is `null`.
      Parameters:
        `tableName` - The new table name. Must be `non-null`.
      Throws:
        `IllegalArgumentException` - If `tableName` is `null`.
        `IllegalStateException` - If current table name is `non-null`.

    - #### isFinalTypePrimitive

          public Boolean isFinalTypePrimitive()

      Returns whether the final (non-collection) type of this qualified name is not seen as value composite. Always returns `false` for qualified names of type `QNameInfo.QNameType.ASSOCIATION` and `QNameInfo.QNameType.MANY_ASSOCIATION`.
      Returns:
        `true` if `getFinalType()` is not seen as value composite type; `false` otherwise.

    - #### getPropertyDescriptor

          public PropertyDescriptor getPropertyDescriptor()

      Returns `PropertyDescriptor` associated with this property, if this qualified name info represents a property. Returns `null` otherwise.
      Returns:
        `PropertyDescriptor` if this qualified name info is associated with property, `null` otherwise.

    - #### getAssociationDescriptor

          public AssociationDescriptor getAssociationDescriptor()

      Returns `AssociationDescriptor` associated with this association, if this qualified name info represents an association. Returns `null` otherwise.
      Returns:
        `AssociationDescriptor` if this qualified name info is associated with association, `null` otherwise.

    - #### getManyAssociationDescriptor

          public AssociationDescriptor getManyAssociationDescriptor()

      Returns `AssociationDescriptor` associated with this many-association, if this qualified name info represents a many-association. Returns `null` otherwise.
      Returns:
        `AssociationDescriptor` if this qualified name info is associated with many-association, `null` otherwise.

    - #### getQNameType

          public QNameInfo.QNameType getQNameType()

      Gets the type of represented qualified name: either `QNameInfo.QNameType.PROPERTY` for properties, `QNameInfo.QNameType.ASSOCIATION` for associations, or `QNameInfo.QNameType.MANY_ASSOCIATION` for many-associations.
      Returns:
        The type of represented qualified name: either `QNameInfo.QNameType.PROPERTY`, `QNameInfo.QNameType.ASSOCIATION`, or `QNameInfo.QNameType.MANY_ASSOCIATION`.

    - #### fromProperty

          public static QNameInfo fromProperty(QualifiedName qName,
                               String tableName,
                               PropertyDescriptor propertyDescriptor)

      Creates information about specified qualified name which represents a property.
      Parameters:
        `qName` - The qualified name of property.
        `tableName` - The table name where the values of all instances of propertiy with this qualified name will be stored. May be `null` if it is to be decided later.
        `propertyDescriptor` - `PropertyDescriptor` of this property.
      Returns:
        An object representing information about property with this qualified name, and how instances of this property are stored in database.

    - #### fromAssociation

          public static QNameInfo fromAssociation(QualifiedName qName,
                                  String tableName,
                                  AssociationDescriptor assoDescriptor)

      Creates information about specified qualified name which represents an association.
      Parameters:
        `qName` - The qualified name of the association.
        `tableName` - The table name where the values of all instances of association with this qualified name will be stored. May be `null` if it is to be decided later.
        `assoDescriptor` - `AssociationDescriptor` of this association.
      Returns:
        An object representing information about association with this qualified name, and how instances of this association are stored in database.

    - #### fromManyAssociation

          public static QNameInfo fromManyAssociation(QualifiedName qName,
                                      String tableName,
                                      AssociationDescriptor manyAssoDescriptor)

      Creates information about specified qualified name which represents a many-association.
      Parameters:
        `qName` - The qualified name of the many-association.
        `tableName` - The table name where the values of all instances of many-association with this qualified name will be stored. May be `null` if it is to be decided later.
        `manyAssoDescriptor` - `AssociationDescriptor` of this many-association.
      Returns:
        An object representing information about many-association with this qualified name, and how instances of this many-association are stored in database.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`