Class Values

java.lang.Object
org.neo4j.driver.Values

public final class Values extends Object
Utility for wrapping regular Java types and exposing them as Value objects, and vice versa.

The long set of ofXXX methods in this class are meant to be used as arguments for methods like Value.asList(Function), MapAccessor.asMap(Function), MapAccessor.asMap(Function) and so on.

Since:
1.0
  • Field Details

    • EmptyMap

      public static final Value EmptyMap
      The value instance of an empty map.
    • NULL

      public static final Value NULL
      The value instance of NULL.
  • Method Details

    • value

      public static Value value(Object value)
      Returns a value from object.
      Parameters:
      value - the object value
      Returns:
      the array of values
    • values

      public static Value[] values(Object... input)
      Returns an array of values from object vararg.
      Parameters:
      input - the object value(s)
      Returns:
      the array of values
    • value

      public static Value value(Value... input)
      Returns a value from value vararg.
      Parameters:
      input - the value(s)
      Returns:
      the value
    • value

      public static Value value(byte... input)
      Returns a value from byte vararg.
      Parameters:
      input - the byte value(s)
      Returns:
      the value
    • value

      public static Value value(String... input)
      Returns a value from string vararg.
      Parameters:
      input - the string value(s)
      Returns:
      the value
    • value

      public static Value value(boolean... input)
      Returns a value from boolean vararg.
      Parameters:
      input - the boolean value(s)
      Returns:
      the value
    • value

      public static Value value(char... input)
      Returns a value from char vararg.
      Parameters:
      input - the char value(s)
      Returns:
      the value
    • value

      public static Value value(long... input)
      Returns a value from long vararg.
      Parameters:
      input - the long value(s)
      Returns:
      the value
    • value

      public static Value value(short... input)
      Returns a value from short vararg.
      Parameters:
      input - the short value(s)
      Returns:
      the value
    • value

      public static Value value(int... input)
      Returns a value from int vararg.
      Parameters:
      input - the int value(s)
      Returns:
      the value
    • value

      public static Value value(double... input)
      Returns a value from double vararg.
      Parameters:
      input - the double value(s)
      Returns:
      the value
    • value

      public static Value value(float... input)
      Returns a value from float vararg.
      Parameters:
      input - the float value(s)
      Returns:
      the value
    • value

      public static Value value(List<Object> vals)
      Returns a value from list of objects.
      Parameters:
      vals - the list of objects
      Returns:
      the value
    • value

      public static Value value(Iterable<Object> val)
      Returns a value from iterable of objects.
      Parameters:
      val - the iterable of objects
      Returns:
      the value
    • value

      public static Value value(Iterator<Object> val)
      Returns a value from iterator of objects.
      Parameters:
      val - the iterator of objects
      Returns:
      the value
    • value

      public static Value value(Stream<Object> stream)
      Returns a value from stream of objects.
      Parameters:
      stream - the stream of objects
      Returns:
      the value
    • value

      public static Value value(char val)
      Returns a value from char.
      Parameters:
      val - the char value
      Returns:
      the value
    • value

      public static Value value(String val)
      Returns a value from string.
      Parameters:
      val - the string value
      Returns:
      the value
    • value

      public static Value value(long val)
      Returns a value from long.
      Parameters:
      val - the long value
      Returns:
      the value
    • value

      public static Value value(int val)
      Returns a value from int.
      Parameters:
      val - the int value
      Returns:
      the value
    • value

      public static Value value(double val)
      Returns a value from double.
      Parameters:
      val - the double value
      Returns:
      the value
    • value

      public static Value value(boolean val)
      Returns a value from boolean.
      Parameters:
      val - the boolean value
      Returns:
      the value
    • value

      public static Value value(Map<String,Object> val)
      Returns a value from string to object map.
      Parameters:
      val - the string to object map
      Returns:
      the value
    • value

      public static Value value(LocalDate localDate)
      Returns a value from local date.
      Parameters:
      localDate - the local date value
      Returns:
      the value
    • value

      public static Value value(OffsetTime offsetTime)
      Returns a value from offset time.
      Parameters:
      offsetTime - the offset time value
      Returns:
      the value
    • value

      public static Value value(LocalTime localTime)
      Returns a value from local time.
      Parameters:
      localTime - the local time value
      Returns:
      the value
    • value

      public static Value value(LocalDateTime localDateTime)
      Returns a value from local date time.
      Parameters:
      localDateTime - the local date time value
      Returns:
      the value
    • value

      public static Value value(OffsetDateTime offsetDateTime)
      Returns a value from offset date time.
      Parameters:
      offsetDateTime - the offset date time value
      Returns:
      the value
    • value

      public static Value value(ZonedDateTime zonedDateTime)
      Returns a value from zoned date time.
      Parameters:
      zonedDateTime - the zoned date time value
      Returns:
      the value
    • value

      public static Value value(Period period)
      Returns a value from period.
      Parameters:
      period - the period value
      Returns:
      the value
    • value

      public static Value value(Duration duration)
      Returns a value from duration.
      Parameters:
      duration - the duration value
      Returns:
      the value
    • isoDuration

      public static Value isoDuration(long months, long days, long seconds, int nanoseconds)
      Returns a value from month, day, seconds and nanoseconds values.
      Parameters:
      months - the month value
      days - the day value
      seconds - the seconds value
      nanoseconds - the nanoseconds value
      Returns:
      the value
    • point

      public static Value point(int srid, double x, double y)
      Returns a value from SRID, x and y values.
      Parameters:
      srid - the SRID value
      x - the x value
      y - the y value
      Returns:
      the value
    • point

      public static Value point(int srid, double x, double y, double z)
      Returns a value from SRID, x ,y and z values.
      Parameters:
      srid - the SRID value
      x - the x value
      y - the y value
      z - the z value
      Returns:
      the value
    • parameters

      public static Value parameters(Object... keysAndValues)
      Helper function for creating a map of parameters, this can be used when you run queries.

      Allowed parameter types are:

      Parameters:
      keysAndValues - alternating sequence of keys and values
      Returns:
      Map containing all parameters specified
      See Also:
    • ofValue

      public static Function<Value,Value> ofValue()
      The identity function for value conversion - returns the value untouched.
      Returns:
      a function that returns the value passed into it - the identity function
    • ofObject

      public static Function<Value,Object> ofObject()
      Converts values to objects using Value.asObject().
      Returns:
      a function that returns Value.asObject() of a Value
    • ofNumber

      public static Function<Value,Number> ofNumber()
      Converts values to Number.
      Returns:
      a function that returns Value.asNumber() of a Value
    • ofString

      public static Function<Value,String> ofString()
      Converts values to String.

      If you want to access a string you've retrieved from the database, this is the right choice. If you want to print any value for human consumption, for instance in a log, ofToString() is the right choice.

      Returns:
      a function that returns Value.asString() of a Value
    • ofToString

      public static Function<Value,String> ofToString()
      Converts values using Value.toString(), a human-readable string description of any value.

      This is different from ofString(), which returns a java String value from a database TypeSystem.STRING().

      If you are wanting to print any value for human consumption, this is the right choice. If you are wanting to access a string value stored in the database, you should use ofString().

      Returns:
      a function that returns Value.toString() of a Value
    • ofInteger

      public static Function<Value,Integer> ofInteger()
      Converts values to Integer.
      Returns:
      a function that returns Value.asInt() of a Value
    • ofLong

      public static Function<Value,Long> ofLong()
      Converts values to Long.
      Returns:
      a function that returns Value.asLong() of a Value
    • ofFloat

      public static Function<Value,Float> ofFloat()
      Converts values to Float.
      Returns:
      a function that returns Value.asFloat() of a Value
    • ofDouble

      public static Function<Value,Double> ofDouble()
      Converts values to Double.
      Returns:
      a function that returns Value.asDouble() of a Value
    • ofBoolean

      public static Function<Value,Boolean> ofBoolean()
      Converts values to Boolean.
      Returns:
      a function that returns Value.asBoolean() of a Value
    • ofMap

      public static Function<Value,Map<String,Object>> ofMap()
      Converts values to Map.
      Returns:
      a function that returns MapAccessor.asMap() of a Value
    • ofMap

      public static <T> Function<Value,Map<String,T>> ofMap(Function<Value,T> valueConverter)
      Converts values to Map, with the map values further converted using the provided converter.
      Type Parameters:
      T - the type of values in the returned map
      Parameters:
      valueConverter - converter to use for the values of the map
      Returns:
      a function that returns MapAccessor.asMap(Function) of a Value
    • ofEntity

      public static Function<Value,Entity> ofEntity()
      Converts values to Entity.
      Returns:
      a function that returns Value.asEntity() of a Value
    • ofEntityId

      @Deprecated public static Function<Value,Long> ofEntityId()
      Deprecated.
      superseded by ofEntityElementId().
      Converts values to entity id.
      Returns:
      a function that returns the id an entity Value
    • ofEntityElementId

      public static Function<Value,String> ofEntityElementId()
      Converts values to element id.
      Returns:
      a function that returns the element id of an entity Value
    • ofNode

      public static Function<Value,Node> ofNode()
      Converts values to Node.
      Returns:
      a function that returns Value.asNode() of a Value
    • ofRelationship

      public static Function<Value,Relationship> ofRelationship()
      Converts values to Relationship.
      Returns:
      a function that returns Value.asRelationship() of a Value
    • ofPath

      public static Function<Value,Path> ofPath()
      Converts values to Path.
      Returns:
      a function that returns Value.asPath() of a Value
    • ofLocalDate

      public static Function<Value,LocalDate> ofLocalDate()
      Converts values to LocalDate.
      Returns:
      a function that returns Value.asLocalDate() of a Value
    • ofOffsetTime

      public static Function<Value,OffsetTime> ofOffsetTime()
      Converts values to OffsetTime.
      Returns:
      a function that returns Value.asOffsetTime() of a Value
    • ofLocalTime

      public static Function<Value,LocalTime> ofLocalTime()
      Converts values to LocalTime.
      Returns:
      a function that returns Value.asLocalTime() of a Value
    • ofLocalDateTime

      public static Function<Value,LocalDateTime> ofLocalDateTime()
      Converts values to LocalDateTime.
      Returns:
      a function that returns Value.asLocalDateTime() of a Value
    • ofOffsetDateTime

      public static Function<Value,OffsetDateTime> ofOffsetDateTime()
      Converts values to OffsetDateTime.
      Returns:
      a function that returns Value.asOffsetDateTime() of a Value
    • ofZonedDateTime

      public static Function<Value,ZonedDateTime> ofZonedDateTime()
      Converts values to ZonedDateTime.
      Returns:
      a function that returns Value.asZonedDateTime() of a Value
    • ofIsoDuration

      public static Function<Value,IsoDuration> ofIsoDuration()
      Converts values to IsoDuration.
      Returns:
      a function that returns Value.asIsoDuration() of a Value
    • ofPoint

      public static Function<Value,Point> ofPoint()
      Converts values to Point.
      Returns:
      a function that returns Value.asPoint() of a Value
    • ofList

      public static Function<Value,List<Object>> ofList()
      Converts values to List of Object.
      Returns:
      a function that returns Value.asList() of a Value
    • ofList

      public static <T> Function<Value,List<T>> ofList(Function<Value,T> innerMap)
      Converts values to List of T.
      Type Parameters:
      T - the type of values inside the list
      Parameters:
      innerMap - converter for the values inside the list
      Returns:
      a function that returns Value.asList(Function) of a Value