Skip to content

Commit

Permalink
Runtime: Fix test errors due to new fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil Forslund committed Jul 28, 2016
1 parent 77492fa commit 7d9272f
Show file tree
Hide file tree
Showing 23 changed files with 626 additions and 75 deletions.
Expand Up @@ -17,6 +17,7 @@
package com.speedment.runtime.field.trait; package com.speedment.runtime.field.trait;


import com.speedment.runtime.annotation.Api; import com.speedment.runtime.annotation.Api;
import com.speedment.runtime.field.Field;
import com.speedment.runtime.field.predicate.Inclusion; import com.speedment.runtime.field.predicate.Inclusion;
import java.util.Comparator; import java.util.Comparator;
import java.util.Set; import java.util.Set;
Expand All @@ -36,7 +37,7 @@
* @since 2.2.0 * @since 2.2.0
*/ */
@Api(version = "3.0") @Api(version = "3.0")
public interface HasComparableOperators<ENTITY, V extends Comparable<? super V>> { public interface HasComparableOperators<ENTITY, V extends Comparable<? super V>> extends Field<ENTITY> {


/** /**
* Returns a {@link Comparator} that will compare to this field using this * Returns a {@link Comparator} that will compare to this field using this
Expand Down Expand Up @@ -86,55 +87,60 @@ public interface HasComparableOperators<ENTITY, V extends Comparable<? super V>>
* @return a Predicate that will evaluate to {@code true}, if and only if * @return a Predicate that will evaluate to {@code true}, if and only if
* this Field is <em>not equal</em> to the given value * this Field is <em>not equal</em> to the given value
*/ */
default Predicate<ENTITY> notEqual(V value) { Predicate<ENTITY> notEqual(V value);
return equal(value).negate();
}


/** /**
* Returns a {@link java.util.function.Predicate} that will evaluate to * Returns a {@link java.util.function.Predicate} that will evaluate to
* {@code true}, if and only if this Field is <em>less than</em> the given * {@code true}, if and only if this Field is <em>less than</em> the given
* value. * value.
* <p>
* If the specified value is {@code null}, the returned predicate will
* always return {@code false}.
* *
* @param value to compare * @param value to compare
* @return a Predicate that will evaluate to {@code true}, if and only if * @return a Predicate that will evaluate to {@code true}, if and only if
* this Field is <em>less than</em> the given value * this Field is <em>less than</em> the given value
*/ */
default Predicate<ENTITY> lessThan(V value) { Predicate<ENTITY> lessThan(V value);
return greaterOrEqual(value).negate();
}


/** /**
* Returns a {@link java.util.function.Predicate} that will evaluate to * Returns a {@link java.util.function.Predicate} that will evaluate to
* {@code true}, if and only if this Field is <em>less than or equal</em> * {@code true}, if and only if this Field is <em>less than or equal</em>
* to the given value. * to the given value.
* <p>
* If the specified value is {@code null}, the returned predicate will
* only return {@code true} for {@code null} values.
* *
* @param value to compare * @param value to compare
* @return a Predicate that will evaluate to {@code true}, if and only if * @return a Predicate that will evaluate to {@code true}, if and only if
* this Field is <em>less than or equal</em> to the given value * this Field is <em>less than or equal</em> to the given value
*/ */
default Predicate<ENTITY> lessOrEqual(V value) { Predicate<ENTITY> lessOrEqual(V value);
return greaterThan(value).negate();
}


/** /**
* Returns a {@link java.util.function.Predicate} that will evaluate to * Returns a {@link java.util.function.Predicate} that will evaluate to
* {@code true}, if and only if this Field is <em>greater than</em> * {@code true}, if and only if this Field is <em>greater than</em>
* the given value. * the given value.
* If the specified value is {@code null}, the returned predicate will
* always return {@code false}.
* *
* @param value to compare * @param value to compare
* @return a Predicate that will evaluate to {@code true}, if and only if * @return a Predicate that will evaluate to {@code true}, if and only if
* this Field is <em>greater than</em> the given value * this Field is <em>greater than</em> the given value
*/ */
Predicate<ENTITY> greaterThan(V value); Predicate<ENTITY> greaterThan(V value);


/** /**
* Returns a {@link java.util.function.Predicate} that will evaluate to * Returns a {@link java.util.function.Predicate} that will evaluate to
* {@code true}, if and only if this Field is <em>greater than or equal</em> * {@code true}, if and only if this Field is <em>greater than or equal</em>
* to the given value. * to the given value.
* <p>
* If the specified value is {@code null}, the returned predicate will
* only return {@code true} for {@code null} values.
* *
* @param value to compare * @param value to compare
* @return a Predicate that will evaluate to {@code true}, if and only if * @return a Predicate that will evaluate to {@code true}, if and only if
* this Field is <em>greater than or equal</em> to the given value * this Field is <em>greater than or equal</em> to the given value
*/ */
Predicate<ENTITY> greaterOrEqual(V value); Predicate<ENTITY> greaterOrEqual(V value);


Expand All @@ -143,14 +149,14 @@ default Predicate<ENTITY> lessOrEqual(V value) {
* {@code true}, if and only if this Field is <em>between</em> * {@code true}, if and only if this Field is <em>between</em>
* the given values (inclusive the start value but exclusive the end value). * the given values (inclusive the start value but exclusive the end value).
* <p> * <p>
* N.B. if the start value is greater than the end value, then the returned * N.B. if the start value is greater or equal to the end value, then the
* Predicate will always evaluate to {@code false} * returned Predicate will always evaluate to {@code false}.
* *
* @param start to compare as a start value * @param start to compare as a start value
* @param end to compare as an end value * @param end to compare as an end value
* @return a Predicate that will evaluate to {@code true}, if and only if * @return a Predicate that will evaluate to {@code true}, if and only if
* this Field is <em>between</em> the given values (inclusive the start * this Field is <em>between</em> the given values (inclusive the
* value but exclusive the end value) * start value but exclusive the end value)
*/ */
default Predicate<ENTITY> between(V start, V end) { default Predicate<ENTITY> between(V start, V end) {
return between(start, end, Inclusion.START_INCLUSIVE_END_EXCLUSIVE); return between(start, end, Inclusion.START_INCLUSIVE_END_EXCLUSIVE);
Expand Down Expand Up @@ -192,7 +198,7 @@ default Predicate<ENTITY> between(V start, V end) {
* value but exclusive the end value) * value but exclusive the end value)
*/ */
default Predicate<ENTITY> notBetween(V start, V end) { default Predicate<ENTITY> notBetween(V start, V end) {
return between(start, end).negate(); return notBetween(start, end, Inclusion.START_INCLUSIVE_END_EXCLUSIVE);
} }


/** /**
Expand All @@ -214,9 +220,7 @@ default Predicate<ENTITY> notBetween(V start, V end) {
* Inclusion parameter into account when determining if either of the end * Inclusion parameter into account when determining if either of the end
* points shall be included in the Field range or not * points shall be included in the Field range or not
*/ */
default Predicate<ENTITY> notBetween(V start, V end, Inclusion inclusion) { Predicate<ENTITY> notBetween(V start, V end, Inclusion inclusion);
return between(start, end, inclusion).negate();
}


/** /**
* Returns a {@link java.util.function.Predicate} that will evaluate to * Returns a {@link java.util.function.Predicate} that will evaluate to
Expand Down Expand Up @@ -262,7 +266,7 @@ default Predicate<ENTITY> in(V... values) {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
default Predicate<ENTITY> notIn(V... values) { default Predicate<ENTITY> notIn(V... values) {
return in(values).negate(); return notIn(Stream.of(values).collect(toSet()));
} }


/** /**
Expand All @@ -276,7 +280,5 @@ default Predicate<ENTITY> notIn(V... values) {
* @return a Predicate that will evaluate to {@code true}, if and only if * @return a Predicate that will evaluate to {@code true}, if and only if
* this Field is <em>not in</em> the given Set * this Field is <em>not in</em> the given Set
*/ */
default Predicate<ENTITY> notIn(Set<V> values) { Predicate<ENTITY> notIn(Set<V> values);
return in(values).negate();
}
} }
Expand Up @@ -34,6 +34,11 @@
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.speedment.runtime.field.predicate.FieldPredicate; import com.speedment.runtime.field.predicate.FieldPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceLessOrEqualPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceLessThanPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceNotBetweenPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceNotEqualPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceNotInPredicate;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;


/** /**
Expand Down Expand Up @@ -148,4 +153,29 @@ public Predicate<ENTITY> between(V start, V end, Inclusion inclusion) {
public Predicate<ENTITY> in(Set<V> values) { public Predicate<ENTITY> in(Set<V> values) {
return new ReferenceInPredicate<>(this, values); return new ReferenceInPredicate<>(this, values);
} }

@Override
public Predicate<ENTITY> notEqual(V value) {
return new ReferenceNotEqualPredicate<>(this, value);
}

@Override
public Predicate<ENTITY> lessThan(V value) {
return new ReferenceLessThanPredicate<>(this, value);
}

@Override
public Predicate<ENTITY> lessOrEqual(V value) {
return new ReferenceLessOrEqualPredicate<>(this, value);
}

@Override
public Predicate<ENTITY> notBetween(V start, V end, Inclusion inclusion) {
return new ReferenceNotBetweenPredicate<>(this, start, end, inclusion);
}

@Override
public Predicate<ENTITY> notIn(Set<V> values) {
return new ReferenceNotInPredicate<>(this, values);
}
} }
Expand Up @@ -35,6 +35,11 @@
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.speedment.runtime.field.predicate.FieldPredicate; import com.speedment.runtime.field.predicate.FieldPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceLessOrEqualPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceLessThanPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceNotBetweenPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceNotEqualPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceNotInPredicate;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;


/** /**
Expand Down Expand Up @@ -157,4 +162,29 @@ public Predicate<ENTITY> between(V start, V end, Inclusion inclusion) {
public Predicate<ENTITY> in(Set<V> values) { public Predicate<ENTITY> in(Set<V> values) {
return new ReferenceInPredicate<>(this, values); return new ReferenceInPredicate<>(this, values);
} }

@Override
public Predicate<ENTITY> notEqual(V value) {
return new ReferenceNotEqualPredicate<>(this, value);
}

@Override
public Predicate<ENTITY> lessThan(V value) {
return new ReferenceLessThanPredicate<>(this, value);
}

@Override
public Predicate<ENTITY> lessOrEqual(V value) {
return new ReferenceLessOrEqualPredicate<>(this, value);
}

@Override
public Predicate<ENTITY> notBetween(V start, V end, Inclusion inclusion) {
return new ReferenceNotBetweenPredicate<>(this, start, end, inclusion);
}

@Override
public Predicate<ENTITY> notIn(Set<V> values) {
return new ReferenceNotInPredicate<>(this, values);
}
} }
Expand Up @@ -16,6 +16,7 @@
import java.util.Set; import java.util.Set;
import com.speedment.runtime.field.predicate.FieldPredicate; import com.speedment.runtime.field.predicate.FieldPredicate;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
import java.util.function.Predicate;


/** /**
* *
Expand Down Expand Up @@ -123,4 +124,29 @@ public FieldPredicate<ENTITY> between(Long start, Long end, Inclusion inclusion)
public FieldPredicate<ENTITY> in(Set<Long> values) { public FieldPredicate<ENTITY> in(Set<Long> values) {
return new LongInPredicate<>(this, values); return new LongInPredicate<>(this, values);
} }

@Override
public Predicate<ENTITY> notEqual(Long value) {
return new LongEqualPredicate<>(this, value).negate();
}

@Override
public Predicate<ENTITY> lessThan(Long value) {
return new LongGreaterOrEqualPredicate<>(this, value).negate();
}

@Override
public Predicate<ENTITY> lessOrEqual(Long value) {
return new LongGreaterThanPredicate<>(this, value).negate();
}

@Override
public Predicate<ENTITY> notBetween(Long start, Long end, Inclusion inclusion) {
return new LongBetweenPredicate<>(this, start, end, inclusion).negate();
}

@Override
public Predicate<ENTITY> notIn(Set<Long> values) {
return new LongInPredicate<>(this, values).negate();
}
} }
Expand Up @@ -17,6 +17,7 @@
import java.util.Set; import java.util.Set;
import com.speedment.runtime.field.predicate.FieldPredicate; import com.speedment.runtime.field.predicate.FieldPredicate;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
import java.util.function.Predicate;


/** /**
* *
Expand Down Expand Up @@ -133,4 +134,29 @@ public FieldPredicate<ENTITY> between(Long start, Long end, Inclusion inclusion)
public FieldPredicate<ENTITY> in(Set<Long> values) { public FieldPredicate<ENTITY> in(Set<Long> values) {
return new LongInPredicate<>(this, values); return new LongInPredicate<>(this, values);
} }

@Override
public Predicate<ENTITY> notEqual(Long value) {
return new LongEqualPredicate<>(this, value).negate();
}

@Override
public Predicate<ENTITY> lessThan(Long value) {
return new LongGreaterOrEqualPredicate<>(this, value).negate();
}

@Override
public Predicate<ENTITY> lessOrEqual(Long value) {
return new LongGreaterThanPredicate<>(this, value).negate();
}

@Override
public Predicate<ENTITY> notBetween(Long start, Long end, Inclusion inclusion) {
return new LongBetweenPredicate<>(this, start, end, inclusion).negate();
}

@Override
public Predicate<ENTITY> notIn(Set<Long> values) {
return new LongInPredicate<>(this, values).negate();
}
} }
Expand Up @@ -39,6 +39,11 @@
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.speedment.runtime.field.predicate.FieldPredicate; import com.speedment.runtime.field.predicate.FieldPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceLessOrEqualPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceLessThanPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceNotBetweenPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceNotEqualPredicate;
import com.speedment.runtime.internal.field.predicate.reference.ReferenceNotInPredicate;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;


/** /**
Expand Down Expand Up @@ -151,6 +156,31 @@ public Predicate<ENTITY> between(String start, String end, Inclusion inclusion)
public Predicate<ENTITY> in(Set<String> values) { public Predicate<ENTITY> in(Set<String> values) {
return new ReferenceInPredicate<>(this, values); return new ReferenceInPredicate<>(this, values);
} }

@Override
public Predicate<ENTITY> notEqual(String value) {
return new ReferenceNotEqualPredicate<>(this, value);
}

@Override
public Predicate<ENTITY> lessThan(String value) {
return new ReferenceLessThanPredicate<>(this, value);
}

@Override
public Predicate<ENTITY> lessOrEqual(String value) {
return new ReferenceLessOrEqualPredicate<>(this, value);
}

@Override
public Predicate<ENTITY> notBetween(String start, String end, Inclusion inclusion) {
return new ReferenceNotBetweenPredicate<>(this, start, end, inclusion);
}

@Override
public Predicate<ENTITY> notIn(Set<String> values) {
return new ReferenceNotInPredicate<>(this, values);
}


@Override @Override
public Predicate<ENTITY> equalIgnoreCase(String value) { public Predicate<ENTITY> equalIgnoreCase(String value) {
Expand Down

0 comments on commit 7d9272f

Please sign in to comment.