com.facebook.presto.jdbc.internal.spi.function.FunctionMetadata Maven / Gradle / Ivy
/*
* 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 com.facebook.presto.jdbc.internal.spi.function;
import com.facebook.presto.jdbc.internal.common.function.OperatorType;
import com.facebook.presto.jdbc.internal.common.function.QualifiedFunctionName;
import com.facebook.presto.jdbc.internal.common.type.TypeSignature;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import static java.util.Collections.unmodifiableList;
import static java.util.Objects.requireNonNull;
public class FunctionMetadata
{
private final QualifiedFunctionName name;
private final Optional operatorType;
private final List argumentTypes;
private final Optional> argumentNames;
private final TypeSignature returnType;
private final FunctionKind functionKind;
private final FunctionImplementationType implementationType;
private final boolean deterministic;
private final boolean calledOnNullInput;
public FunctionMetadata(
QualifiedFunctionName name,
List argumentTypes,
Optional> argumentNames,
TypeSignature returnType,
FunctionKind functionKind,
FunctionImplementationType implementationType,
boolean deterministic,
boolean calledOnNullInput)
{
this(name, Optional.empty(), argumentTypes, argumentNames, returnType, functionKind, implementationType, deterministic, calledOnNullInput);
}
public FunctionMetadata(
OperatorType operatorType,
List argumentTypes,
TypeSignature returnType,
FunctionKind functionKind,
FunctionImplementationType implementationType,
boolean deterministic,
boolean calledOnNullInput)
{
this(operatorType.getFunctionName(), Optional.of(operatorType), argumentTypes, Optional.empty(), returnType, functionKind, implementationType, deterministic, calledOnNullInput);
}
private FunctionMetadata(
QualifiedFunctionName name,
Optional operatorType,
List argumentTypes,
Optional> argumentNames,
TypeSignature returnType,
FunctionKind functionKind,
FunctionImplementationType implementationType,
boolean deterministic,
boolean calledOnNullInput)
{
this.name = requireNonNull(name, "name is null");
this.operatorType = requireNonNull(operatorType, "operatorType is null");
this.argumentTypes = unmodifiableList(new ArrayList<>(requireNonNull(argumentTypes, "argumentTypes is null")));
this.argumentNames = requireNonNull(argumentNames, "argumentNames is null").map(names -> unmodifiableList(new ArrayList<>(names)));
this.returnType = requireNonNull(returnType, "returnType is null");
this.functionKind = requireNonNull(functionKind, "functionKind is null");
this.implementationType = requireNonNull(implementationType, "language is null");
this.deterministic = deterministic;
this.calledOnNullInput = calledOnNullInput;
}
public FunctionKind getFunctionKind()
{
return functionKind;
}
public QualifiedFunctionName getName()
{
return name;
}
public List getArgumentTypes()
{
return argumentTypes;
}
public Optional> getArgumentNames()
{
return argumentNames;
}
public TypeSignature getReturnType()
{
return returnType;
}
public Optional getOperatorType()
{
return operatorType;
}
public FunctionImplementationType getImplementationType()
{
return implementationType;
}
public boolean isDeterministic()
{
return deterministic;
}
public boolean isCalledOnNullInput()
{
return calledOnNullInput;
}
@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
FunctionMetadata other = (FunctionMetadata) obj;
return Objects.equals(this.name, other.name) &&
Objects.equals(this.operatorType, other.operatorType) &&
Objects.equals(this.argumentTypes, other.argumentTypes) &&
Objects.equals(this.argumentNames, other.argumentNames) &&
Objects.equals(this.returnType, other.returnType) &&
Objects.equals(this.functionKind, other.functionKind) &&
Objects.equals(this.implementationType, other.implementationType) &&
Objects.equals(this.deterministic, other.deterministic) &&
Objects.equals(this.calledOnNullInput, other.calledOnNullInput);
}
@Override
public int hashCode()
{
return Objects.hash(name, operatorType, argumentTypes, argumentNames, returnType, functionKind, implementationType, deterministic, calledOnNullInput);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy