Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.driver;
import static org.neo4j.driver.internal.util.Extract.assertParameter;
import static org.neo4j.driver.internal.util.Iterables.newHashMapWithSize;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.Period;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Stream;
import org.neo4j.driver.exceptions.ClientException;
import org.neo4j.driver.internal.AsValue;
import org.neo4j.driver.internal.InternalIsoDuration;
import org.neo4j.driver.internal.InternalPoint2D;
import org.neo4j.driver.internal.InternalPoint3D;
import org.neo4j.driver.internal.value.BooleanValue;
import org.neo4j.driver.internal.value.BytesValue;
import org.neo4j.driver.internal.value.DateTimeValue;
import org.neo4j.driver.internal.value.DateValue;
import org.neo4j.driver.internal.value.DurationValue;
import org.neo4j.driver.internal.value.FloatValue;
import org.neo4j.driver.internal.value.IntegerValue;
import org.neo4j.driver.internal.value.ListValue;
import org.neo4j.driver.internal.value.LocalDateTimeValue;
import org.neo4j.driver.internal.value.LocalTimeValue;
import org.neo4j.driver.internal.value.MapValue;
import org.neo4j.driver.internal.value.NullValue;
import org.neo4j.driver.internal.value.PointValue;
import org.neo4j.driver.internal.value.StringValue;
import org.neo4j.driver.internal.value.TimeValue;
import org.neo4j.driver.types.Entity;
import org.neo4j.driver.types.IsoDuration;
import org.neo4j.driver.types.MapAccessor;
import org.neo4j.driver.types.Node;
import org.neo4j.driver.types.Path;
import org.neo4j.driver.types.Point;
import org.neo4j.driver.types.Relationship;
import org.neo4j.driver.types.TypeSystem;
/**
* Utility for wrapping regular Java types and exposing them as {@link Value}
* objects, and vice versa.
*
* The long set of {@code ofXXX} methods in this class are meant to be used as
* arguments for methods like {@link Value#asList(Function)}, {@link Value#asMap(Function)},
* {@link Record#asMap(Function)} and so on.
*
* @since 1.0
*/
public abstract class Values {
public static final Value EmptyMap = value(Collections.emptyMap());
public static final Value NULL = NullValue.NULL;
private Values() {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public static Value value(Object value) {
if (value == null) {
return NullValue.NULL;
}
if (value instanceof AsValue) {
return ((AsValue) value).asValue();
}
if (value instanceof Boolean) {
return value((boolean) value);
}
if (value instanceof String) {
return value((String) value);
}
if (value instanceof Character) {
return value((char) value);
}
if (value instanceof Long) {
return value((long) value);
}
if (value instanceof Short) {
return value((short) value);
}
if (value instanceof Byte) {
return value((byte) value);
}
if (value instanceof Integer) {
return value((int) value);
}
if (value instanceof Double) {
return value((double) value);
}
if (value instanceof Float) {
return value((float) value);
}
if (value instanceof LocalDate) {
return value((LocalDate) value);
}
if (value instanceof OffsetTime) {
return value((OffsetTime) value);
}
if (value instanceof LocalTime) {
return value((LocalTime) value);
}
if (value instanceof LocalDateTime) {
return value((LocalDateTime) value);
}
if (value instanceof OffsetDateTime) {
return value((OffsetDateTime) value);
}
if (value instanceof ZonedDateTime) {
return value((ZonedDateTime) value);
}
if (value instanceof IsoDuration) {
return value((IsoDuration) value);
}
if (value instanceof Period) {
return value((Period) value);
}
if (value instanceof Duration) {
return value((Duration) value);
}
if (value instanceof Point) {
return value((Point) value);
}
if (value instanceof List>) {
return value((List