Class AbstractManagedType<X>

java.lang.Object
org.apache.openjpa.persistence.meta.AbstractManagedType<X>
Type Parameters:
X - the
All Implemented Interfaces:
jakarta.persistence.metamodel.ManagedType<X>, jakarta.persistence.metamodel.Type<X>
Direct Known Subclasses:
Types.Embeddable, Types.Identifiable, Types.PseudoEntity

public abstract class AbstractManagedType<X> extends Object implements jakarta.persistence.metamodel.ManagedType<X>
Implements the managed persistent type and its attributes. Provides identity and version attribute facilities for Identifiable type but does not implement it.
Author:
Pinaki Poddar
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
     
    static final class 
    Selects if the attribute type matches the given Java class.
    static final class 
     
    static final class 
    Selects plural attribute of given element type.
    static final class 
     
    static interface 
    Affirms if a given element satisfy a condition.
    static final class 
     
    static final class 
     
    static final class 
    Affirms if the given attribute is a Singular attribute.
    static final class 
     

    Nested classes/interfaces inherited from interface jakarta.persistence.metamodel.Type

    jakarta.persistence.metamodel.Type.PersistenceType
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Class<X>
     
     
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    A protected constructor for creating psudo-managed types.
     
    Construct a managed type.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T, C extends Collection<E>, E>
    C
    Applies chain of filters ANDed on the given collection to populate the given result.
    jakarta.persistence.metamodel.Attribute<? super X,?>
    Returns the attribute of the given name of any type.
    <Y> jakarta.persistence.metamodel.Attribute<? super X,Y>
    getAttribute(String name, Class<Y> type)
    Returns the attribute of the given name and Java type.
    Set<jakarta.persistence.metamodel.Attribute<? super X,?>>
    Returns all the attributes of the managed type including attributes of the super type.
    jakarta.persistence.metamodel.CollectionAttribute<? super X,?>
    Returns the attribute of the given name and of type java.util.Collection.
    <E> jakarta.persistence.metamodel.CollectionAttribute<? super X,E>
    getCollection(String name, Class<E> elementType)
    Returns the attribute of the given name, of type java.util.Collection and contains the given element type.
    jakarta.persistence.metamodel.Attribute<X,?>
    Returns the declared attribute of the given name of any type.
    <Y> jakarta.persistence.metamodel.Attribute<X,Y>
    Returns the declared attribute of the given name and Java type.
    Set<jakarta.persistence.metamodel.Attribute<X,?>>
    Returns all the attributes declared by this managed type only.
    jakarta.persistence.metamodel.CollectionAttribute<X,?>
    Returns the declared attribute of the given name and of type java.util.Collection.
    <E> jakarta.persistence.metamodel.CollectionAttribute<X,E>
    getDeclaredCollection(String name, Class<E> elementType)
    Returns the declared attribute of the given name, of type java.util.Collection and contains the given element type.
    final <Y> jakarta.persistence.metamodel.SingularAttribute<X,Y>
    Returns the declared attribute of given type that corresponds to the id attribute of this identifiable managed type.
    jakarta.persistence.metamodel.ListAttribute<X,?>
    Returns the declared attribute of the given name and of type java.util.List.
    <E> jakarta.persistence.metamodel.ListAttribute<X,E>
    getDeclaredList(String name, Class<E> elementType)
    Returns the declared attribute of the given name, of type java.util.List and contains the given element type.
    jakarta.persistence.metamodel.MapAttribute<X,?,?>
    Returns the declared attribute of the given name and of type java.util.Map.
    <K, V> jakarta.persistence.metamodel.MapAttribute<X,K,V>
    getDeclaredMap(String name, Class<K> keyType, Class<V> valueType)
    Returns the declared attribute of the given name, of type java.util.Map and contains the given key/value type.
    Set<jakarta.persistence.metamodel.PluralAttribute<X,?,?>>
    Return all collection-valued attributes declared by the managed type.
    jakarta.persistence.metamodel.SetAttribute<X,?>
    Returns the declared attribute of the given name and of type java.util.Set.
    <E> jakarta.persistence.metamodel.SetAttribute<X,E>
    getDeclaredSet(String name, Class<E> elementType)
    Returns the declared attribute of the given name, of type java.util.Set and contains the given element type.
    jakarta.persistence.metamodel.SingularAttribute<X,?>
    Returns the declared, single-valued attribute of the given name of any type.
    <Y> jakarta.persistence.metamodel.SingularAttribute<X,Y>
    Returns the declared single-valued attribute of the given name and Java type.
    Set<jakarta.persistence.metamodel.SingularAttribute<X,?>>
    Returns the single-valued attributes declared by the managed type.
    <Y> jakarta.persistence.metamodel.SingularAttribute<X,Y>
    Returns the declared attribute of given type that corresponds to the version attribute of this managed type.
    final <Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y>
    getId(Class<Y> type)
    Returns the attribute of given type that corresponds to the id attribute of this identifiable managed type.
    final Set<jakarta.persistence.metamodel.SingularAttribute<? super X,?>>
    Returns the attributes corresponding to the id class of the identifiable type.
    final Class<X>
     
    jakarta.persistence.metamodel.ListAttribute<? super X,?>
    Returns the attribute of the given name and of type java.util.List.
    <E> jakarta.persistence.metamodel.ListAttribute<? super X,E>
    getList(String name, Class<E> elementType)
    Returns the attribute of the given name, of type java.util.List and contains the given element type.
    jakarta.persistence.metamodel.MapAttribute<? super X,?,?>
    getMap(String name)
    Returns the attribute of the given name and of type java.util.Map.
    <K, V> jakarta.persistence.metamodel.MapAttribute<? super X,K,V>
    getMap(String name, Class<K> keyType, Class<V> valueType)
    Returns the attribute of the given name, of type java.util.Map and contains the given key/value type.
    Set<jakarta.persistence.metamodel.PluralAttribute<? super X,?,?>>
    Returns all collection-valued attributes of the managed type.
    jakarta.persistence.metamodel.SetAttribute<? super X,?>
    getSet(String name)
    Returns the attribute of the given name and of type java.util.Set.
    <E> jakarta.persistence.metamodel.SetAttribute<? super X,E>
    getSet(String name, Class<E> elementType)
    Returns the attribute of the given name, of type java.util.Set and contains the given element type.
    jakarta.persistence.metamodel.SingularAttribute<? super X,?>
    Returns the single-valued attribute of the given name of any type.
    <Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y>
    Returns the single-valued attribute of the given name and Java type.
    Set<jakarta.persistence.metamodel.SingularAttribute<? super X,?>>
    Returns the single-valued attributes of the managed type.
    <Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y>
    getVersion(Class<Y> type)
    Returns the attribute of given type that corresponds to the version attribute of this managed type.
    static <T> T
    Applies chain of filters ANDed on the given collection to pick a single element.
     

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface jakarta.persistence.metamodel.Type

    getJavaType, getPersistenceType
  • Field Details

  • Constructor Details

    • AbstractManagedType

      protected AbstractManagedType(Class<X> cls, MetamodelImpl model)
      A protected constructor for creating psudo-managed types.
    • AbstractManagedType

      public AbstractManagedType(ClassMetaData meta, MetamodelImpl model)
      Construct a managed type. The supplied metadata must be resolved i.e. all its fields populated. Because this receiver will populate its attributes corresponding to the available fields of the metadata.
  • Method Details

    • getAttributes

      public Set<jakarta.persistence.metamodel.Attribute<? super X,?>> getAttributes()
      Returns all the attributes of the managed type including attributes of the super type.
      Specified by:
      getAttributes in interface jakarta.persistence.metamodel.ManagedType<X>
    • getDeclaredAttributes

      public Set<jakarta.persistence.metamodel.Attribute<X,?>> getDeclaredAttributes()
      Returns all the attributes declared by this managed type only.
      Specified by:
      getDeclaredAttributes in interface jakarta.persistence.metamodel.ManagedType<X>
    • getSingularAttributes

      public Set<jakarta.persistence.metamodel.SingularAttribute<? super X,?>> getSingularAttributes()
      Returns the single-valued attributes of the managed type.
      Specified by:
      getSingularAttributes in interface jakarta.persistence.metamodel.ManagedType<X>
    • getDeclaredSingularAttributes

      public Set<jakarta.persistence.metamodel.SingularAttribute<X,?>> getDeclaredSingularAttributes()
      Returns the single-valued attributes declared by the managed type.
      Specified by:
      getDeclaredSingularAttributes in interface jakarta.persistence.metamodel.ManagedType<X>
    • getAttribute

      public <Y> jakarta.persistence.metamodel.Attribute<? super X,Y> getAttribute(String name, Class<Y> type)
      Returns the attribute of the given name and Java type.
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getSingularAttribute

      public <Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y> getSingularAttribute(String name, Class<Y> type)
      Returns the single-valued attribute of the given name and Java type.
      Specified by:
      getSingularAttribute in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredAttribute

      public <Y> jakarta.persistence.metamodel.Attribute<X,Y> getDeclaredAttribute(String name, Class<Y> type)
      Returns the declared attribute of the given name and Java type.
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredSingularAttribute

      public <Y> jakarta.persistence.metamodel.SingularAttribute<X,Y> getDeclaredSingularAttribute(String name, Class<Y> type)
      Returns the declared single-valued attribute of the given name and Java type.
      Specified by:
      getDeclaredSingularAttribute in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getPluralAttributes

      public Set<jakarta.persistence.metamodel.PluralAttribute<? super X,?,?>> getPluralAttributes()
      Returns all collection-valued attributes of the managed type.
      Specified by:
      getPluralAttributes in interface jakarta.persistence.metamodel.ManagedType<X>
    • getDeclaredPluralAttributes

      public Set<jakarta.persistence.metamodel.PluralAttribute<X,?,?>> getDeclaredPluralAttributes()
      Return all collection-valued attributes declared by the managed type.
      Specified by:
      getDeclaredPluralAttributes in interface jakarta.persistence.metamodel.ManagedType<X>
    • getCollection

      public <E> jakarta.persistence.metamodel.CollectionAttribute<? super X,E> getCollection(String name, Class<E> elementType)
      Returns the attribute of the given name, of type java.util.Collection and contains the given element type.
      Specified by:
      getCollection in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getSet

      public <E> jakarta.persistence.metamodel.SetAttribute<? super X,E> getSet(String name, Class<E> elementType)
      Returns the attribute of the given name, of type java.util.Set and contains the given element type.
      Specified by:
      getSet in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getList

      public <E> jakarta.persistence.metamodel.ListAttribute<? super X,E> getList(String name, Class<E> elementType)
      Returns the attribute of the given name, of type java.util.List and contains the given element type.
      Specified by:
      getList in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getMap

      public <K, V> jakarta.persistence.metamodel.MapAttribute<? super X,K,V> getMap(String name, Class<K> keyType, Class<V> valueType)
      Returns the attribute of the given name, of type java.util.Map and contains the given key/value type.
      Specified by:
      getMap in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredCollection

      public <E> jakarta.persistence.metamodel.CollectionAttribute<X,E> getDeclaredCollection(String name, Class<E> elementType)
      Returns the declared attribute of the given name, of type java.util.Collection and contains the given element type.
      Specified by:
      getDeclaredCollection in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredSet

      public <E> jakarta.persistence.metamodel.SetAttribute<X,E> getDeclaredSet(String name, Class<E> elementType)
      Returns the declared attribute of the given name, of type java.util.Set and contains the given element type.
      Specified by:
      getDeclaredSet in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredList

      public <E> jakarta.persistence.metamodel.ListAttribute<X,E> getDeclaredList(String name, Class<E> elementType)
      Returns the declared attribute of the given name, of type java.util.List and contains the given element type.
      Specified by:
      getDeclaredList in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredMap

      public <K, V> jakarta.persistence.metamodel.MapAttribute<X,K,V> getDeclaredMap(String name, Class<K> keyType, Class<V> valueType)
      Returns the declared attribute of the given name, of type java.util.Map and contains the given key/value type.
      Specified by:
      getDeclaredMap in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getAttribute

      public jakarta.persistence.metamodel.Attribute<? super X,?> getAttribute(String name)
      Returns the attribute of the given name of any type.
      Specified by:
      getAttribute in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredAttribute

      public jakarta.persistence.metamodel.Attribute<X,?> getDeclaredAttribute(String name)
      Returns the declared attribute of the given name of any type.
      Specified by:
      getDeclaredAttribute in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getSingularAttribute

      public jakarta.persistence.metamodel.SingularAttribute<? super X,?> getSingularAttribute(String name)
      Returns the single-valued attribute of the given name of any type.
      Specified by:
      getSingularAttribute in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredSingularAttribute

      public jakarta.persistence.metamodel.SingularAttribute<X,?> getDeclaredSingularAttribute(String name)
      Returns the declared, single-valued attribute of the given name of any type.
      Specified by:
      getDeclaredSingularAttribute in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getCollection

      public jakarta.persistence.metamodel.CollectionAttribute<? super X,?> getCollection(String name)
      Returns the attribute of the given name and of type java.util.Collection.
      Specified by:
      getCollection in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getSet

      public jakarta.persistence.metamodel.SetAttribute<? super X,?> getSet(String name)
      Returns the attribute of the given name and of type java.util.Set.
      Specified by:
      getSet in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getList

      public jakarta.persistence.metamodel.ListAttribute<? super X,?> getList(String name)
      Returns the attribute of the given name and of type java.util.List.
      Specified by:
      getList in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getMap

      public jakarta.persistence.metamodel.MapAttribute<? super X,?,?> getMap(String name)
      Returns the attribute of the given name and of type java.util.Map.
      Specified by:
      getMap in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredCollection

      public jakarta.persistence.metamodel.CollectionAttribute<X,?> getDeclaredCollection(String name)
      Returns the declared attribute of the given name and of type java.util.Collection.
      Specified by:
      getDeclaredCollection in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredSet

      public jakarta.persistence.metamodel.SetAttribute<X,?> getDeclaredSet(String name)
      Returns the declared attribute of the given name and of type java.util.Set.
      Specified by:
      getDeclaredSet in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredList

      public jakarta.persistence.metamodel.ListAttribute<X,?> getDeclaredList(String name)
      Returns the declared attribute of the given name and of type java.util.List.
      Specified by:
      getDeclaredList in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredMap

      public jakarta.persistence.metamodel.MapAttribute<X,?,?> getDeclaredMap(String name)
      Returns the declared attribute of the given name and of type java.util.Map.
      Specified by:
      getDeclaredMap in interface jakarta.persistence.metamodel.ManagedType<X>
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getIdClassAttributes

      public final Set<jakarta.persistence.metamodel.SingularAttribute<? super X,?>> getIdClassAttributes()
      Returns the attributes corresponding to the id class of the identifiable type.
      Throws:
      IllegalArgumentException - if the this type is not using an id class
    • getId

      public final <Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y> getId(Class<Y> type)
      Returns the attribute of given type that corresponds to the id attribute of this identifiable managed type.
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredId

      public final <Y> jakarta.persistence.metamodel.SingularAttribute<X,Y> getDeclaredId(Class<Y> type)
      Returns the declared attribute of given type that corresponds to the id attribute of this identifiable managed type.
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getVersion

      public <Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y> getVersion(Class<Y> type)
      Returns the attribute of given type that corresponds to the version attribute of this managed type.
      Throws:
      IllegalArgumentException - if no such attribute exists
    • getDeclaredVersion

      public <Y> jakarta.persistence.metamodel.SingularAttribute<X,Y> getDeclaredVersion(Class<Y> type)
      Returns the declared attribute of given type that corresponds to the version attribute of this managed type.
      Throws:
      IllegalArgumentException - if no such attribute exists
    • filter

      public static <T, C extends Collection<E>, E> C filter(Collection<T> original, C result, AbstractManagedType.Filter<T> f1, AbstractManagedType.Filter<T> f2, AbstractManagedType.Filter<T> f3, AbstractManagedType.Filter<T> f4)
      Applies chain of filters ANDed on the given collection to populate the given result. A null filter evaluates always TRUE. The arguments are not passed as variable argument list to suppress warnings in in the caller for generic varargs array construction.
    • pick

      public static <T> T pick(Collection<T> original, AbstractManagedType.Filter<T> f1, AbstractManagedType.Filter<T> f2, AbstractManagedType.Filter<T> f3, AbstractManagedType.Filter<T> f4)
      Applies chain of filters ANDed on the given collection to pick a single element. A null filter evaluates always TRUE. The arguments are not passed as variable argument list to suppress warnings in in the caller for generic varargs array construction.
    • getJavaType

      public final Class<X> getJavaType()
      Specified by:
      getJavaType in interface jakarta.persistence.metamodel.Type<X>
    • toString

      public String toString()
      Overrides:
      toString in class Object