org.neo4j.driver.v1.Values Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neo4j-java-driver Show documentation
Show all versions of neo4j-java-driver Show documentation
Access to the Neo4j graph database through Java
/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.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.v1;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.neo4j.driver.internal.AsValue;
import org.neo4j.driver.internal.value.BooleanValue;
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.MapValue;
import org.neo4j.driver.internal.value.NullValue;
import org.neo4j.driver.internal.value.StringValue;
import org.neo4j.driver.v1.exceptions.ClientException;
/**
* Utility for wrapping regular Java types and exposing them as {@link Value}
* objects.
*/
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 Collection> ) { return value( (List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy