Java Code Examples for org.neo4j.driver.Values#NULL
The following examples show how to use
org.neo4j.driver.Values#NULL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultNeo4jConverter.java From sdn-rx with Apache License 2.0 | 6 votes |
@Override @Nullable public Object readValueForProperty(@Nullable Value value, TypeInformation<?> type) { boolean valueIsLiteralNullOrNullValue = value == null || value == Values.NULL; try { Class<?> rawType = type.getType(); if (!valueIsLiteralNullOrNullValue && isCollection(type)) { Collection<Object> target = createCollection(rawType, type.getComponentType().getType(), value.size()); value.values().forEach( element -> target.add(conversionService.convert(element, type.getComponentType().getType()))); return target; } return conversionService.convert(valueIsLiteralNullOrNullValue ? null : value, rawType); } catch (Exception e) { String msg = String.format("Could not convert %s into %s", value, type.toString()); throw new TypeMismatchDataAccessException(msg, e); } }
Example 2
Source File: DefaultNeo4jConverter.java From sdn-rx with Apache License 2.0 | 6 votes |
@Override public Value writeValueFromProperty(@Nullable Object value, TypeInformation<?> type) { if (value == null) { return Values.NULL; } if (isCollection(type)) { Collection<?> sourceCollection = (Collection<?>) value; Object[] targetCollection = (sourceCollection).stream().map(element -> conversionService.convert(element, Value.class)).toArray(); return Values.value(targetCollection); } return conversionService.convert(value, Value.class); }
Example 3
Source File: Neo4jQuerySupport.java From sdn-rx with Apache License 2.0 | 5 votes |
/** * Converts parameter as needed by the query generated, which is not covered by standard conversion services. * * @param parameter The parameter to fit into the generated query. * @return A parameter that fits the place holders of a generated query */ final Object convertParameter(Object parameter) { if (parameter == null) { // According to https://neo4j.com/docs/cypher-manual/current/syntax/working-with-null/#cypher-null-intro // it does not make any sense to continue if a `null` value gets into a comparison // but we just warn the users and do not throw an exception on `null`. log.warn("Do not use `null` as a property value for comparison." + " It will always be false and return an empty result."); return Values.NULL; } // Maybe move all of those into Neo4jConverter at some point. if (parameter instanceof Range) { return convertRange((Range) parameter); } else if (parameter instanceof Distance) { return calculateDistanceInMeter((Distance) parameter); } else if (parameter instanceof Circle) { return convertCircle((Circle) parameter); } else if (parameter instanceof Instant) { return ((Instant) parameter).atOffset(ZoneOffset.UTC); } else if (parameter instanceof Box) { return convertBox((Box) parameter); } else if (parameter instanceof BoundingBox) { return convertBoundingBox((BoundingBox) parameter); } // Good hook to check the NodeManager whether the thing is an entity and we replace the value with a known id. return mappingContext.getConverter() .writeValueFromProperty(parameter, ClassTypeInformation.from(parameter.getClass())); }
Example 4
Source File: AdditionalTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
static Value value(UUID uuid) { if (uuid == null) { return Values.NULL; } return Values.value(uuid.toString()); }
Example 5
Source File: AdditionalTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
static Value value(BigDecimal bigDecimal) { if (bigDecimal == null) { return Values.NULL; } return Values.value(bigDecimal.toString()); }
Example 6
Source File: AdditionalTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
static Value value(BigInteger bigInteger) { if (bigInteger == null) { return Values.NULL; } return Values.value(bigInteger.toString()); }
Example 7
Source File: AdditionalTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
static Value value(Byte aByte) { if (aByte == null) { return Values.NULL; } return Values.value(new Byte[] { aByte }); }
Example 8
Source File: AdditionalTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
static Value value(Date date) { if (date == null) { return Values.NULL; } return Values.value(DATE_TIME_FORMATTER.format(date.toInstant().atZone(ZoneOffset.UTC.normalized()))); }
Example 9
Source File: AdditionalTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
@Override public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { if (source == null) { return Value.class.isAssignableFrom(targetType.getType()) ? Values.NULL : null; } if (Value.class.isAssignableFrom(sourceType.getType())) { return Enum.valueOf((Class<Enum>) targetType.getType(), ((Value) source).asString()); } else { return Values.value(((Enum) source).name()); } }
Example 10
Source File: AdditionalTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
static Value value(Float aFloat) { if (aFloat == null) { return Values.NULL; } return Values.value(aFloat.toString()); }
Example 11
Source File: AdditionalTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
static Value value(Locale locale) { if (locale == null) { return Values.NULL; } return Values.value(locale.toString()); }
Example 12
Source File: AdditionalTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
static Value value(Short aShort) { if (aShort == null) { return Values.NULL; } return Values.value(aShort.longValue()); }
Example 13
Source File: AdditionalTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
static Value value(float[] aFloatArray) { if (aFloatArray == null) { return Values.NULL; } String[] values = new String[aFloatArray.length]; int i = 0; for (float v : aFloatArray) { values[i++] = Float.toString(v); } return Values.value(values); }
Example 14
Source File: AdditionalTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
static Value value(short[] aShortArray) { if (aShortArray == null) { return Values.NULL; } long[] values = new long[aShortArray.length]; int i = 0; for (short v : aShortArray) { values[i++] = v; } return Values.value(values); }
Example 15
Source File: SpatialTypes.java From sdn-rx with Apache License 2.0 | 5 votes |
static Value value(Point[] aPointArray) { if (aPointArray == null) { return Values.NULL; } Value[] values = new Value[aPointArray.length]; int i = 0; for (Point v : aPointArray) { values[i++] = value(v); } return Values.value(values); }
Example 16
Source File: SingleValueMappingFunction.java From sdn-rx with Apache License 2.0 | 5 votes |
@Override public T apply(TypeSystem typeSystem, Record record) { if (record.size() == 0) { throw new IllegalArgumentException("Record has no elements, cannot map nothing."); } if (record.size() > 1) { throw new IllegalArgumentException( "Records with more than one value cannot be converted without a mapper."); } Value source = record.get(0); return source == null || source == Values.NULL ? null : conversionService.convert(source, targetClass); }