|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PolymorphicTypeMapper
Represents a strategy for bi-directional mapping between entity types and
their corresponding polymorphic type flag value (if any). The mappings
represented by this strategy will usually be similar, though not
necessarily identical to the values returned by the mono-directional
mapping of entity type to table names (TableNameConverter
). A
passable description of polymorphic type flags and relationships is
available in the javadoc for the FieldNameConverter
interface.
An example set of mappings follows (assuming these are all polymorphic types):
Classname | Polymorphic Type Flag |
com.company.db.Employee | employee |
com.company.db.Manager | manager |
com.company.db.CEO | ceo |
Mappings need not be entirely unique, as long as the mappings for all
subtypes of a specific supertype are internally unique. For example, the
above example implies that all three entities are subtypes of a single
supertype (probably Person
). Thus, all of the mapping values
must be uniquely paired. However, a fourth entity could just as easily be
represented which extends an entirely separate supertype. Such an entity
would not be constrained to uniqueness with the other, unrelated entities.
However, if the hierarchy for a single supertype does not have fully-defined
and unique mappings, unexpected behavior may result (such as retrieving
references to invalid entities).
A sane implementation (using manually-specified mappings) is implemented
within the DefaultPolymorphicTypeMapper
class. Very few use-cases
call for a custom implementation of this interface directly.
Method Summary | |
---|---|
String |
convert(Class<? extends RawEntity<?>> type)
Retrieves the polymorphic type flag value which corresponds to the specified type. |
Class<? extends RawEntity<?>> |
invert(Class<? extends RawEntity<?>> parent,
String type)
Retrieves the entity type which corresponds to the given polymorphic type flag value as a subtype of the specified parent entity type. |
Method Detail |
---|
String convert(Class<? extends RawEntity<?>> type)
type
- The type for which a polymorphic flag must be generated.
invert(Class, String)
Class<? extends RawEntity<?>> invert(Class<? extends RawEntity<?>> parent, String type)
convert(Class)
method.
parent
- The parent interface of the type which must be retrieved.type
- The polymorphic type flag value which corresponds to the type
which must be retrieved.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |