Package org.neo4j.ogm.annotation
Annotation Interface Properties
Tells OGM to map values of a Map field in a node or relationship entity to properties of a node or a relationship
in the graph.
The property names are derived from field name or
prefix()
, delimiter and keys in the Map. If the delimiter,
prefix or keys conflict with other field names in the class the behaviour is not defined.
Supported types for keys in the Map are String and Enum.
The values in the Map can be of any Java type equivalent to Cypher types. Type derivation works best when you use concrete
types in the declaration of the map (i.e. Map<String, Long>
as we are able to use this information most of the
time. In case you want Enum values, you must declare the composite property as Map<SUPPORTED_KEY_TYPE, YourEnumType>
.
Otherwise only writing, but not reading into an enum is supported.
If allowCast()
is set to true then types that can be cast to corresponding Cypher types are allowed as well.- Since:
- 3.0
- Author:
- Frantisek Hartman, Michael J. Simons
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static enum
Phase of the mapping currently taking place. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
Some Java types, like Integer and Float, can be automatically cast into a wider type, like Long and Double, by the Neo4j type systems.Allows for specifying a prefix for the map properties.Class<? extends BiFunction<Properties.Phase,
String, String>> This attribute allows for configuring a transformation that is applied to enum properties.
-
Element Details
-
prefix
String prefixAllows for specifying a prefix for the map properties. OGM defaults to the field name of the map attribute when not set.- Returns:
- The prefix for mapped properties.
- Default:
- ""
-
delimiter
String delimiter- Returns:
- Delimiter to use in the property names
- Default:
- "."
-
allowCast
boolean allowCastSome Java types, like Integer and Float, can be automatically cast into a wider type, like Long and Double, by the Neo4j type systems. This in most cases not what one does expect during mapping. We have however not a way to determine whether the type of the value put into the map was supposed originally when reading the instance containing the map back. Set this attribute to true to allow OGM to accept the automatic cast.- Returns:
- True, when the values of map entries are allowed to be cast to a wider datatype.
- Default:
- false
-
transformEnumKeysWith
Class<? extends BiFunction<Properties.Phase,String, transformEnumKeysWithString>> This attribute allows for configuring a transformation that is applied to enum properties.Properties.Phase.TO_GRAPH
is applied before the name of the enum is written to the graph,Properties.Phase.TO_ENTITY
is applied before an instance of the enum value is referenced.- Returns:
- A transformation to be used on enum keys.
- Default:
- org.neo4j.ogm.annotation.Properties.NoopTransformation.class
-