Class VectorValue
- All Implemented Interfaces:
org.neo4j.bolt.connection.values.Value, InternalValue, MapAccessor, MapAccessorWithDefaultValue, Value
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TMaps this value to the given type providing that is it supported.org.neo4j.bolt.connection.values.VectorasVector()Returns the value as anVector, if possible.org.neo4j.bolt.connection.values.Typetype()Returns the type of this value as defined in the Neo4j type system.Methods inherited from class ObjectValueAdapter
asObject, equals, hashCode, toStringMethods inherited from class ValueAdapter
asBoolean, asBoolean, asByteArray, asByteArray, asDouble, asDouble, asEntity, asFloat, asFloat, asInt, asInt, asIsoDuration, asIsoDuration, asList, asList, asList, asList, asLocalDate, asLocalDate, asLocalDateTime, asLocalDateTime, asLocalTime, asLocalTime, asLong, asLong, asMap, asMap, asMap, asMap, asMapped, asNode, asNumber, asOffsetDateTime, asOffsetDateTime, asOffsetTime, asOffsetTime, asPath, asPoint, asPoint, asRelationship, asString, asString, asUnsupportedType, asUUID, asValue, asZonedDateTime, asZonedDateTime, computeOrDefault, containsKey, get, get, hasType, isEmpty, isFalse, isNull, isTrue, keys, size, typeConstructor, values, valuesModifier and TypeMethodDescriptionbooleanReturns the value as a Java boolean, if possible.booleanasBoolean(boolean defaultValue) Returns the value as a Java boolean, if possible.byte[]Returns the value as a Java byte array, if possible.byte[]asByteArray(byte[] defaultValue) Returns the value as a Java byte array, if possible.doubleasDouble()Returns a Java double if no precision is lost in the conversion.doubleasDouble(double defaultValue) Returns a Java double if no precision is lost in the conversion.asEntity()Returns the value as aEntity, if possible.floatasFloat()Returns a Java float if no precision is lost in the conversion.floatasFloat(float defaultValue) Returns a Java float if no precision is lost in the conversion.intasInt()Returns a Java int if no precision is lost in the conversion.intasInt(int defaultValue) Returns a Java int if no precision is lost in the conversion.Returns the value as aIsoDuration, if possible.asIsoDuration(IsoDuration defaultValue) Returns the value as aIsoDuration, if possible.asList()If the underlying type can be viewed as a list, returns a java list of values, where each value has been converted usingValue.asObject().<T> List<T> Returns the value as a list of T obtained by mapping from the list elements, if possible.<T> List<T> Returns the value as a list of T obtained by mapping from the list elements, if possible.If the underlying type can be viewed as a list, returns a java list of values, where each value has been converted usingValue.asObject().Returns the value as aLocalDate, if possible.asLocalDate(LocalDate defaultValue) Returns the value as aLocalDate, if possible.Returns the value as aLocalDateTime, if possible.asLocalDateTime(LocalDateTime defaultValue) Returns the value as aLocalDateTime, if possible.Returns the value as aLocalTime, if possible.asLocalTime(LocalTime defaultValue) Returns the value as aLocalTime, if possible.longasLong()Returns a Java long if no precision is lost in the conversion.longasLong(long defaultValue) Returns a Java long if no precision is lost in the conversion.asMap()Return the underlying map as a map of string keys and values converted usingValue.asObject().Return the underlying map as a map of string keys and values converted using the supplied function.Returns the value as a map from string keys to values of type T obtained from mapping he original map values, if possible.Return as a map of string keys and values converted usingValue.asObject().protected <T> TasNode()Returns the value as aNode, if possible.asNumber()Returns the value as a Java Number, if possible.Returns the value as aOffsetDateTime, if possible.asOffsetDateTime(OffsetDateTime defaultValue) Returns the value as aOffsetDateTime, if possible.Returns the value as aOffsetTime, if possible.asOffsetTime(OffsetTime defaultValue) Returns the value as aOffsetTime, if possible.asPath()Returns the value as aPath, if possible.asPoint()Returns the value as aPoint, if possible.Returns the value as aPoint, if possible.Returns the value as aRelationship, if possible.asString()Returns the value as a Java String, if possible.Returns the value as a Java String, if possible.Returns the value as anUnsupportedType, if possible.asUUID()Returns the value as aUUID, if possible.asValue()Returns the value as aZonedDateTime, if possible.asZonedDateTime(ZonedDateTime defaultValue) Returns the value as aZonedDateTime, if possible.<T> TcomputeOrDefault(Function<Value, T> mapper, T defaultValue) booleancontainsKey(String key) Check if the list of keys contains the given keyget(int index) Retrieve the value at the given indexRetrieve the value of the property with the given keybooleanTest if this value is a value of the given type.booleanisEmpty()If this value represents a list or map, test if the collection is empty.booleanisFalse()Returnstrueif the value is a Boolean value and has the value False.booleanisNull()Returnstrueif the value is a Null, otherwisefalse.booleanisTrue()Returnstrueif the value is a Boolean value and has the value True.keys()Retrieve the keys of the underlying mapintsize()Retrieve the number of entries in this mapfinal TypeConstructorvalues()Retrieve all values of the underlying collection<T> Iterable<T> Map and retrieve all values of the underlying collectionMethods inherited from class InternalMapAccessorWithDefaultValue
get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, getModifier and TypeMethodDescriptionbooleanRetrieve the java boolean with the given key.doubleRetrieve the java double number with the given key.floatRetrieve the java float number with the given key.intRetrieve the java integer with the given key.longRetrieve the java long number with the given key.Retrieve the number with the given key.Retrieve the object with the given key.Retrieve the java string with the given key.Retrieve the list of objects with the given key.<T> List<T> Retrieve the list with the given key.Retrieve the map with the given key.Retrieve the map with the given key.Retrieve the entity with the given key.Retrieve the node with the given key.Retrieve the path with the given key.get(String key, Relationship defaultValue) Retrieve the value with the given key.Retrieve the value with the given key.Methods inherited from interface InternalValue
as, as, asBoltIsoDuration, asBoltMap, asBoltPoint, boltValues, getBoltValueModifier and TypeMethodDescriptiondefault Objectas(ParameterizedType type) default Objectdefault org.neo4j.bolt.connection.values.IsoDurationdefault org.neo4j.bolt.connection.values.Pointdefault Iterable<org.neo4j.bolt.connection.values.Value> default org.neo4j.bolt.connection.values.ValuegetBoltValue(String key)
-
Constructor Details
-
VectorValue
-
-
Method Details
-
type
-
boltValueType
public org.neo4j.bolt.connection.values.Type boltValueType() -
asVector
-
as
Description copied from interface:ValueMaps this value to the given type providing that is it supported.Basic Mapping
Supported destination types depend on the value
Type, please see the table below for more details.Object Mapping
Mapping of user-defined properties to user-defined types is supported for the following value types:
Example (using the Neo4j Movies Database):
// assuming the following Java record public record Movie(String title, String tagline, long released) {} // the nodes may be mapped to Movie instances var movies = driver.executableQuery("MATCH (movie:Movie) RETURN movie") .execute() .records() .stream() .map(record -> record.get("movie").as(Movie.class)) .toList();Note that Object Mapping is an alternative to accessing the user-defined values in a
MapAccessor. If Object Graph Mapping (OGM) is needed, please use a higher level solution built on top of the driver, like Spring Data Neo4j.The mapping is done by matching user-defined property names to target type constructor parameters. Therefore, the constructor parameters must either have
Propertyannotation or have a matching name that is available at runtime (note that the constructor parameter names are typically changed by the compiler unless either the compiler-parametersoption is used or they belong to the cannonical constructor ofjava.lang.Record). The name matching is case-sensitive.Additionally, the
Propertyannotation may be used when mapping a property with a different name tojava.lang.Recordcannonical constructor parameter.The constructor selection criteria is the following (top priority first):
- Maximum matching properties.
- Minimum mismatching properties.
Class.getDeclaredConstructors().Only constructors that are accessible or can be made accessible using
AccessibleObject.trySetAccessible()are included in the search. If multiple constructors have the same number of matching and mismatching properties, the first constructor that is accessible by default is selected.The search finishes as soon as a constructor that is accessible by default and matches all properties is found. Otherwise, it finishes once all constructors have been visited.
At least 1 property match must be present for mapping to work.
A
nullvalue is used for arguments that don't have a matching property. If the argument does not acceptnullvalue (this includes primitive types), an alternative constructor that excludes it must be available.The mapping only works for types with directly accessible constructors, not interfaces or abstract types.
Example with optional property (using the Neo4j Movies Database):
// assuming the following Java record public record Person(String name, long born) { // alternative constructor for values that don't have 'born' property available public Person(@Property("name") String name) { this(name, -1); } } // the nodes may be mapped to Person instances var persons = driver.executableQuery("MATCH (person:Person) RETURN person") .execute() .records() .stream() .map(record -> record.get("person").as(Person.class)) .toList();Types with generic parameters defined at the class level are not supported. However, constructor arguments with specific types are permitted.
Example (using the Neo4j Movies Database):
On the contrary, the following record would not be mapped because the type information is insufficient:// assuming the following Java record public record Acted(List<String> roles) {} // the relationships may be mapped to Acted instances var actedList = driver.executableQuery("MATCH ()-[acted:ACTED_IN]-() RETURN acted") .execute() .records() .stream() .map(record -> record.get("acted").as(Acted.class)) .toList();
Wildcard type value is not supported.public record Acted<T>(List<T> roles) {}- Type Parameters:
T- the target type to map to- Parameters:
targetClass- the target class to map to- Returns:
- the mapped value
- See Also:
-
asBoltVector
public org.neo4j.bolt.connection.values.Vector asBoltVector()- Specified by:
asBoltVectorin interfaceorg.neo4j.bolt.connection.values.Value- Overrides:
asBoltVectorin classValueAdapter
-