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.internal.types;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import org.neo4j.driver.Value;
import org.neo4j.driver.Values;
import org.neo4j.driver.internal.AsValue;
import org.neo4j.driver.types.Entity;
import org.neo4j.driver.types.MapAccessorWithDefaultValue;
import org.neo4j.driver.types.Node;
import org.neo4j.driver.types.Path;
import org.neo4j.driver.types.Relationship;
public abstract class InternalMapAccessorWithDefaultValue implements MapAccessorWithDefaultValue {
public abstract Value get(String key);
@Override
public Value get(String key, Value defaultValue) {
return get(get(key), defaultValue);
}
private Value get(Value value, Value defaultValue) {
if (value.equals(Values.NULL)) {
return defaultValue;
} else {
return ((AsValue) value).asValue();
}
}
@Override
public Object get(String key, Object defaultValue) {
return get(get(key), defaultValue);
}
private Object get(Value value, Object defaultValue) {
if (value.equals(Values.NULL)) {
return defaultValue;
} else {
return value.asObject();
}
}
@Override
public Number get(String key, Number defaultValue) {
return get(get(key), defaultValue);
}
private Number get(Value value, Number defaultValue) {
if (value.equals(Values.NULL)) {
return defaultValue;
} else {
return value.asNumber();
}
}
@Override
public Entity get(String key, Entity defaultValue) {
return get(get(key), defaultValue);
}
private Entity get(Value value, Entity defaultValue) {
if (value.equals(Values.NULL)) {
return defaultValue;
} else {
return value.asEntity();
}
}
@Override
public Node get(String key, Node defaultValue) {
return get(get(key), defaultValue);
}
private Node get(Value value, Node defaultValue) {
if (value.equals(Values.NULL)) {
return defaultValue;
} else {
return value.asNode();
}
}
@Override
public Path get(String key, Path defaultValue) {
return get(get(key), defaultValue);
}
private Path get(Value value, Path defaultValue) {
if (value.equals(Values.NULL)) {
return defaultValue;
} else {
return value.asPath();
}
}
@Override
public Relationship get(String key, Relationship defaultValue) {
return get(get(key), defaultValue);
}
private Relationship get(Value value, Relationship defaultValue) {
if (value.equals(Values.NULL)) {
return defaultValue;
} else {
return value.asRelationship();
}
}
@Override
public List