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.
Neo4j kernel is a lightweight, embedded Java database designed to
store data structured as graphs rather than tables. For more
information, see http://neo4j.org.
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package org.neo4j.kernel.impl.util;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import org.neo4j.graphdb.Entity;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Path;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.spatial.Geometry;
import org.neo4j.graphdb.spatial.Point;
import org.neo4j.util.CalledFromGeneratedCode;
import org.neo4j.values.AnyValue;
import org.neo4j.values.storable.BooleanValue;
import org.neo4j.values.storable.CoordinateReferenceSystem;
import org.neo4j.values.storable.DoubleValue;
import org.neo4j.values.storable.IntValue;
import org.neo4j.values.storable.LongValue;
import org.neo4j.values.storable.PointValue;
import org.neo4j.values.storable.TextValue;
import org.neo4j.values.storable.Value;
import org.neo4j.values.storable.Values;
import org.neo4j.values.virtual.ListValue;
import org.neo4j.values.virtual.ListValueBuilder;
import org.neo4j.values.virtual.MapValue;
import org.neo4j.values.virtual.MapValueBuilder;
import org.neo4j.values.virtual.VirtualNodeValue;
import org.neo4j.values.virtual.VirtualPathValue;
import org.neo4j.values.virtual.VirtualRelationshipValue;
import org.neo4j.values.virtual.VirtualValues;
public final class ValueUtils
{
private ValueUtils()
{
throw new UnsupportedOperationException( "do not instantiate" );
}
public static AnyValue of( Object object )
{
return of( object, false );
}
/**
* Creates an AnyValue by doing type inspection. Do not use in production code where performance is important.
*
* @param object the object to turned into a AnyValue
* @return the AnyValue corresponding to object.
*/
@SuppressWarnings( "unchecked" )
public static AnyValue of( Object object, boolean wrapEntities )
{
if ( object instanceof AnyValue )
{
return (AnyValue) object;
}
Value value = Values.unsafeOf( object, true );
if ( value != null )
{
return value;
}
else
{
if ( object instanceof Entity )
{
if ( object instanceof Node )
{
if ( wrapEntities )
{
return wrapNodeEntity( (Node) object );
}
else
{
return fromNodeEntity( (Node) object );
}
}
else if ( object instanceof Relationship )
{
if ( wrapEntities )
{
return wrapRelationshipEntity( (Relationship) object );
}
else
{
return fromRelationshipEntity( (Relationship) object );
}
}
else
{
throw new IllegalArgumentException( "Unknown entity + " + object.getClass().getName() );
}
}
else if ( object instanceof Iterable> )
{
if ( object instanceof Path )
{
if ( wrapEntities )
{
return wrapPath( (Path) object );
}
else
{
return pathReferenceFromPath( (Path) object );
}
}
else if ( object instanceof List> )
{
return asListValue( (List