Class Type<T extends Item>
- java.lang.Object
-
- com.exedio.cope.Type<T>
-
- All Implemented Interfaces:
AbstractType<T>
,Serializable
,Comparable<Type<?>>
public final class Type<T extends Item> extends Object implements Comparable<Type<?>>, AbstractType<T>
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <X extends Item>
Type<X>as(Class<X> clazz)
<X extends Item>
Type<? extends X>asExtends(Class<X> clazz)
Type<? extends T>
asSubtype(Type<?> subtype)
Deprecated.UsecastTypeExtends(Type)
instead<X extends Item>
Type<? super X>asSuper(Class<X> clazz)
T
cast(Item item)
<X extends Item>
Type<X>castType(Class<X> clazz)
Deprecated.Useas(Class)
insteadType<? extends T>
castTypeExtends(Type<?> subtype)
int
checkCompleteness(Type<? extends T> subType)
Deprecated.UsecheckCompletenessL(Type)
insteadlong
checkCompletenessL(Type<? extends T> subType)
int
checkModificationCounter()
Deprecated.UsecheckUpdateCounter()
insteadint
checkPrimaryKey()
Deprecated.UsecheckSequenceBehindPrimaryKey()
.isBehindBy
() insteadSequenceBehindInfo
checkSequenceBehindPrimaryKey()
int
checkUpdateCounter()
Deprecated.UsecheckUpdateCounterL()
insteadlong
checkUpdateCounterL()
int
compareTo(Type<?> o)
Query<T>
emptyQuery()
static <X extends Item>
Type<X>findByJavaClass(Class<X> javaClass)
Deprecated.UseforClass(Class)
insteadstatic Type<?>
findByJavaClassUnchecked(Class<? extends Item> javaClass)
Deprecated.UseforClassUnchecked(Class)
insteadstatic <X extends Item>
Type<X>forClass(Class<X> javaClass)
Deprecated.UseTypesBound.forClass(Class)
instead.static Type<?>
forClassUnchecked(Class<? extends Item> javaClass)
Deprecated.UseTypesBound.forClassUnchecked(Class)
instead.<A extends Annotation>
AgetAnnotation(Class<A> annotationClass)
List<? extends Field<?>>
getAttributes()
Deprecated.Renamed togetFields()
.List<? extends CheckConstraint>
getCheckConstraints()
List<? extends CopyConstraint>
getCopyConstraints()
long
getCreateLimit()
List<? extends Field<?>>
getDeclaredAttributes()
Deprecated.Renamed togetDeclaredFields()
.List<? extends CheckConstraint>
getDeclaredCheckConstraints()
List<? extends CopyConstraint>
getDeclaredCopyConstraints()
Feature
getDeclaredFeature(String name)
List<? extends Feature>
getDeclaredFeatures()
List<? extends Field<?>>
getDeclaredFields()
Returns the list of persistent fields declared by the this type.List<ItemField<T>>
getDeclaredReferences()
Returns allItemField
s of the model this type belongs to, whichvalue type
equals this type.List<? extends UniqueConstraint>
getDeclaredUniqueConstraints()
Feature
getFeature(String name)
List<? extends Feature>
getFeatures()
List<? extends Field<?>>
getFields()
Returns the list of accessible persistent fields of this type.String
getID()
Returns the id of this type.Class<T>
getJavaClass()
List<String>
getLocalizationKeys()
Model
getModel()
Pattern
getPattern()
String
getPrimaryKeyColumnName()
Deprecated.UseSchemaInfo.getPrimaryKeyColumnName(Type)
insteadSequenceInfo
getPrimaryKeyInfo()
List<ItemField<? super T>>
getReferences()
Returns allItemField
s of the model this type belongs to, whichvalue type
equals this type or any of it's super types.List<? extends Type<? extends T>>
getSubtypes()
Returns all types whosesuper type
is this type.List<? extends Type<? extends T>>
getSubTypes()
Deprecated.UsegetSubtypes()
insteadList<? extends Type<? extends T>>
getSubtypesTransitively()
Returns a list of allsubtypes
and all subtypes of the subtypes etc.List<? extends Type<? extends T>>
getSubTypesTransitively()
Deprecated.UsegetSubtypesTransitively()
insteadType<? super T>
getSupertype()
Returns the type representing thesuperclass
of this type'sjava class
.String
getTableName()
Deprecated.UseSchemaInfo.getTableName(Type)
insteadThis<T>
getThis()
String
getTypeColumnName()
Deprecated.UseSchemaInfo.getTypeColumnName(Type)
insteadList<Type<? extends T>>
getTypesOfInstances()
Returns a list of types, that instances (items) of this type can have.List<? extends UniqueConstraint>
getUniqueConstraints()
boolean
hasUniqueJavaClass()
Deprecated.UseisBound()
insteadboolean
isAbstract()
boolean
isAnnotationPresent(Class<? extends Annotation> annotationClass)
boolean
isAssignableFrom(Type<?> type)
boolean
isBound()
Returns, whether this type bound to it's java class.boolean
isJavaClassExclusive()
Deprecated.UseisBound()
insteadboolean
needsCheckModificationCounter()
Deprecated.UseneedsCheckUpdateCounter()
insteadboolean
needsCheckUpdateCounter()
T
newItem(SetValue<?>... setValues)
T
newItem(List<SetValue<?>> setValues)
ItemField<T>
newItemField(ItemField.DeletePolicy policy)
Query<T>
newQuery()
Query<T>
newQuery(Condition condition)
Random
random(int seed)
List<T>
search()
Searches for all items of this type.List<T>
search(Condition condition)
Searches for items of this type, that match the given condition.List<T>
search(Condition condition, Function<?> orderBy, boolean ascending)
Searches for items of this type, that match the given condition.T
searchSingleton(Condition condition)
Searches equivalently tosearch(Condition)
, but assumes that the condition forces the search result to have at most one element.T
searchSingletonStrict(Condition condition)
Searches equivalently tosearch(Condition)
, but assumes that the condition forces the search result to have exactly one element.T
searchUnique(Condition condition)
Deprecated.renamed tosearchSingleton(Condition)
.String
toString()
-
-
-
Method Detail
-
as
public <X extends Item> Type<X> as(Class<X> clazz)
- See Also:
asExtends(Class)
,asSuper(Class)
,Class.asSubclass(Class)
-
asExtends
public <X extends Item> Type<? extends X> asExtends(Class<X> clazz)
- See Also:
as(Class)
,Class.asSubclass(Class)
-
isAnnotationPresent
public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
- See Also:
Class.isAnnotationPresent(Class)
-
getAnnotation
public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
- See Also:
Class.getAnnotation(Class)
-
getJavaClass
public Class<T> getJavaClass()
- Specified by:
getJavaClass
in interfaceAbstractType<T extends Item>
-
isBound
public boolean isBound()
Returns, whether this type bound to it's java class. Only such types can be found byTypesBound.forClass(Class)
andTypesBound.forClassUnchecked(Class)
.
-
getID
public String getID()
Returns the id of this type. Type ids are unique within amodel
. UseModel.getType(String)
for lookup.
-
getModel
public Model getModel()
-
getTypesOfInstances
public List<Type<? extends T>> getTypesOfInstances()
Returns a list of types, that instances (items) of this type can have. These are all subtypes of this type, including indirect subtypes, and including this type itself, which are not abstract.
-
getPrimaryKeyInfo
public SequenceInfo getPrimaryKeyInfo()
-
checkPrimaryKey
@Deprecated public int checkPrimaryKey()
Deprecated.UsecheckSequenceBehindPrimaryKey()
.isBehindBy
() instead- Throws:
IllegalStateException
- is a transaction is bound to the current thread
-
checkSequenceBehindPrimaryKey
public SequenceBehindInfo checkSequenceBehindPrimaryKey()
- Throws:
IllegalStateException
- is a transaction is bound to the current thread
-
getSupertype
public Type<? super T> getSupertype()
Returns the type representing thesuperclass
of this type'sjava class
. If this type has no super type (i.e. the superclass of this type's java class isItem
), then null is returned.- Specified by:
getSupertype
in interfaceAbstractType<T extends Item>
-
getSubtypes
public List<? extends Type<? extends T>> getSubtypes()
Returns all types whosesuper type
is this type.- Specified by:
getSubtypes
in interfaceAbstractType<T extends Item>
- See Also:
getSubtypesTransitively()
-
getSubtypesTransitively
public List<? extends Type<? extends T>> getSubtypesTransitively()
Returns a list of allsubtypes
and all subtypes of the subtypes etc. The result includes this type as well, as any type is its own zeroth-order subtype.- See Also:
getSubtypes()
-
isAssignableFrom
public boolean isAssignableFrom(Type<?> type)
-
castTypeExtends
public Type<? extends T> castTypeExtends(Type<?> subtype)
- See Also:
Class.cast(Object)
-
isAbstract
public boolean isAbstract()
-
getDeclaredReferences
public List<ItemField<T>> getDeclaredReferences()
Returns allItemField
s of the model this type belongs to, whichvalue type
equals this type.- See Also:
getReferences()
-
getReferences
public List<ItemField<? super T>> getReferences()
Returns allItemField
s of the model this type belongs to, whichvalue type
equals this type or any of it's super types.- See Also:
getDeclaredReferences()
-
getDeclaredFields
public List<? extends Field<?>> getDeclaredFields()
Returns the list of persistent fields declared by the this type. This excludes inherited fields. The elements in the list returned are ordered by their occurance in the source code. This method returns an empty list if the type declares no fields.If you want to get all persistent fields of this type, including fields inherited from super types, use
getFields()
.Naming of this method is inspired by Java Reflection API method
getDeclaredFields
.
-
getFields
public List<? extends Field<?>> getFields()
Returns the list of accessible persistent fields of this type. This includes inherited fields. The elements in the list returned are ordered by their type, with types higher in type hierarchy coming first, and within each type by their occurance in the source code. This method returns an empty list if the type has no accessible fields.If you want to get persistent fields declared by this type only, excluding fields inherited from super types, use
getDeclaredFields()
.
-
getDeclaredFeatures
public List<? extends Feature> getDeclaredFeatures()
- Specified by:
getDeclaredFeatures
in interfaceAbstractType<T extends Item>
-
getFeatures
public List<? extends Feature> getFeatures()
- Specified by:
getFeatures
in interfaceAbstractType<T extends Item>
-
getDeclaredFeature
public Feature getDeclaredFeature(String name)
- Specified by:
getDeclaredFeature
in interfaceAbstractType<T extends Item>
-
getFeature
public Feature getFeature(String name)
- Specified by:
getFeature
in interfaceAbstractType<T extends Item>
-
getLocalizationKeys
public List<String> getLocalizationKeys()
- Specified by:
getLocalizationKeys
in interfaceAbstractType<T extends Item>
- See Also:
LocalizationKeys
-
getDeclaredUniqueConstraints
public List<? extends UniqueConstraint> getDeclaredUniqueConstraints()
-
getUniqueConstraints
public List<? extends UniqueConstraint> getUniqueConstraints()
-
getDeclaredCheckConstraints
public List<? extends CheckConstraint> getDeclaredCheckConstraints()
-
getCheckConstraints
public List<? extends CheckConstraint> getCheckConstraints()
-
getDeclaredCopyConstraints
public List<? extends CopyConstraint> getDeclaredCopyConstraints()
-
getCopyConstraints
public List<? extends CopyConstraint> getCopyConstraints()
-
getPattern
public Pattern getPattern()
- See Also:
Pattern.getSourceTypes()
-
newItemField
public ItemField<T> newItemField(ItemField.DeletePolicy policy)
-
getCreateLimit
public long getCreateLimit()
- See Also:
CopeCreateLimit
-
search
public List<T> search()
Searches for all items of this type.Returns an unmodifiable collection. Any attempts to modify the returned collection, whether direct or via its iterator, result in an
UnsupportedOperationException
.
-
search
public List<T> search(Condition condition)
Searches for items of this type, that match the given condition.Returns an unmodifiable collection. Any attempts to modify the returned collection, whether direct or via its iterator, result in an
UnsupportedOperationException
.- Parameters:
condition
- the condition the searched items must match.
-
search
public List<T> search(Condition condition, Function<?> orderBy, boolean ascending)
Searches for items of this type, that match the given condition. The result is sorted by the given functionorderBy
.Returns an unmodifiable collection. Any attempts to modify the returned collection, whether direct or via its iterator, result in an
UnsupportedOperationException
.- Parameters:
condition
- the condition the searched items must match.ascending
- whether the result is sorted ascendingly (true</tt>) or descendingly (<tt>false
).
-
searchSingleton
public T searchSingleton(Condition condition)
Searches equivalently tosearch(Condition)
, but assumes that the condition forces the search result to have at most one element.Returns null, if the search result is
empty
, returns the only element of the search result, if the resultsize
is exactly one.- Throws:
IllegalArgumentException
- if the search result size is greater than one.- See Also:
Query.searchSingleton()
,searchSingletonStrict(Condition)
-
searchSingletonStrict
public T searchSingletonStrict(Condition condition)
Searches equivalently tosearch(Condition)
, but assumes that the condition forces the search result to have exactly one element.Returns the only element of the search result, if the result
size
is exactly one.- Throws:
IllegalArgumentException
- if the search result size is not exactly one.- See Also:
Query.searchSingletonStrict()
,searchSingleton(Condition)
-
compareTo
public int compareTo(Type<?> o)
- Specified by:
compareTo
in interfaceComparable<T extends Item>
-
checkCompletenessL
public long checkCompletenessL(Type<? extends T> subType)
- Parameters:
subType
- is allowed any type fromgetTypesOfInstances()
, but not itself.
-
needsCheckUpdateCounter
public boolean needsCheckUpdateCounter()
-
checkUpdateCounterL
public long checkUpdateCounterL()
-
random
public Random random(int seed)
-
checkUpdateCounter
@Deprecated public int checkUpdateCounter()
Deprecated.UsecheckUpdateCounterL()
instead
-
checkCompleteness
@Deprecated public int checkCompleteness(Type<? extends T> subType)
Deprecated.UsecheckCompletenessL(Type)
instead
-
asSubtype
@Deprecated public Type<? extends T> asSubtype(Type<?> subtype)
Deprecated.UsecastTypeExtends(Type)
instead
-
findByJavaClass
@Deprecated public static <X extends Item> Type<X> findByJavaClass(Class<X> javaClass)
Deprecated.UseforClass(Class)
instead
-
findByJavaClassUnchecked
@Deprecated public static Type<?> findByJavaClassUnchecked(Class<? extends Item> javaClass)
Deprecated.UseforClassUnchecked(Class)
instead
-
getTableName
@Deprecated public String getTableName()
Deprecated.UseSchemaInfo.getTableName(Type)
instead
-
getPrimaryKeyColumnName
@Deprecated public String getPrimaryKeyColumnName()
Deprecated.UseSchemaInfo.getPrimaryKeyColumnName(Type)
instead
-
getTypeColumnName
@Deprecated public String getTypeColumnName()
Deprecated.UseSchemaInfo.getTypeColumnName(Type)
instead
-
getDeclaredAttributes
@Deprecated public List<? extends Field<?>> getDeclaredAttributes()
Deprecated.Renamed togetDeclaredFields()
.
-
getAttributes
@Deprecated public List<? extends Field<?>> getAttributes()
Deprecated.Renamed togetFields()
.
-
searchUnique
@Deprecated public T searchUnique(Condition condition)
Deprecated.renamed tosearchSingleton(Condition)
.
-
castType
@Deprecated public <X extends Item> Type<X> castType(Class<X> clazz)
Deprecated.Useas(Class)
instead
-
hasUniqueJavaClass
@Deprecated public boolean hasUniqueJavaClass()
Deprecated.UseisBound()
instead
-
getSubTypes
@Deprecated public List<? extends Type<? extends T>> getSubTypes()
Deprecated.UsegetSubtypes()
instead
-
getSubTypesTransitively
@Deprecated public List<? extends Type<? extends T>> getSubTypesTransitively()
Deprecated.UsegetSubtypesTransitively()
instead
-
isJavaClassExclusive
@Deprecated public boolean isJavaClassExclusive()
Deprecated.UseisBound()
instead
-
forClass
@Deprecated public static <X extends Item> Type<X> forClass(Class<X> javaClass)
Deprecated.UseTypesBound.forClass(Class)
instead.
-
forClassUnchecked
@Deprecated public static Type<?> forClassUnchecked(Class<? extends Item> javaClass)
Deprecated.UseTypesBound.forClassUnchecked(Class)
instead.
-
needsCheckModificationCounter
@Deprecated public boolean needsCheckModificationCounter()
Deprecated.UseneedsCheckUpdateCounter()
instead
-
checkModificationCounter
@Deprecated public int checkModificationCounter()
Deprecated.UsecheckUpdateCounter()
instead
-
-