All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.speedment.jpastreamer.field.internal.predicate.ints.IntNotInPredicate 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.ints;

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.HasIntValue;

import java.util.Set;

import static java.util.Objects.requireNonNull;

/**
 * A predicate that evaluates if a value is not included in a set of ints.
 * 
 * @param  entity type
 *
 * @author Emil Forslund
 * @since  3.0.11
 */
public final class IntNotInPredicate
extends AbstractFieldPredicate>
implements HasArg0> {
    
    private final Set set;
    
    public IntNotInPredicate(HasIntValue field, Set set) {
        super(PredicateType.NOT_IN, field, entity -> !set.contains(field.getAsInt(entity)));
        this.set = requireNonNull(set);
    }
    
    @Override
    public Set get0() {
        return set;
    }
    
    @Override
    public IntInPredicate negate() {
        return new IntInPredicate<>(getField(), set);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy