package com.speedment.runtime.compute.trait;

import java.util.function.Function;
import java.util.function.Predicate;

/**
 * Trait for expressions that result in a nullable value. Those expressions have
 * additional methods for checking for {@code null}-values.
 *
 * @author Emil Forslund
 * @since  3.1.0
 */
public interface ToNullable<T, R> extends Function<T, R> {

    default Predicate<T> isNull() {
        return this::isNull;
    }

    default Predicate<T> isNotNull() {
        return this::isNotNull;
    }

    default boolean isNull(T object) {
        return apply(object) == null;
    }

    default boolean isNotNull(T object) {
        return apply(object) != null;
    }

}
@@ -39,16 +39,77 @@
 trait;%0A%0A
+import com.speedment.runtime.compute.expression.Expression;%0A%0A
 import j
@@ -424,16 +424,31 @@
 on%3CT, R%3E
+, Expression%3CT%3E
  %7B%0A%0A    

Make ToNullable extend Expression