public class Mapping extends Object
For each field, a Mapping with the same name must be defined. This mapping is used to reference the field (or its property) in queries. This adds syntactic checks and permits refactorings (renaming etc.).
An example for a field with its mapping would be:
public static final Mapping AGE = Mapping.named("age");
private int age;
Modifier and Type | Field and Description |
---|---|
static String |
NESTED_SEPARATOR
Used to join several field names (e.g. for nesteds).
|
static String |
SUBFIELD_SEPARATOR
Used to join several field names (e.g. for composites or mixins).
|
Modifier and Type | Method and Description |
---|---|
String |
getName()
Returns the field name for which this mapping was created.
|
Mapping |
getParent()
Returns the parent field.
|
Mapping |
inMixin(Class<?> mixinType)
References a mixin for an inner composite or referenced type.
|
Mapping |
inner(Mapping inner)
References an inner field of a composite represented by this mapping.
|
Mapping |
join(Mapping joinMapping)
Joins the referenced field described by joinMapping.
|
static Mapping |
mixin(Class<?> mixinType)
Creates a new Mapping for a mixin class.
|
static Mapping |
named(String name)
Creates a new Mapping.
|
Mapping |
nested(Mapping inner)
References a field of a nested list or map represented by this mapping.
|
Mapping |
nested(String inner)
References a dynamic inner property of a nested map represented by this mapping.
|
String |
toString() |
public static final String SUBFIELD_SEPARATOR
public static final String NESTED_SEPARATOR
public static Mapping named(String name)
name
- the name of the represented fieldpublic static Mapping mixin(Class<?> mixinType)
mixinType
- the class which defines the mixinpublic Mapping inner(Mapping inner)
inner
- the inner field of the composite represented by this mappingpublic Mapping nested(Mapping inner)
This is the equivalent of join(Mapping)
for NOSQL databases like Elasticsearch or Mongo DB.
inner
- the inner field of the nested represented by this mappingpublic Mapping nested(String inner)
This is the equivalent of join(Mapping)
for NOSQL databases like Elasticsearch or Mongo DB.
inner
- the inner field of the nested represented by this mappingpublic Mapping inMixin(Class<?> mixinType)
mixinType
- t the class which defines the mixinpublic Mapping join(Mapping joinMapping)
Note that this mapping needs to represent an EntityRef field.
joinMapping
- the mapping of the referenced entity to joinpublic String getName()
Note that this is not necessarily the property name as for properties in mixins or compounds, the
parent fields are appended separated by SUBFIELD_SEPARATOR
.
@Nullable public Mapping getParent()
Copyright © 2018. All rights reserved.