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

org.solidcoding.validation.predicates.ObjectPredicateBuilder Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
package org.solidcoding.validation.predicates;

import java.util.Objects;
import java.util.function.Predicate;

public final class ObjectPredicateBuilder extends PredicateContainer {

    private ObjectPredicateBuilder() {
        super();
    }

    private ObjectPredicateBuilder(Predicate predicate) {
        super();
        addPredicate(predicate);
    }

    /**
     * Checks whether the actual value is present.
     * @param  the type upon which the validations are tested.
     * @return Predicate to continue adding rules.
     */
    public static  Predicate isNotNull() {
        return new ObjectPredicateBuilder<>(Objects::nonNull);
    }

    /**
     * @param clazz the class of the object to validate. This is only a compiler flag to treat T as its instance.
     * @param    the type upon which the validations are tested.
     * @return ObjectPredicate to continue adding rules.
     */
    public static  GenericPredicate isA(Class clazz) {
        return new ObjectPredicateBuilder<>();
    }

    /**
     * @param clazz the class of the object to validate. This is only a compiler flag to treat T as its instance.
     * @param    the type upon which the validations are tested.
     * @return ObjectPredicate to continue adding rules.
     */
    public static  GenericPredicate isAn(Class clazz) {
        return isA(clazz);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy