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) 2023-2024 "Neo4j,"
* Neo4j Sweden AB [https://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
*
* https://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.jdbc.values;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
abstract class AbstractMapAccessorWithDefaultValue implements MapAccessorWithDefaultValue {
@Override
public Value get(String key, Value defaultValue) {
return get(get(key), defaultValue);
}
private static 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 static 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 static 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 static 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 static 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 static 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 static Relationship get(Value value, Relationship defaultValue) {
if (value.equals(Values.NULL)) {
return defaultValue;
}
else {
return value.asRelationship();
}
}
@Override
public List