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 java.lang.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 classAbstractManagedType.AttributeNameFilter<X>static classAbstractManagedType.AttributeTypeFilter<X,Y>Selects if the attribute type matches the given Java class.static classAbstractManagedType.DeclaredAttributeFilter<X>static classAbstractManagedType.ElementTypeFilter<X,E>Selects plural attribute of given element type.static classAbstractManagedType.EntryTypeFilter<X,K,V>static interfaceAbstractManagedType.Filter<T>Affirms if a given element satisfy a condition.static classAbstractManagedType.IdAttributeFilter<X>static classAbstractManagedType.PluralCategoryFilter<X>static classAbstractManagedType.SingularAttributeFilter<X>Affirms if the given attribute is a Singular attribute.static classAbstractManagedType.VersionAttributeFilter<X>
-
Field Summary
Fields Modifier and Type Field Description java.lang.Class<X>clsClassMetaDatametaMetamodelImplmodel
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractManagedType(java.lang.Class<X> cls, MetamodelImpl model)A protected constructor for creating psudo-managed types.AbstractManagedType(ClassMetaData meta, MetamodelImpl model)Construct a managed type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T,C extends java.util.Collection<E>,E>
Cfilter(java.util.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.jakarta.persistence.metamodel.Attribute<? super X,?>getAttribute(java.lang.String name)Returns the attribute of the given name of any type.<Y> jakarta.persistence.metamodel.Attribute<? super X,Y>getAttribute(java.lang.String name, java.lang.Class<Y> type)Returns the attribute of the given name and Java type.java.util.Set<jakarta.persistence.metamodel.Attribute<? super X,?>>getAttributes()Returns all the attributes of the managed type including attributes of the super type.jakarta.persistence.metamodel.CollectionAttribute<? super X,?>getCollection(java.lang.String name)Returns the attribute of the given name and of type java.util.Collection.<E> jakarta.persistence.metamodel.CollectionAttribute<? super X,E>getCollection(java.lang.String name, java.lang.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,?>getDeclaredAttribute(java.lang.String name)Returns the declared attribute of the given name of any type.<Y> jakarta.persistence.metamodel.Attribute<X,Y>getDeclaredAttribute(java.lang.String name, java.lang.Class<Y> type)Returns the declared attribute of the given name and Java type.java.util.Set<jakarta.persistence.metamodel.Attribute<X,?>>getDeclaredAttributes()Returns all the attributes declared by this managed type only.jakarta.persistence.metamodel.CollectionAttribute<X,?>getDeclaredCollection(java.lang.String name)Returns the declared attribute of the given name and of type java.util.Collection.<E> jakarta.persistence.metamodel.CollectionAttribute<X,E>getDeclaredCollection(java.lang.String name, java.lang.Class<E> elementType)Returns the declared attribute of the given name, of type java.util.Collection and contains the given element type.<Y> jakarta.persistence.metamodel.SingularAttribute<X,Y>getDeclaredId(java.lang.Class<Y> type)Returns the declared attribute of given type that corresponds to the id attribute of this identifiable managed type.jakarta.persistence.metamodel.ListAttribute<X,?>getDeclaredList(java.lang.String name)Returns the declared attribute of the given name and of type java.util.List.<E> jakarta.persistence.metamodel.ListAttribute<X,E>getDeclaredList(java.lang.String name, java.lang.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,?,?>getDeclaredMap(java.lang.String name)Returns the declared attribute of the given name and of type java.util.Map.<K,V>
jakarta.persistence.metamodel.MapAttribute<X,K,V>getDeclaredMap(java.lang.String name, java.lang.Class<K> keyType, java.lang.Class<V> valueType)Returns the declared attribute of the given name, of type java.util.Map and contains the given key/value type.java.util.Set<jakarta.persistence.metamodel.PluralAttribute<X,?,?>>getDeclaredPluralAttributes()Return all collection-valued attributes declared by the managed type.jakarta.persistence.metamodel.SetAttribute<X,?>getDeclaredSet(java.lang.String name)Returns the declared attribute of the given name and of type java.util.Set.<E> jakarta.persistence.metamodel.SetAttribute<X,E>getDeclaredSet(java.lang.String name, java.lang.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,?>getDeclaredSingularAttribute(java.lang.String name)Returns the declared, single-valued attribute of the given name of any type.<Y> jakarta.persistence.metamodel.SingularAttribute<X,Y>getDeclaredSingularAttribute(java.lang.String name, java.lang.Class<Y> type)Returns the declared single-valued attribute of the given name and Java type.java.util.Set<jakarta.persistence.metamodel.SingularAttribute<X,?>>getDeclaredSingularAttributes()Returns the single-valued attributes declared by the managed type.<Y> jakarta.persistence.metamodel.SingularAttribute<X,Y>getDeclaredVersion(java.lang.Class<Y> type)Returns the declared attribute of given type that corresponds to the version attribute of this managed type.<Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y>getId(java.lang.Class<Y> type)Returns the attribute of given type that corresponds to the id attribute of this identifiable managed type.java.util.Set<jakarta.persistence.metamodel.SingularAttribute<? super X,?>>getIdClassAttributes()Returns the attributes corresponding to the id class of the identifiable type.java.lang.Class<X>getJavaType()jakarta.persistence.metamodel.ListAttribute<? super X,?>getList(java.lang.String name)Returns the attribute of the given name and of type java.util.List.<E> jakarta.persistence.metamodel.ListAttribute<? super X,E>getList(java.lang.String name, java.lang.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(java.lang.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(java.lang.String name, java.lang.Class<K> keyType, java.lang.Class<V> valueType)Returns the attribute of the given name, of type java.util.Map and contains the given key/value type.java.util.Set<jakarta.persistence.metamodel.PluralAttribute<? super X,?,?>>getPluralAttributes()Returns all collection-valued attributes of the managed type.jakarta.persistence.metamodel.SetAttribute<? super X,?>getSet(java.lang.String name)Returns the attribute of the given name and of type java.util.Set.<E> jakarta.persistence.metamodel.SetAttribute<? super X,E>getSet(java.lang.String name, java.lang.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,?>getSingularAttribute(java.lang.String name)Returns the single-valued attribute of the given name of any type.<Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y>getSingularAttribute(java.lang.String name, java.lang.Class<Y> type)Returns the single-valued attribute of the given name and Java type.java.util.Set<jakarta.persistence.metamodel.SingularAttribute<? super X,?>>getSingularAttributes()Returns the single-valued attributes of the managed type.<Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y>getVersion(java.lang.Class<Y> type)Returns the attribute of given type that corresponds to the version attribute of this managed type.static <T> Tpick(java.util.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.java.lang.StringtoString()
-
-
-
Field Detail
-
model
public final MetamodelImpl model
-
meta
public final ClassMetaData meta
-
cls
public final java.lang.Class<X> cls
-
-
Constructor Detail
-
AbstractManagedType
protected AbstractManagedType(java.lang.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 Detail
-
getAttributes
public java.util.Set<jakarta.persistence.metamodel.Attribute<? super X,?>> getAttributes()
Returns all the attributes of the managed type including attributes of the super type.- Specified by:
getAttributesin interfacejakarta.persistence.metamodel.ManagedType<X>
-
getDeclaredAttributes
public java.util.Set<jakarta.persistence.metamodel.Attribute<X,?>> getDeclaredAttributes()
Returns all the attributes declared by this managed type only.- Specified by:
getDeclaredAttributesin interfacejakarta.persistence.metamodel.ManagedType<X>
-
getSingularAttributes
public java.util.Set<jakarta.persistence.metamodel.SingularAttribute<? super X,?>> getSingularAttributes()
Returns the single-valued attributes of the managed type.- Specified by:
getSingularAttributesin interfacejakarta.persistence.metamodel.ManagedType<X>
-
getDeclaredSingularAttributes
public java.util.Set<jakarta.persistence.metamodel.SingularAttribute<X,?>> getDeclaredSingularAttributes()
Returns the single-valued attributes declared by the managed type.- Specified by:
getDeclaredSingularAttributesin interfacejakarta.persistence.metamodel.ManagedType<X>
-
getAttribute
public <Y> jakarta.persistence.metamodel.Attribute<? super X,Y> getAttribute(java.lang.String name, java.lang.Class<Y> type)
Returns the attribute of the given name and Java type.- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getSingularAttribute
public <Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y> getSingularAttribute(java.lang.String name, java.lang.Class<Y> type)
Returns the single-valued attribute of the given name and Java type.- Specified by:
getSingularAttributein interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredAttribute
public <Y> jakarta.persistence.metamodel.Attribute<X,Y> getDeclaredAttribute(java.lang.String name, java.lang.Class<Y> type)
Returns the declared attribute of the given name and Java type.- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredSingularAttribute
public <Y> jakarta.persistence.metamodel.SingularAttribute<X,Y> getDeclaredSingularAttribute(java.lang.String name, java.lang.Class<Y> type)
Returns the declared single-valued attribute of the given name and Java type.- Specified by:
getDeclaredSingularAttributein interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getPluralAttributes
public java.util.Set<jakarta.persistence.metamodel.PluralAttribute<? super X,?,?>> getPluralAttributes()
Returns all collection-valued attributes of the managed type.- Specified by:
getPluralAttributesin interfacejakarta.persistence.metamodel.ManagedType<X>
-
getDeclaredPluralAttributes
public java.util.Set<jakarta.persistence.metamodel.PluralAttribute<X,?,?>> getDeclaredPluralAttributes()
Return all collection-valued attributes declared by the managed type.- Specified by:
getDeclaredPluralAttributesin interfacejakarta.persistence.metamodel.ManagedType<X>
-
getCollection
public <E> jakarta.persistence.metamodel.CollectionAttribute<? super X,E> getCollection(java.lang.String name, java.lang.Class<E> elementType)
Returns the attribute of the given name, of type java.util.Collection and contains the given element type.- Specified by:
getCollectionin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getSet
public <E> jakarta.persistence.metamodel.SetAttribute<? super X,E> getSet(java.lang.String name, java.lang.Class<E> elementType)
Returns the attribute of the given name, of type java.util.Set and contains the given element type.- Specified by:
getSetin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getList
public <E> jakarta.persistence.metamodel.ListAttribute<? super X,E> getList(java.lang.String name, java.lang.Class<E> elementType)
Returns the attribute of the given name, of type java.util.List and contains the given element type.- Specified by:
getListin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getMap
public <K,V> jakarta.persistence.metamodel.MapAttribute<? super X,K,V> getMap(java.lang.String name, java.lang.Class<K> keyType, java.lang.Class<V> valueType)
Returns the attribute of the given name, of type java.util.Map and contains the given key/value type.- Specified by:
getMapin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredCollection
public <E> jakarta.persistence.metamodel.CollectionAttribute<X,E> getDeclaredCollection(java.lang.String name, java.lang.Class<E> elementType)
Returns the declared attribute of the given name, of type java.util.Collection and contains the given element type.- Specified by:
getDeclaredCollectionin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredSet
public <E> jakarta.persistence.metamodel.SetAttribute<X,E> getDeclaredSet(java.lang.String name, java.lang.Class<E> elementType)
Returns the declared attribute of the given name, of type java.util.Set and contains the given element type.- Specified by:
getDeclaredSetin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredList
public <E> jakarta.persistence.metamodel.ListAttribute<X,E> getDeclaredList(java.lang.String name, java.lang.Class<E> elementType)
Returns the declared attribute of the given name, of type java.util.List and contains the given element type.- Specified by:
getDeclaredListin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredMap
public <K,V> jakarta.persistence.metamodel.MapAttribute<X,K,V> getDeclaredMap(java.lang.String name, java.lang.Class<K> keyType, java.lang.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:
getDeclaredMapin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getAttribute
public jakarta.persistence.metamodel.Attribute<? super X,?> getAttribute(java.lang.String name)
Returns the attribute of the given name of any type.- Specified by:
getAttributein interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredAttribute
public jakarta.persistence.metamodel.Attribute<X,?> getDeclaredAttribute(java.lang.String name)
Returns the declared attribute of the given name of any type.- Specified by:
getDeclaredAttributein interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getSingularAttribute
public jakarta.persistence.metamodel.SingularAttribute<? super X,?> getSingularAttribute(java.lang.String name)
Returns the single-valued attribute of the given name of any type.- Specified by:
getSingularAttributein interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredSingularAttribute
public jakarta.persistence.metamodel.SingularAttribute<X,?> getDeclaredSingularAttribute(java.lang.String name)
Returns the declared, single-valued attribute of the given name of any type.- Specified by:
getDeclaredSingularAttributein interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getCollection
public jakarta.persistence.metamodel.CollectionAttribute<? super X,?> getCollection(java.lang.String name)
Returns the attribute of the given name and of type java.util.Collection.- Specified by:
getCollectionin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getSet
public jakarta.persistence.metamodel.SetAttribute<? super X,?> getSet(java.lang.String name)
Returns the attribute of the given name and of type java.util.Set.- Specified by:
getSetin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getList
public jakarta.persistence.metamodel.ListAttribute<? super X,?> getList(java.lang.String name)
Returns the attribute of the given name and of type java.util.List.- Specified by:
getListin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getMap
public jakarta.persistence.metamodel.MapAttribute<? super X,?,?> getMap(java.lang.String name)
Returns the attribute of the given name and of type java.util.Map.- Specified by:
getMapin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredCollection
public jakarta.persistence.metamodel.CollectionAttribute<X,?> getDeclaredCollection(java.lang.String name)
Returns the declared attribute of the given name and of type java.util.Collection.- Specified by:
getDeclaredCollectionin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredSet
public jakarta.persistence.metamodel.SetAttribute<X,?> getDeclaredSet(java.lang.String name)
Returns the declared attribute of the given name and of type java.util.Set.- Specified by:
getDeclaredSetin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredList
public jakarta.persistence.metamodel.ListAttribute<X,?> getDeclaredList(java.lang.String name)
Returns the declared attribute of the given name and of type java.util.List.- Specified by:
getDeclaredListin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredMap
public jakarta.persistence.metamodel.MapAttribute<X,?,?> getDeclaredMap(java.lang.String name)
Returns the declared attribute of the given name and of type java.util.Map.- Specified by:
getDeclaredMapin interfacejakarta.persistence.metamodel.ManagedType<X>- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getIdClassAttributes
public final java.util.Set<jakarta.persistence.metamodel.SingularAttribute<? super X,?>> getIdClassAttributes()
Returns the attributes corresponding to the id class of the identifiable type.- Throws:
java.lang.IllegalArgumentException- if the this type is not using an id class
-
getId
public final <Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y> getId(java.lang.Class<Y> type)
Returns the attribute of given type that corresponds to the id attribute of this identifiable managed type.- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredId
public final <Y> jakarta.persistence.metamodel.SingularAttribute<X,Y> getDeclaredId(java.lang.Class<Y> type)
Returns the declared attribute of given type that corresponds to the id attribute of this identifiable managed type.- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getVersion
public <Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y> getVersion(java.lang.Class<Y> type)
Returns the attribute of given type that corresponds to the version attribute of this managed type.- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
getDeclaredVersion
public <Y> jakarta.persistence.metamodel.SingularAttribute<X,Y> getDeclaredVersion(java.lang.Class<Y> type)
Returns the declared attribute of given type that corresponds to the version attribute of this managed type.- Throws:
java.lang.IllegalArgumentException- if no such attribute exists
-
filter
public static <T,C extends java.util.Collection<E>,E> C filter(java.util.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(java.util.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 java.lang.Class<X> getJavaType()
- Specified by:
getJavaTypein interfacejakarta.persistence.metamodel.Type<X>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-