com.speedment.jpastreamer.field.method.BooleanGetter 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.method;
import com.speedment.common.function.ToBooleanFunction;
import java.util.function.Function;
/**
* A short-cut functional reference to the {@code getXXX(value)} method for a
* particular field in an entity.
*
* A {@code BooleanGetter} has the following signature:
* {@code
* interface ENTITY {
* boolean getXXX();
* }
* }
*
* @param the entity
*
* @author Emil Forslund
* @since 3.0.0
*/
@FunctionalInterface
public interface BooleanGetter extends Getter, ToBooleanFunction {
/**
* Returns the member represented by this getter in the specified instance.
*
* @param instance the instance to get from
* @return the value
*/
@Override
boolean applyAsBoolean(ENTITY instance);
@Override
default Boolean apply(ENTITY instance) {
return applyAsBoolean(instance);
}
@Override
default Function asFunction() {
return this::apply;
}
}