class ReferenceNotBetweenPredicate<ENTITY, D, V extends Comparable<? super V>>
    extends AbstractFieldPredicate<ENTITY, HasReferenceValue<ENTITY, D, V>>
    implements HasInclusion, Tuple2<V, V> {

    private final V start;
    private final V end;
    private final Inclusion inclusion;

    public ReferenceNotBetweenPredicate(
        final HasReferenceValue<ENTITY, D, V> referenceField,
        final V start,
        final V end,
        final Inclusion inclusion
    ) {
        super(NOT_BETWEEN, referenceField, entityPredicate(referenceField, start, end, inclusion));
        this.start     = start;
        this.end       = end;
        this.inclusion = requireNonNull(inclusion);
    }

    private static <ENTITY, D, V extends Comparable<? super V>> Predicate<ENTITY> entityPredicate(HasReferenceValue<ENTITY, D, V> referenceField, V start, V end, Inclusion inclusion) {<FILL_FUNCTION_BODY>}

    private static <V extends Comparable<? super V>> boolean starInclusiveEndInclusive(V start, V end, V fieldValue) {
        if (fieldValue == null) {
            return start == null || end == null;
        } else if (start == null || end == null) {
            return false;
        }
        return !(start.compareTo(fieldValue) <= 0 && end.compareTo(fieldValue) >= 0);
    }

    private static <V extends Comparable<? super V>> boolean startInclusiveEndExclusive(V start, V end, V fieldValue) {
        if (fieldValue == null) {
            return start == null && end != null;
        } else if (start == null || end == null) {
            return false;
        }
        return !(start.compareTo(fieldValue) <= 0 && end.compareTo(fieldValue) > 0);
    }

    private static <V extends Comparable<? super V>> boolean startExclusiveEndInclusive(V start, V end, V fieldValue) {
        if (fieldValue == null) {
            return start != null && end == null;
        } else if (start == null || end == null) {
            return false;
        } else return !(start.compareTo(fieldValue) < 0 && end.compareTo(fieldValue) >= 0);
    }

    private static <V extends Comparable<? super V>> boolean startExclusiveEndExclusive(V start, V end, V fieldValue) {
        if (fieldValue == null) {
            return false;
        } else if (start == null || end == null) {
            return false;
        } else return !(start.compareTo(fieldValue) < 0 && end.compareTo(fieldValue) > 0);
    }

    @Override
    public V get0() {
        return start;
    }

    @Override
    public V get1() {
        return end;
    }

    @Override
    public Inclusion getInclusion() {
        return inclusion;
    }

    @Override
    public ReferenceBetweenPredicate<ENTITY, D, V> negate() {
        return new ReferenceBetweenPredicate<>(getField(), start, end, inclusion);
    }
    
    
}

        return entity -> {
            final V fieldValue = referenceField.get(entity);

            switch (inclusion) {
                case START_EXCLUSIVE_END_EXCLUSIVE :
                    return startExclusiveEndExclusive(start, end, fieldValue);

                case START_EXCLUSIVE_END_INCLUSIVE :
                    return startExclusiveEndInclusive(start, end, fieldValue);

                case START_INCLUSIVE_END_EXCLUSIVE :
                    return startInclusiveEndExclusive(start, end, fieldValue);

                case START_INCLUSIVE_END_INCLUSIVE :
                    return starInclusiveEndInclusive(start, end, fieldValue);

                default : throw new IllegalStateException("Inclusion unknown: " + inclusion);
            }
        };
    
<methods>public boolean applyAsBoolean(ENTITY) ,public final HasReferenceValue<ENTITY,D,V> getField() ,public final com.speedment.runtime.field.predicate.PredicateType getPredicateType() ,public java.lang.String toString() <variables>private final non-sealed HasReferenceValue<ENTITY,D,V> field,private final non-sealed com.speedment.runtime.field.predicate.PredicateType predicateType,private final non-sealed Predicate<ENTITY> tester