com.speedment.jpastreamer.field.internal.predicate.longs.LongInPredicate Maven / Gradle / Ivy
/*
* JPAstreamer - Express JPA queries with Java Streams
* Copyright (c) 2020-2020, Speedment, Inc. All Rights Reserved.
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
*
* This library 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 Lesser General Public License for more details.
*
* See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE
*/
package com.speedment.jpastreamer.field.internal.predicate.longs;
import com.speedment.jpastreamer.field.internal.predicate.AbstractFieldPredicate;
import com.speedment.jpastreamer.field.predicate.PredicateType;
import com.speedment.jpastreamer.field.trait.HasArg0;
import com.speedment.jpastreamer.field.trait.HasLongValue;
import java.util.Set;
import static java.util.Objects.requireNonNull;
/**
* A predicate that evaluates if a value is included in a set of longs.
*
* @param entity type
*
* @author Emil Forslund
* @since 3.0.0
*/
public final class LongInPredicate
extends AbstractFieldPredicate>
implements HasArg0> {
private final Set set;
public LongInPredicate(HasLongValue field, Set set) {
super(PredicateType.IN, field, entity -> set.contains(field.getAsLong(entity)));
this.set = requireNonNull(set);
}
@Override
public Set get0() {
return set;
}
@Override
public LongNotInPredicate negate() {
return new LongNotInPredicate<>(getField(), set);
}
}