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.
/*
* 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.spi.predicate;
import com.facebook.presto.spi.ConnectorSession;
import com.facebook.presto.spi.type.Type;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import static java.util.Objects.requireNonNull;
/**
* Defines the possible values of a single variable in terms of its valid scalar values and nullability.
*
* For example:
*
*
*
Domain.none() => no scalar values allowed, NULL not allowed
*
Domain.all() => all scalar values allowed, NULL allowed
*
Domain.onlyNull() => no scalar values allowed, NULL allowed
*
Domain.notNull() => all scalar values allowed, NULL not allowed
*
*
*/
public final class Domain
{
private final ValueSet values;
private final boolean nullAllowed;
private Domain(ValueSet values, boolean nullAllowed)
{
this.values = requireNonNull(values, "values is null");
this.nullAllowed = nullAllowed;
}
@JsonCreator
public static Domain create(
@JsonProperty("values") ValueSet values,
@JsonProperty("nullAllowed") boolean nullAllowed)
{
return new Domain(values, nullAllowed);
}
public static Domain none(Type type)
{
return new Domain(ValueSet.none(type), false);
}
public static Domain all(Type type)
{
return new Domain(ValueSet.all(type), true);
}
public static Domain onlyNull(Type type)
{
return new Domain(ValueSet.none(type), true);
}
public static Domain notNull(Type type)
{
return new Domain(ValueSet.all(type), false);
}
public static Domain singleValue(Type type, Object value)
{
return new Domain(ValueSet.of(type, value), false);
}
public static Domain multipleValues(Type type, List