com.landawn.abacus.util.function.BytePredicate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of abacus-common Show documentation
Show all versions of abacus-common Show documentation
A general programming library in Java/Android. It's easy to learn and simple to use with concise and powerful APIs.
/*
* Copyright (c) 2015, Haiyang Li. All rights reserved.
*/
package com.landawn.abacus.util.function;
import com.landawn.abacus.util.N;
import com.landawn.abacus.util.Throwables;
public interface BytePredicate extends Throwables.BytePredicate { //NOSONAR
BytePredicate ALWAYS_TRUE = value -> true;
BytePredicate ALWAYS_FALSE = value -> false;
BytePredicate IS_ZERO = value -> value == 0;
BytePredicate NOT_ZERO = value -> value != 0;
BytePredicate IS_POSITIVE = value -> value > 0;
BytePredicate NOT_POSITIVE = value -> value <= 0;
BytePredicate IS_NEGATIVE = value -> value < 0;
BytePredicate NOT_NEGATIVE = value -> value >= 0;
/**
*
*
* @param value
* @return
*/
@Override
boolean test(byte value);
/**
* Returns the specified instance.
*
* @param predicate
* @return
*/
static BytePredicate of(final BytePredicate predicate) {
N.checkArgNotNull(predicate);
return predicate;
}
/**
*
*
* @return
*/
default BytePredicate negate() {
return t -> !test(t);
}
/**
*
*
* @param other
* @return
*/
default BytePredicate and(BytePredicate other) {
N.checkArgNotNull(other);
return t -> test(t) && other.test(t);
}
/**
*
*
* @param other
* @return
*/
default BytePredicate or(BytePredicate other) {
N.checkArgNotNull(other);
return t -> test(t) || other.test(t);
}
/**
*
*
* @param targetByte
* @return
*/
static BytePredicate equal(byte targetByte) { //NOSONAR
return value -> value == targetByte;
}
/**
*
*
* @param targetByte
* @return
*/
static BytePredicate notEqual(byte targetByte) {
return value -> value != targetByte;
}
/**
*
*
* @param targetByte
* @return
*/
static BytePredicate greaterThan(byte targetByte) {
return value -> value > targetByte;
}
/**
*
*
* @param targetByte
* @return
*/
static BytePredicate greaterEqual(byte targetByte) {
return value -> value >= targetByte;
}
/**
*
*
* @param targetByte
* @return
*/
static BytePredicate lessThan(byte targetByte) {
return value -> value < targetByte;
}
/**
*
*
* @param targetByte
* @return
*/
static BytePredicate lessEqual(byte targetByte) {
return value -> value <= targetByte;
}
/**
*
*
* @param minValue
* @param maxValue
* @return
*/
static BytePredicate between(byte minValue, byte maxValue) {
return value -> value > minValue && value < maxValue;
}
}