org.apache.openjpa.persistence.meta
Class MetamodelImpl

java.lang.Object
  extended by org.apache.openjpa.persistence.meta.MetamodelImpl
All Implemented Interfaces:
Metamodel, Resolver

public class MetamodelImpl
extends Object
implements Metamodel, Resolver

Adapts JPA Metamodel to OpenJPA meta-data repository.

Author:
Pinaki Poddar

Constructor Summary
MetamodelImpl(MetaDataRepository repos)
          Constructs a model with the current content of the supplied non-null repository.
 
Method Summary
(package private) static PluralAttribute.CollectionType categorizeCollection(Class<?> cls)
           
 Class classForName(String name, String[] imports)
           
<X> EmbeddableType<X>
embeddable(Class<X> clazz)
          Return the metamodel embeddable type representing the embeddable class.
<X> EntityType<X>
entity(Class<X> clazz)
          Return the metamodel entity type representing the entity.
 AggregateListener getAggregateListener(String tag)
           
 OpenJPAConfiguration getConfiguration()
           
 Set<EmbeddableType<?>> getEmbeddables()
          Return the metamodel embeddable types.
 Set<EntityType<?>> getEntities()
          Return the metamodel entity types.
 FilterListener getFilterListener(String tag)
           
 Set<ManagedType<?>> getManagedTypes()
          Return the metamodel managed types.
(package private)  ParameterizedType getParameterizedType(Field mf)
          Gets the parameterized type of the given field after validating.
static Type.PersistenceType getPersistenceType(ClassMetaData meta)
           
 QueryContext getQueryContext()
           
 MetaDataRepository getRepository()
           
<X> Type<X>
getType(Class<X> cls)
          Return the type representing the basic, entity, mapped superclass, or embeddable class.
<X> ManagedType<X>
managedType(Class<X> clazz)
          Return the metamodel managed type representing the entity, mapped superclass, or embeddable class.
<X> void
populate(AbstractManagedType<X> type)
          Populate the static fields of the canonical type.
(package private)  String toTypeName(Type type)
          Pretty prints a Type.
<T> Set<T>
unmodifiableSet(Collection<T> coll)
           
(package private)  void validate(Field metaField, FieldMetaData fmd)
          Validates the given field of the meta class matches the given FieldMetaData and
(package private)
<X,Y> void
validate(Field mField, Members.Member<X,Y> member)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetamodelImpl

public MetamodelImpl(MetaDataRepository repos)
Constructs a model with the current content of the supplied non-null repository.

Method Detail

getRepository

public MetaDataRepository getRepository()

embeddable

public <X> EmbeddableType<X> embeddable(Class<X> clazz)
Return the metamodel embeddable type representing the embeddable class.

Specified by:
embeddable in interface Metamodel
Parameters:
cls - the type of the represented embeddable class
Returns:
the metamodel embeddable type
Throws:
IllegalArgumentException - if not an embeddable class

entity

public <X> EntityType<X> entity(Class<X> clazz)
Return the metamodel entity type representing the entity.

Specified by:
entity in interface Metamodel
Parameters:
cls - the type of the represented entity
Returns:
the metamodel entity type
Throws:
IllegalArgumentException - if not an entity

getEmbeddables

public Set<EmbeddableType<?>> getEmbeddables()
Return the metamodel embeddable types.

Specified by:
getEmbeddables in interface Metamodel
Returns:
the metamodel embeddable types

getEntities

public Set<EntityType<?>> getEntities()
Return the metamodel entity types.

Specified by:
getEntities in interface Metamodel
Returns:
the metamodel entity types

getManagedTypes

public Set<ManagedType<?>> getManagedTypes()
Return the metamodel managed types.

Specified by:
getManagedTypes in interface Metamodel
Returns:
the metamodel managed types

managedType

public <X> ManagedType<X> managedType(Class<X> clazz)
Return the metamodel managed type representing the entity, mapped superclass, or embeddable class.

Specified by:
managedType in interface Metamodel
Parameters:
cls - the type of the represented managed class
Returns:
the metamodel managed type
Throws:
IllegalArgumentException - if not a managed class

getType

public <X> Type<X> getType(Class<X> cls)
Return the type representing the basic, entity, mapped superclass, or embeddable class. This method differs from #type(Class) as it also creates a basic or pesudo type for the given class argument if not already available in this receiver.

Parameters:
cls - the type of the represented managed class
Returns:
the metamodel managed type
Throws:
IllegalArgumentException - if not a managed class

getPersistenceType

public static Type.PersistenceType getPersistenceType(ClassMetaData meta)

unmodifiableSet

public <T> Set<T> unmodifiableSet(Collection<T> coll)

categorizeCollection

static PluralAttribute.CollectionType categorizeCollection(Class<?> cls)

populate

public <X> void populate(AbstractManagedType<X> type)
Populate the static fields of the canonical type.


getParameterizedType

ParameterizedType getParameterizedType(Field mf)
Gets the parameterized type of the given field after validating.

Returns:
the field's type as a parameterized type. If the field is not parameterized type (that can happen for non-canonical metamodel or weaving process introducing synthetic fields), returns null.

toTypeName

String toTypeName(Type type)
Pretty prints a Type.


validate

void validate(Field metaField,
              FieldMetaData fmd)
Validates the given field of the meta class matches the given FieldMetaData and

Type Parameters:
X -
Y -
Parameters:
mField -
member -

validate

<X,Y> void validate(Field mField,
                    Members.Member<X,Y> member)

classForName

public Class classForName(String name,
                          String[] imports)
Specified by:
classForName in interface Resolver

getAggregateListener

public AggregateListener getAggregateListener(String tag)
Specified by:
getAggregateListener in interface Resolver

getConfiguration

public OpenJPAConfiguration getConfiguration()
Specified by:
getConfiguration in interface Resolver

getFilterListener

public FilterListener getFilterListener(String tag)
Specified by:
getFilterListener in interface Resolver

getQueryContext

public QueryContext getQueryContext()
Specified by:
getQueryContext in interface Resolver


Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.