exedio cope

com.exedio.cope
Class Type<C extends Item>

java.lang.Object
  extended by com.exedio.cope.Type<C>

public final class Type<C extends Item>
extends Object


Nested Class Summary
static class Type.This<E extends Item>
           
 
Method Summary
<X extends Item>
Type<X>
as(Class<X> clazz)
           
 C cast(Item item)
           
<X extends Item>
Type<X>
castType(Class<X> clazz)
          Deprecated. Use as(Class) instead
 int checkPrimaryKey()
           
static
<X extends Item>
Type<X>
findByJavaClass(Class<X> javaClass)
          Deprecated. Use forClass(Class) instead
static Type<?> findByJavaClassUnchecked(Class<?> javaClass)
          Deprecated. Use forClassUnchecked(Class) instead
static
<X extends Item>
Type<X>
forClass(Class<X> javaClass)
           
static Type<?> forClassUnchecked(Class<?> javaClass)
           
<T extends java.lang.annotation.Annotation>
T
getAnnotation(Class<T> annotationClass)
           
 List<Field> getAttributes()
          Deprecated. Renamed to getFields().
 List<CopyConstraint> getCopyConstraints()
           
 List<Field> getDeclaredAttributes()
          Deprecated. Renamed to getDeclaredFields().
 List<CopyConstraint> getDeclaredCopyConstraints()
           
 Feature getDeclaredFeature(String name)
           
 List<Feature> getDeclaredFeatures()
           
 List<Field> getDeclaredFields()
          Returns the list of persistent fields declared by the this type.
 List<ItemField<C>> getDeclaredReferences()
          Returns all ItemFields of the model this type belongs to, which value type equals this type.
 List<UniqueConstraint> getDeclaredUniqueConstraints()
           
 Feature getFeature(String name)
           
 List<Feature> getFeatures()
           
 List<Field> getFields()
          Returns the list of accessible persistent fields of this type.
 String getID()
           
 Class<C> getJavaClass()
           
 Model getModel()
           
 Pattern getPattern()
           
 String getPrimaryKeyColumnName()
          Deprecated. Use SchemaInfo.getPrimaryKeyColumnName(Type) instead
 SequenceInfo getPrimaryKeyInfo()
           
 List<ItemField> getReferences()
          Returns all ItemFields of the model this type belongs to, which value type equals this type or any of it's super types.
 List<Type<? extends C>> getSubTypes()
           
 List<Type<? extends C>> getSubTypesTransitively()
           
 Type<? super C> getSupertype()
          Returns the type representing the superclass of this type's java class.
 String getTableName()
          Deprecated. Use SchemaInfo.getTableName(Type) instead
 Type.This<C> getThis()
           
 String getTypeColumnName()
          Deprecated. Use SchemaInfo.getTypeColumnName(Type) instead
 List<Type<? extends C>> getTypesOfInstances()
          Returns a list of types, that instances (items) of this type can have.
 List<UniqueConstraint> getUniqueConstraints()
           
 boolean hasUniqueJavaClass()
          Returns, whether this type has a java class uniquely for this type.
 boolean isAbstract()
           
 boolean isAssignableFrom(Type type)
           
 C newItem(SetValue... setValues)
           
 ItemField<C> newItemField(ItemField.DeletePolicy policy)
           
 Query<C> newQuery()
           
 Query<C> newQuery(Condition condition)
           
 List<C> search()
          Searches for all items of this type.
 List<C> search(Condition condition)
          Searches for items of this type, that match the given condition.
 List<C> search(Condition condition, Function orderBy, boolean ascending)
          Searches for items of this type, that match the given condition.
 C searchSingleton(Condition condition)
          Searches equivalently to search(Condition), but assumes that the condition forces the search result to have at most one element.
 C searchSingletonStrict(Condition condition)
          Searches equivalently to search(Condition), but assumes that the condition forces the search result to have exactly one element.
 C searchUnique(Condition condition)
          Deprecated. renamed to searchSingleton(Condition).
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

forClass

public static final <X extends Item> Type<X> forClass(Class<X> javaClass)
Throws:
IllegalArgumentException - if there is no type for the given java class.
See Also:
hasUniqueJavaClass()

as

public <X extends Item> Type<X> as(Class<X> clazz)

forClassUnchecked

public static final Type<?> forClassUnchecked(Class<?> javaClass)
Throws:
IllegalArgumentException - if there is no type for the given java class.
See Also:
hasUniqueJavaClass()

getAnnotation

public <T extends java.lang.annotation.Annotation> T getAnnotation(Class<T> annotationClass)
See Also:
Class.getAnnotation(Class)

getJavaClass

public Class<C> getJavaClass()

hasUniqueJavaClass

public boolean hasUniqueJavaClass()
Returns, whether this type has a java class uniquely for this type. Only such types can be found by forClass(Class) and forClassUnchecked(Class).


getID

public String getID()
See Also:
Model.getType(String)

getModel

public Model getModel()

getTypesOfInstances

public List<Type<? extends C>> 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

public int checkPrimaryKey()

getSupertype

public Type<? super C> getSupertype()
Returns the type representing the superclass of this type's java class. If this type has no super type (i.e. the superclass of this type's java class is Item), then null is returned.


getSubTypes

public List<Type<? extends C>> getSubTypes()
See Also:
getSubTypesTransitively()

getSubTypesTransitively

public List<Type<? extends C>> getSubTypesTransitively()
See Also:
getSubTypes()

isAssignableFrom

public boolean isAssignableFrom(Type type)

isAbstract

public boolean isAbstract()

getThis

public Type.This<C> getThis()

getDeclaredReferences

public List<ItemField<C>> getDeclaredReferences()
Returns all ItemFields of the model this type belongs to, which value type equals this type.

See Also:
getReferences()

getReferences

public List<ItemField> getReferences()
Returns all ItemFields of the model this type belongs to, which value type equals this type or any of it's super types.

See Also:
getDeclaredReferences()

getDeclaredFields

public List<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<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<Feature> getDeclaredFeatures()

getFeatures

public List<Feature> getFeatures()

getDeclaredFeature

public Feature getDeclaredFeature(String name)

getFeature

public Feature getFeature(String name)

getDeclaredUniqueConstraints

public List<UniqueConstraint> getDeclaredUniqueConstraints()

getUniqueConstraints

public List<UniqueConstraint> getUniqueConstraints()

getDeclaredCopyConstraints

public List<CopyConstraint> getDeclaredCopyConstraints()

getCopyConstraints

public List<CopyConstraint> getCopyConstraints()

getPattern

public Pattern getPattern()
See Also:
Pattern.getSourceTypes()

newItemField

public ItemField<C> newItemField(ItemField.DeletePolicy policy)

newItem

public C newItem(SetValue... setValues)
                       throws ConstraintViolationException
Throws:
ConstraintViolationException

cast

public C cast(Item item)

search

public List<C> 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<C> 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<C> 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 function orderBy.

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) or descendingly (false).

searchSingleton

public C searchSingleton(Condition condition)
Searches equivalently to search(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 result size is exactly one.

Throws:
IllegalArgumentException - if the search result size is greater than one.
See Also:
Query.searchSingleton(), searchSingletonStrict(Condition)

searchSingletonStrict

public C searchSingletonStrict(Condition condition)
Searches equivalently to search(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)

newQuery

public Query<C> newQuery()

newQuery

public Query<C> newQuery(Condition condition)

toString

public String toString()
Overrides:
toString in class Object

findByJavaClass

@Deprecated
public static final <X extends Item> Type<X> findByJavaClass(Class<X> javaClass)
Deprecated. Use forClass(Class) instead


findByJavaClassUnchecked

@Deprecated
public static final Type<?> findByJavaClassUnchecked(Class<?> javaClass)
Deprecated. Use forClassUnchecked(Class) instead


getTableName

@Deprecated
public String getTableName()
Deprecated. Use SchemaInfo.getTableName(Type) instead


getPrimaryKeyColumnName

@Deprecated
public String getPrimaryKeyColumnName()
Deprecated. Use SchemaInfo.getPrimaryKeyColumnName(Type) instead


getTypeColumnName

@Deprecated
public String getTypeColumnName()
Deprecated. Use SchemaInfo.getTypeColumnName(Type) instead


getDeclaredAttributes

@Deprecated
public List<Field> getDeclaredAttributes()
Deprecated. Renamed to getDeclaredFields().


getAttributes

@Deprecated
public List<Field> getAttributes()
Deprecated. Renamed to getFields().


searchUnique

@Deprecated
public C searchUnique(Condition condition)
Deprecated. renamed to searchSingleton(Condition).


castType

@Deprecated
public <X extends Item> Type<X> castType(Class<X> clazz)
Deprecated. Use as(Class) instead


Cope with
Object
Persistence

SourceForge.net LogoCopyright © 2004-2008 exedio Gesellschaft für Softwareentwicklung mbH. All rights reserved.
svn.12752 build.5319 20090312135114