com.sleepycat.persist.model

## Class ClassMetadata

- java.lang.Object
- - com.sleepycat.persist.model.ClassMetadata

- All Implemented Interfaces:
    java.io.Serializable

      public class ClassMetadata
      extends java.lang.Object
      implements java.io.Serializable

  The metadata for a persistent class. A persistent class may be specified with the `Entity` or `Persistent` annotation.

  `ClassMetadata` objects are thread-safe. Multiple threads may safely call the methods of a shared `ClassMetadata` object.

  This and other metadata classes are classes rather than interfaces to allow adding properties to the model at a future date without causing incompatibilities. Any such property will be given a default value and its use will be optional.

  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClassMetadata(java.lang.String className, int version, java.lang.String proxiedClassName, boolean entityClass, PrimaryKeyMetadata primaryKey, java.util.Map<java.lang.String,SecondaryKeyMetadata> secondaryKeys, java.util.List<FieldMetadata> compositeKeyFields)` Used by an `EntityModel` to construct persistent class metadata.
    `ClassMetadata(java.lang.String className, int version, java.lang.String proxiedClassName, boolean entityClass, PrimaryKeyMetadata primaryKey, java.util.Map<java.lang.String,SecondaryKeyMetadata> secondaryKeys, java.util.List<FieldMetadata> compositeKeyFields, java.util.Collection<FieldMetadata> persistentFields)` Used by an `EntityModel` to construct persistent class metadata.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object other)`
    `java.lang.String` | `getClassName()` Returns the name of the persistent class.
    `java.util.List<FieldMetadata>` | `getCompositeKeyFields()` Returns an unmodifiable list of metadata for the fields making up a composite key, or null if this is a not a composite key class.
    `java.util.Collection<FieldMetadata>` | `getPersistentFields()` Returns an unmodifiable list of metadata for the persistent fields in this class, or null if the default rules for persistent fields should be used.
    `PrimaryKeyMetadata` | `getPrimaryKey()` Returns the primary key metadata for a key declared in this class, or null if none is declared.
    `java.lang.String` | `getProxiedClassName()` Returns the class name of the proxied class if this class is a `PersistentProxy`, or null otherwise.
    `java.util.Map<java.lang.String,SecondaryKeyMetadata>` | `getSecondaryKeys()` Returns an unmodifiable map of key name (which may be different from field name) to secondary key metadata for all secondary keys declared in this class, or null if no secondary keys are declared in this class.
    `int` | `getVersion()` Returns the version of this persistent class.
    `int` | `hashCode()`
    `boolean` | `isEntityClass()` Returns whether this class is an entity class.

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

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ClassMetadata

          public ClassMetadata(java.lang.String className,
                               int version,
                               java.lang.String proxiedClassName,
                               boolean entityClass,
                               PrimaryKeyMetadata primaryKey,
                               java.util.Map<java.lang.String,SecondaryKeyMetadata> secondaryKeys,
                               java.util.List<FieldMetadata> compositeKeyFields)

      Used by an `EntityModel` to construct persistent class metadata. The optional `getPersistentFields()` property will be set to null.
      Parameters:
        `className` - the class name.
        `version` - the version.
        `proxiedClassName` - the proxied class name.
        `entityClass` - whether the class is an entity class.
        `primaryKey` - the primary key metadata.
        `secondaryKeys` - the secondary key metadata.
        `compositeKeyFields` - the composite key field metadata.

    - #### ClassMetadata

          public ClassMetadata(java.lang.String className,
                               int version,
                               java.lang.String proxiedClassName,
                               boolean entityClass,
                               PrimaryKeyMetadata primaryKey,
                               java.util.Map<java.lang.String,SecondaryKeyMetadata> secondaryKeys,
                               java.util.List<FieldMetadata> compositeKeyFields,
                               java.util.Collection<FieldMetadata> persistentFields)

      Used by an `EntityModel` to construct persistent class metadata.
      Parameters:
        `className` - the class name.
        `version` - the version.
        `proxiedClassName` - the proxied class name.
        `entityClass` - whether the class is an entity class.
        `primaryKey` - the primary key metadata.
        `secondaryKeys` - the secondary key metadata.
        `compositeKeyFields` - the composite key field metadata.
        `persistentFields` - the persistent field metadata.

  - ### Method Detail

    - #### getClassName

          public java.lang.String getClassName()

      Returns the name of the persistent class.
      Returns:
        the name of the persistent class.

    - #### getVersion

          public int getVersion()

      Returns the version of this persistent class. This may be specified using the `Entity.version()` or `Persistent.version()` annotation.
      Returns:
        the version of this persistent class.

    - #### getProxiedClassName

          public java.lang.String getProxiedClassName()

      Returns the class name of the proxied class if this class is a `PersistentProxy`, or null otherwise.
      Returns:
        the class name of the proxied class, or null.

    - #### isEntityClass

          public boolean isEntityClass()

      Returns whether this class is an entity class.
      Returns:
        whether this class is an entity class.

    - #### getPrimaryKey

          public PrimaryKeyMetadata getPrimaryKey()

      Returns the primary key metadata for a key declared in this class, or null if none is declared. This may be specified using the `PrimaryKey` annotation.
      Returns:
        the primary key metadata, or null.

    - #### getSecondaryKeys

          public java.util.Map<java.lang.String,SecondaryKeyMetadata> getSecondaryKeys()

      Returns an unmodifiable map of key name (which may be different from field name) to secondary key metadata for all secondary keys declared in this class, or null if no secondary keys are declared in this class. This metadata may be specified using `SecondaryKey` annotations.
      Returns:
        the unmodifiable map, or null.

    - #### getCompositeKeyFields

          public java.util.List<FieldMetadata> getCompositeKeyFields()

      Returns an unmodifiable list of metadata for the fields making up a composite key, or null if this is a not a composite key class. The order of the fields in the returned list determines their stored order and may be specified using the `KeyField` annotation. When the composite key class does not implement `Comparable`, the order of the fields is the relative sort order.
      Returns:
        the unmodifiable list, or null.

    - #### getPersistentFields

          public java.util.Collection<FieldMetadata> getPersistentFields()

      Returns an unmodifiable list of metadata for the persistent fields in this class, or null if the default rules for persistent fields should be used. All fields returned must be declared in this class and must be non-static.

      By default (if null is returned) the persistent fields of a class will be all declared instance fields that are non-transient (are not declared with the `transient` keyword). The default rules may be overridden by an `EntityModel`. For example, the `AnnotationModel` overrides the default rules when the `NotPersistent` or `NotTransient` annotation is specified.

      Returns:
        the unmodifiable list, or null.

    - #### equals

          public boolean equals(java.lang.Object other)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

Copyright (c) 1996, 2016 Oracle and/or its affiliates. All rights reserved.