mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Simplify to use single type (not use another different type for Query.Property)
This commit is contained in:
+17
-19
@@ -6,11 +6,10 @@ import io.ebean.Query;
|
||||
/**
|
||||
* Base property for all comparable types.
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
* @param <T> the type of the scalar property
|
||||
* @param <BT> the base type of the property
|
||||
* @param <R> the root query bean type
|
||||
* @param <T> the type of the scalar property
|
||||
*/
|
||||
public abstract class PBaseCompareable<R, T, BT> extends PBaseValueEqual<R, T, BT> {
|
||||
public abstract class PBaseComparable<R, T> extends PBaseValueEqual<R, T> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
@@ -18,14 +17,14 @@ public abstract class PBaseCompareable<R, T, BT> extends PBaseValueEqual<R, T, B
|
||||
* @param name property name
|
||||
* @param root the root query bean instance
|
||||
*/
|
||||
public PBaseCompareable(String name, R root) {
|
||||
public PBaseComparable(String name, R root) {
|
||||
super(name, root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct with additional path prefix.
|
||||
*/
|
||||
public PBaseCompareable(String name, R root, String prefix) {
|
||||
public PBaseComparable(String name, R root, String prefix) {
|
||||
super(name, root, prefix);
|
||||
}
|
||||
|
||||
@@ -48,11 +47,10 @@ public abstract class PBaseCompareable<R, T, BT> extends PBaseValueEqual<R, T, B
|
||||
* Note that the other property must have the same common "Base type" (String, Number, Temporal, Boolean or Object).
|
||||
*
|
||||
* @param other the other property to compare
|
||||
*
|
||||
* @return the root query bean instance
|
||||
*/
|
||||
public final R gt(TQProperty<?, BT> other) {
|
||||
expr().raw(_name + " > " + other.propertyName());
|
||||
public final R gt(Query.Property<T> other) {
|
||||
expr().raw(_name + " > " + other.toString());
|
||||
return _root;
|
||||
}
|
||||
|
||||
@@ -84,8 +82,8 @@ public abstract class PBaseCompareable<R, T, BT> extends PBaseValueEqual<R, T, B
|
||||
* @param other the other property to compare
|
||||
* @return the root query bean instance
|
||||
*/
|
||||
public final R ge(TQProperty<?, BT> other) {
|
||||
expr().raw(_name + " >= " + other.propertyName());
|
||||
public final R ge(Query.Property<T> other) {
|
||||
expr().raw(_name + " >= " + other.toString());
|
||||
return _root;
|
||||
}
|
||||
|
||||
@@ -117,8 +115,8 @@ public abstract class PBaseCompareable<R, T, BT> extends PBaseValueEqual<R, T, B
|
||||
* @param other the other property to compare
|
||||
* @return the root query bean instance
|
||||
*/
|
||||
public final R lt(TQProperty<?, BT> other) {
|
||||
expr().raw(_name + " < " + other.propertyName());
|
||||
public final R lt(Query.Property<T> other) {
|
||||
expr().raw(_name + " < " + other.toString());
|
||||
return _root;
|
||||
}
|
||||
|
||||
@@ -150,8 +148,8 @@ public abstract class PBaseCompareable<R, T, BT> extends PBaseValueEqual<R, T, B
|
||||
* @param other the other property to compare
|
||||
* @return the root query bean instance
|
||||
*/
|
||||
public final R le(TQProperty<?, BT> other) {
|
||||
expr().raw(_name + " <= " + other.propertyName());
|
||||
public final R le(Query.Property<T> other) {
|
||||
expr().raw(_name + " <= " + other.toString());
|
||||
return _root;
|
||||
}
|
||||
|
||||
@@ -200,8 +198,8 @@ public abstract class PBaseCompareable<R, T, BT> extends PBaseValueEqual<R, T, B
|
||||
* The most common use of this could be called "effective dating" where 2 date or
|
||||
* timestamp columns represent the date range in which
|
||||
*/
|
||||
public final R inRangeWith(TQProperty<?, BT> highProperty, T value) {
|
||||
expr().inRangeWith(_name, highProperty._name, value);
|
||||
public final R inRangeWith(Query.Property<T> highProperty, T value) {
|
||||
expr().inRangeWith(_name, highProperty.toString(), value);
|
||||
return _root;
|
||||
}
|
||||
|
||||
@@ -223,8 +221,8 @@ public abstract class PBaseCompareable<R, T, BT> extends PBaseValueEqual<R, T, B
|
||||
* <p>
|
||||
* This is a convenience expression combining a number of simple expressions.
|
||||
*/
|
||||
public final R inRangeWith(TQProperty<?, BT> lowProperty, TQProperty<?, BT> highProperty) {
|
||||
expr().inRangeWithProperties(_name, lowProperty.propertyName(), highProperty.propertyName());
|
||||
public final R inRangeWith(Query.Property<T> lowProperty, Query.Property<T> highProperty) {
|
||||
expr().inRangeWithProperties(_name, lowProperty.toString(), highProperty.toString());
|
||||
return _root;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package io.ebean.typequery;
|
||||
|
||||
import java.time.temporal.Temporal;
|
||||
|
||||
/**
|
||||
* Base property for date and date time types.
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
* @param <D> the date time type
|
||||
* @param <T> the scalar type
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract class PBaseDate<R, D extends Comparable> extends PBaseCompareable<R, D, Temporal> {
|
||||
public abstract class PBaseDate<R, T extends Comparable> extends PBaseComparable<R, T> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
@@ -34,7 +32,7 @@ public abstract class PBaseDate<R, D extends Comparable> extends PBaseCompareabl
|
||||
* @param value the equal to bind value
|
||||
* @return the root query bean instance
|
||||
*/
|
||||
public final R after(D value) {
|
||||
public final R after(T value) {
|
||||
expr().gt(_name, value);
|
||||
return _root;
|
||||
}
|
||||
@@ -45,7 +43,7 @@ public abstract class PBaseDate<R, D extends Comparable> extends PBaseCompareabl
|
||||
* @param value the equal to bind value
|
||||
* @return the root query bean instance
|
||||
*/
|
||||
public final R before(D value) {
|
||||
public final R before(T value) {
|
||||
expr().lt(_name, value);
|
||||
return _root;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ package io.ebean.typequery;
|
||||
* Base property for number types.
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
* @param <T> the number type
|
||||
* @param <T> the property type
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract class PBaseNumber<R, T extends Comparable> extends PBaseCompareable<R, T, T> {
|
||||
public abstract class PBaseNumber<R, T extends Comparable> extends PBaseComparable<R, T> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -5,7 +5,7 @@ package io.ebean.typequery;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public abstract class PBaseString<R, T> extends PBaseCompareable<R, T, String> {
|
||||
public abstract class PBaseString<R, T> extends PBaseComparable<R, T> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package io.ebean.typequery;
|
||||
|
||||
import java.time.temporal.Temporal;
|
||||
|
||||
/**
|
||||
* Base property for time types.
|
||||
*
|
||||
@@ -9,7 +7,7 @@ import java.time.temporal.Temporal;
|
||||
* @param <T> the number type
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract class PBaseTime<R, T extends Comparable> extends PBaseCompareable<R, T, Temporal> {
|
||||
public abstract class PBaseTime<R, T extends Comparable> extends PBaseComparable<R, T> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Collection;
|
||||
* @param <R> the root query bean type
|
||||
* @param <T> the number type
|
||||
*/
|
||||
public abstract class PBaseValueEqual<R, T, BT> extends TQPropertyBase<R, BT> {
|
||||
public abstract class PBaseValueEqual<R, T> extends TQPropertyBase<R, T> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
@@ -89,8 +89,8 @@ public abstract class PBaseValueEqual<R, T, BT> extends TQPropertyBase<R, BT> {
|
||||
* @param other the other property to compare
|
||||
* @return the root query bean instance
|
||||
*/
|
||||
public final R eq(TQProperty<?, BT> other) {
|
||||
expr().raw(_name + " = " + other.propertyName());
|
||||
public final R eq(Query.Property<T> other) {
|
||||
expr().raw(_name + " = " + other.toString());
|
||||
return _root;
|
||||
}
|
||||
|
||||
@@ -152,8 +152,8 @@ public abstract class PBaseValueEqual<R, T, BT> extends TQPropertyBase<R, BT> {
|
||||
* @param other the other property to compare
|
||||
* @return the root query bean instance
|
||||
*/
|
||||
public final R ne(TQProperty<?, BT> other) {
|
||||
expr().raw(_name + " <> " + other.propertyName());
|
||||
public final R ne(Query.Property<T> other) {
|
||||
expr().raw(_name + " <> " + other.toString());
|
||||
return _root;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ package io.ebean.typequery;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PBoolean<R> extends PBaseValueEqual<R, Boolean, Boolean> {
|
||||
public final class PBoolean<R> extends PBaseValueEqual<R, Boolean> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -5,7 +5,7 @@ package io.ebean.typequery;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PByteArray<R> extends PBaseValueEqual<R, byte[], Object> {
|
||||
public final class PByteArray<R> extends PBaseValueEqual<R, byte[]> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Calendar;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PCalendar<R> extends PBaseDate<R,Calendar> {
|
||||
public final class PCalendar<R> extends PBaseDate<R, Calendar> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -6,7 +6,7 @@ package io.ebean.typequery;
|
||||
* @param <E> the enum specific type
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PEnum<R, E> extends PBaseValueEqual<R, E, E> {
|
||||
public final class PEnum<R, E> extends PBaseValueEqual<R, E> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.time.Instant;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PInstant<R> extends PBaseDate<R,Instant> {
|
||||
public final class PInstant<R> extends PBaseDate<R, Instant> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.joda.time.DateMidnight;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PJodaDateMidnight<R> extends PBaseDate<R,DateMidnight> {
|
||||
public final class PJodaDateMidnight<R> extends PBaseDate<R, DateMidnight> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.joda.time.DateTime;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PJodaDateTime<R> extends PBaseDate<R,DateTime> {
|
||||
public final class PJodaDateTime<R> extends PBaseDate<R, DateTime> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.joda.time.LocalDate;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PJodaLocalDate<R> extends PBaseDate<R,LocalDate> {
|
||||
public final class PJodaLocalDate<R> extends PBaseDate<R, LocalDate> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.joda.time.LocalDateTime;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PJodaLocalDateTime<R> extends PBaseDate<R,LocalDateTime> {
|
||||
public final class PJodaLocalDateTime<R> extends PBaseDate<R, LocalDateTime> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -5,15 +5,11 @@ package io.ebean.typequery;
|
||||
* JSON document type.
|
||||
* <p>
|
||||
* Type that is JSON content mapped to database types such as Postgres JSON/JSONB and otherwise Varchar,Clob and Blob.
|
||||
* </p>
|
||||
* <p>
|
||||
* The expressions on this type are valid of Postgres and Oracle.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* The path can reference a nested property in the JSON document using dot notation -
|
||||
* for example "documentMeta.score" where "score" is an embedded attribute of "documentMeta"
|
||||
* </p>
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
@@ -92,7 +88,7 @@ public final class PJson<R> extends TQPropertyBase<R, String> {
|
||||
*
|
||||
* }</pre>
|
||||
*
|
||||
* @param path the dot notation path in the JSON document
|
||||
* @param path the dot notation path in the JSON document
|
||||
* @param value the equal to bind value
|
||||
*/
|
||||
public R jsonEqualTo(String path, Object value) {
|
||||
@@ -103,7 +99,7 @@ public final class PJson<R> extends TQPropertyBase<R, String> {
|
||||
/**
|
||||
* Not Equal to - for the given path in a JSON document.
|
||||
*
|
||||
* @param path the nested path in the JSON document in dot notation
|
||||
* @param path the nested path in the JSON document in dot notation
|
||||
* @param value the value used to test equality against the document path's value
|
||||
*/
|
||||
public R jsonNotEqualTo(String path, Object value) {
|
||||
@@ -114,7 +110,7 @@ public final class PJson<R> extends TQPropertyBase<R, String> {
|
||||
/**
|
||||
* Greater than - for the given path in a JSON document.
|
||||
*
|
||||
* @param path the nested path in the JSON document in dot notation
|
||||
* @param path the nested path in the JSON document in dot notation
|
||||
* @param value the value used to test against the document path's value
|
||||
*/
|
||||
public R jsonGreaterThan(String path, Object value) {
|
||||
@@ -125,7 +121,7 @@ public final class PJson<R> extends TQPropertyBase<R, String> {
|
||||
/**
|
||||
* Greater than or equal to - for the given path in a JSON document.
|
||||
*
|
||||
* @param path the nested path in the JSON document in dot notation
|
||||
* @param path the nested path in the JSON document in dot notation
|
||||
* @param value the value used to test against the document path's value
|
||||
*/
|
||||
public R jsonGreaterOrEqual(String path, Object value) {
|
||||
@@ -136,7 +132,7 @@ public final class PJson<R> extends TQPropertyBase<R, String> {
|
||||
/**
|
||||
* Less than - for the given path in a JSON document.
|
||||
*
|
||||
* @param path the nested path in the JSON document in dot notation
|
||||
* @param path the nested path in the JSON document in dot notation
|
||||
* @param value the value used to test against the document path's value
|
||||
*/
|
||||
public R jsonLessThan(String path, Object value) {
|
||||
@@ -147,7 +143,7 @@ public final class PJson<R> extends TQPropertyBase<R, String> {
|
||||
/**
|
||||
* Less than or equal to - for the given path in a JSON document.
|
||||
*
|
||||
* @param path the nested path in the JSON document in dot notation
|
||||
* @param path the nested path in the JSON document in dot notation
|
||||
* @param value the value used to test against the document path's value
|
||||
*/
|
||||
public R jsonLessOrEqualTo(String path, Object value) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.time.LocalDate;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PLocalDate<R> extends PBaseDate<R,LocalDate> {
|
||||
public final class PLocalDate<R> extends PBaseDate<R, LocalDate> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.time.LocalDateTime;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PLocalDateTime<R> extends PBaseDate<R,LocalDateTime> {
|
||||
public final class PLocalDateTime<R> extends PBaseDate<R, LocalDateTime> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.time.Month;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PMonth<R> extends PBaseDate<R,Month> {
|
||||
public final class PMonth<R> extends PBaseDate<R, Month> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.time.MonthDay;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PMonthDay<R> extends PBaseDate<R,MonthDay> {
|
||||
public final class PMonthDay<R> extends PBaseDate<R, MonthDay> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.time.OffsetDateTime;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class POffsetDateTime<R> extends PBaseDate<R,OffsetDateTime> {
|
||||
public final class POffsetDateTime<R> extends PBaseDate<R, OffsetDateTime> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -6,7 +6,7 @@ package io.ebean.typequery;
|
||||
* @param <R> the root query bean type
|
||||
* @param <D> the scalar type
|
||||
*/
|
||||
public final class PScalar<R, D> extends PBaseValueEqual<R, D, Object> {
|
||||
public final class PScalar<R, D> extends PBaseValueEqual<R, D> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -8,7 +8,7 @@ package io.ebean.typequery;
|
||||
* @param <R> the root query bean type
|
||||
* @param <D> the scalar type
|
||||
*/
|
||||
public final class PScalarComparable<R, D extends Comparable<D>> extends PBaseCompareable<R, D, Object> {
|
||||
public final class PScalarComparable<R, D extends Comparable<D>> extends PBaseComparable<R, D> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.sql.Date;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PSqlDate<R> extends PBaseDate<R,Date> {
|
||||
public final class PSqlDate<R> extends PBaseDate<R, Date> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -5,7 +5,7 @@ package io.ebean.typequery;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PString<R> extends PBaseCompareable<R, String, String> {
|
||||
public final class PString<R> extends PBaseComparable<R, String> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.sql.Timestamp;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PTimestamp<R> extends PBaseDate<R,Timestamp> {
|
||||
public final class PTimestamp<R> extends PBaseDate<R, Timestamp> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Date;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PUtilDate<R> extends PBaseDate<R,Date> {
|
||||
public final class PUtilDate<R> extends PBaseDate<R, Date> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.UUID;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PUuid<R> extends PBaseValueEqual<R, UUID, Object> {
|
||||
public final class PUuid<R> extends PBaseValueEqual<R, UUID> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.time.YearMonth;
|
||||
*
|
||||
* @param <R> the root query bean type
|
||||
*/
|
||||
public final class PYearMonth<R> extends PBaseDate<R,YearMonth> {
|
||||
public final class PYearMonth<R> extends PBaseDate<R, YearMonth> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
@@ -6,10 +6,10 @@ import io.ebean.Query;
|
||||
/**
|
||||
* A property used in type query.
|
||||
*
|
||||
* @param <R> The type of the owning root bean
|
||||
* @param <BT> The base type, one of String, Number, Temporal, Boolean, Object.
|
||||
* @param <R> The type of the owning root bean
|
||||
* @param <T> The property type
|
||||
*/
|
||||
public class TQProperty<R, BT> implements Query.Property<BT> {
|
||||
public class TQProperty<R, T> implements Query.Property<T> {
|
||||
|
||||
protected final String _name;
|
||||
protected final R _root;
|
||||
|
||||
@@ -3,10 +3,10 @@ package io.ebean.typequery;
|
||||
/**
|
||||
* Base scalar property.
|
||||
*
|
||||
* @param <R> The type of the owning root bean
|
||||
* @param <BT> The base type of the property
|
||||
* @param <R> The type of the owning root bean
|
||||
* @param <T> The property type
|
||||
*/
|
||||
public abstract class TQPropertyBase<R, BT> extends TQProperty<R, BT> {
|
||||
public abstract class TQPropertyBase<R, T> extends TQProperty<R, T> {
|
||||
|
||||
/**
|
||||
* Construct with a property name and root instance.
|
||||
|
||||
Reference in New Issue
Block a user