diff --git a/hibernate-types-4/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java b/hibernate-types-4/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java index d3ae0097c..17f27a723 100644 --- a/hibernate-types-4/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java +++ b/hibernate-types-4/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java @@ -23,7 +23,7 @@ * @author Edgar Asatryan * @author Vlad Mihalcea */ -public final class Range implements Serializable { +public final class Range> implements Serializable { public static final int LOWER_INCLUSIVE = 1 << 1; public static final int LOWER_EXCLUSIVE = 1 << 2; @@ -67,7 +67,7 @@ private Range(T lower, T upper, int mask, Class clazz) { * @return The closed range. */ @SuppressWarnings("unchecked") - public static > Range closed(T lower, T upper) { + public static > Range closed(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range(lower, upper, LOWER_INCLUSIVE | UPPER_INCLUSIVE, (Class) lower.getClass()); @@ -88,7 +88,7 @@ public static > Range closed(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range open(T lower, T upper) { + public static > Range open(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range(lower, upper, LOWER_EXCLUSIVE | UPPER_EXCLUSIVE, (Class) lower.getClass()); @@ -109,7 +109,7 @@ public static > Range open(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range openClosed(T lower, T upper) { + public static > Range openClosed(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range(lower, upper, LOWER_EXCLUSIVE | UPPER_INCLUSIVE, (Class) lower.getClass()); @@ -130,7 +130,7 @@ public static > Range openClosed(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range closedOpen(T lower, T upper) { + public static > Range closedOpen(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range(lower, upper, LOWER_INCLUSIVE | UPPER_EXCLUSIVE, (Class) lower.getClass()); @@ -150,7 +150,7 @@ public static > Range closedOpen(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range openInfinite(T lower) { + public static > Range openInfinite(T lower) { Objects.requireNonNull(lower); return new Range(lower, null, LOWER_EXCLUSIVE | UPPER_INFINITE, (Class) lower.getClass()); } @@ -169,7 +169,7 @@ public static > Range openInfinite(T lower) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range closedInfinite(T lower) { + public static > Range closedInfinite(T lower) { Objects.requireNonNull(lower); return new Range(lower, null, LOWER_INCLUSIVE | UPPER_INFINITE, lower.getClass()); } @@ -188,7 +188,7 @@ public static > Range closedInfinite(T lower) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range infiniteOpen(T upper) { + public static > Range infiniteOpen(T upper) { Objects.requireNonNull(upper); return new Range(null, upper, UPPER_EXCLUSIVE | LOWER_INFINITE, (Class) upper.getClass()); } @@ -207,7 +207,7 @@ public static > Range infiniteOpen(T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range infiniteClosed(T upper) { + public static > Range infiniteClosed(T upper) { Objects.requireNonNull(upper); return new Range(null, upper, UPPER_INCLUSIVE | LOWER_INFINITE, (Class) upper.getClass()); } @@ -226,12 +226,12 @@ public static > Range infiniteClosed(T upper) { * @return The infinite range. */ @SuppressWarnings("unchecked") - public static > Range infinite(Class cls) { + public static > Range infinite(Class cls) { return new Range(null, null, LOWER_INFINITE | UPPER_INFINITE, cls); } @SuppressWarnings("unchecked") - public static Range ofString(String str, Function converter, Class clazz) { + public static > Range ofString(String str, Function converter, Class clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } @@ -514,7 +514,7 @@ public interface Function { R apply(T t); } - public static > Range emptyRange(Class clazz) { + public static > Range emptyRange(Class clazz) { return new Range( null, null, diff --git a/hibernate-types-43/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java b/hibernate-types-43/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java index d3ae0097c..f196e3fbf 100644 --- a/hibernate-types-43/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java +++ b/hibernate-types-43/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java @@ -23,7 +23,7 @@ * @author Edgar Asatryan * @author Vlad Mihalcea */ -public final class Range implements Serializable { +public final class Range> implements Serializable { public static final int LOWER_INCLUSIVE = 1 << 1; public static final int LOWER_EXCLUSIVE = 1 << 2; @@ -67,7 +67,7 @@ private Range(T lower, T upper, int mask, Class clazz) { * @return The closed range. */ @SuppressWarnings("unchecked") - public static > Range closed(T lower, T upper) { + public static > Range closed(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range(lower, upper, LOWER_INCLUSIVE | UPPER_INCLUSIVE, (Class) lower.getClass()); @@ -88,7 +88,7 @@ public static > Range closed(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range open(T lower, T upper) { + public static > Range open(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range(lower, upper, LOWER_EXCLUSIVE | UPPER_EXCLUSIVE, (Class) lower.getClass()); @@ -109,7 +109,7 @@ public static > Range open(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range openClosed(T lower, T upper) { + public static > Range openClosed(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range(lower, upper, LOWER_EXCLUSIVE | UPPER_INCLUSIVE, (Class) lower.getClass()); @@ -130,7 +130,7 @@ public static > Range openClosed(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range closedOpen(T lower, T upper) { + public static > Range closedOpen(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range(lower, upper, LOWER_INCLUSIVE | UPPER_EXCLUSIVE, (Class) lower.getClass()); @@ -150,7 +150,7 @@ public static > Range closedOpen(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range openInfinite(T lower) { + public static > Range openInfinite(T lower) { Objects.requireNonNull(lower); return new Range(lower, null, LOWER_EXCLUSIVE | UPPER_INFINITE, (Class) lower.getClass()); } @@ -169,7 +169,7 @@ public static > Range openInfinite(T lower) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range closedInfinite(T lower) { + public static > Range closedInfinite(T lower) { Objects.requireNonNull(lower); return new Range(lower, null, LOWER_INCLUSIVE | UPPER_INFINITE, lower.getClass()); } @@ -188,7 +188,7 @@ public static > Range closedInfinite(T lower) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range infiniteOpen(T upper) { + public static > Range infiniteOpen(T upper) { Objects.requireNonNull(upper); return new Range(null, upper, UPPER_EXCLUSIVE | LOWER_INFINITE, (Class) upper.getClass()); } @@ -207,7 +207,7 @@ public static > Range infiniteOpen(T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range infiniteClosed(T upper) { + public static > Range infiniteClosed(T upper) { Objects.requireNonNull(upper); return new Range(null, upper, UPPER_INCLUSIVE | LOWER_INFINITE, (Class) upper.getClass()); } @@ -226,12 +226,12 @@ public static > Range infiniteClosed(T upper) { * @return The infinite range. */ @SuppressWarnings("unchecked") - public static > Range infinite(Class cls) { + public static > Range infinite(Class cls) { return new Range(null, null, LOWER_INFINITE | UPPER_INFINITE, cls); } @SuppressWarnings("unchecked") - public static Range ofString(String str, Function converter, Class clazz) { + public static > Range ofString(String str, Function converter, Class clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } @@ -367,9 +367,9 @@ public boolean equals(Object o) { if (!(o instanceof Range)) return false; Range range = (Range) o; return mask == range.mask && - Objects.equals(lower, range.lower) && - Objects.equals(upper, range.upper) && - Objects.equals(clazz, range.clazz); + Objects.equals(lower, range.lower) && + Objects.equals(upper, range.upper) && + Objects.equals(clazz, range.clazz); } @Override @@ -380,22 +380,22 @@ public int hashCode() { @Override public String toString() { return "Range{" + "lower=" + lower + - ", upper=" + upper + - ", mask=" + mask + - ", clazz=" + clazz + - '}'; + ", upper=" + upper + + ", mask=" + mask + + ", clazz=" + clazz + + '}'; } public boolean hasMask(int flag) { return (mask & flag) == flag; } - + public boolean isLowerBoundClosed() { - return hasLowerBound() && hasMask(LOWER_INCLUSIVE); + return hasLowerBound() && hasMask(LOWER_INCLUSIVE); } - + public boolean isUpperBoundClosed() { - return hasUpperBound() && hasMask(UPPER_INCLUSIVE); + return hasUpperBound() && hasMask(UPPER_INCLUSIVE); } public boolean hasLowerBound() { @@ -488,10 +488,10 @@ public String asString() { StringBuilder sb = new StringBuilder(); sb.append(hasMask(LOWER_INCLUSIVE) ? '[' : '(') - .append(hasLowerBound() ? boundToString().apply(lower) : "") - .append(",") - .append(hasUpperBound() ? boundToString().apply(upper) : "") - .append(hasMask(UPPER_INCLUSIVE) ? ']' : ')'); + .append(hasLowerBound() ? boundToString().apply(lower) : "") + .append(",") + .append(hasUpperBound() ? boundToString().apply(upper) : "") + .append(hasMask(UPPER_INCLUSIVE) ? ']' : ')'); return sb.toString(); } @@ -510,11 +510,11 @@ Class getClazz() { } public interface Function { - + R apply(T t); } - public static > Range emptyRange(Class clazz) { + public static > Range emptyRange(Class clazz) { return new Range( null, null, diff --git a/hibernate-types-5/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java b/hibernate-types-5/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java index d3ae0097c..f196e3fbf 100644 --- a/hibernate-types-5/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java +++ b/hibernate-types-5/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java @@ -23,7 +23,7 @@ * @author Edgar Asatryan * @author Vlad Mihalcea */ -public final class Range implements Serializable { +public final class Range> implements Serializable { public static final int LOWER_INCLUSIVE = 1 << 1; public static final int LOWER_EXCLUSIVE = 1 << 2; @@ -67,7 +67,7 @@ private Range(T lower, T upper, int mask, Class clazz) { * @return The closed range. */ @SuppressWarnings("unchecked") - public static > Range closed(T lower, T upper) { + public static > Range closed(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range(lower, upper, LOWER_INCLUSIVE | UPPER_INCLUSIVE, (Class) lower.getClass()); @@ -88,7 +88,7 @@ public static > Range closed(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range open(T lower, T upper) { + public static > Range open(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range(lower, upper, LOWER_EXCLUSIVE | UPPER_EXCLUSIVE, (Class) lower.getClass()); @@ -109,7 +109,7 @@ public static > Range open(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range openClosed(T lower, T upper) { + public static > Range openClosed(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range(lower, upper, LOWER_EXCLUSIVE | UPPER_INCLUSIVE, (Class) lower.getClass()); @@ -130,7 +130,7 @@ public static > Range openClosed(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range closedOpen(T lower, T upper) { + public static > Range closedOpen(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range(lower, upper, LOWER_INCLUSIVE | UPPER_EXCLUSIVE, (Class) lower.getClass()); @@ -150,7 +150,7 @@ public static > Range closedOpen(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range openInfinite(T lower) { + public static > Range openInfinite(T lower) { Objects.requireNonNull(lower); return new Range(lower, null, LOWER_EXCLUSIVE | UPPER_INFINITE, (Class) lower.getClass()); } @@ -169,7 +169,7 @@ public static > Range openInfinite(T lower) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range closedInfinite(T lower) { + public static > Range closedInfinite(T lower) { Objects.requireNonNull(lower); return new Range(lower, null, LOWER_INCLUSIVE | UPPER_INFINITE, lower.getClass()); } @@ -188,7 +188,7 @@ public static > Range closedInfinite(T lower) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range infiniteOpen(T upper) { + public static > Range infiniteOpen(T upper) { Objects.requireNonNull(upper); return new Range(null, upper, UPPER_EXCLUSIVE | LOWER_INFINITE, (Class) upper.getClass()); } @@ -207,7 +207,7 @@ public static > Range infiniteOpen(T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range infiniteClosed(T upper) { + public static > Range infiniteClosed(T upper) { Objects.requireNonNull(upper); return new Range(null, upper, UPPER_INCLUSIVE | LOWER_INFINITE, (Class) upper.getClass()); } @@ -226,12 +226,12 @@ public static > Range infiniteClosed(T upper) { * @return The infinite range. */ @SuppressWarnings("unchecked") - public static > Range infinite(Class cls) { + public static > Range infinite(Class cls) { return new Range(null, null, LOWER_INFINITE | UPPER_INFINITE, cls); } @SuppressWarnings("unchecked") - public static Range ofString(String str, Function converter, Class clazz) { + public static > Range ofString(String str, Function converter, Class clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } @@ -367,9 +367,9 @@ public boolean equals(Object o) { if (!(o instanceof Range)) return false; Range range = (Range) o; return mask == range.mask && - Objects.equals(lower, range.lower) && - Objects.equals(upper, range.upper) && - Objects.equals(clazz, range.clazz); + Objects.equals(lower, range.lower) && + Objects.equals(upper, range.upper) && + Objects.equals(clazz, range.clazz); } @Override @@ -380,22 +380,22 @@ public int hashCode() { @Override public String toString() { return "Range{" + "lower=" + lower + - ", upper=" + upper + - ", mask=" + mask + - ", clazz=" + clazz + - '}'; + ", upper=" + upper + + ", mask=" + mask + + ", clazz=" + clazz + + '}'; } public boolean hasMask(int flag) { return (mask & flag) == flag; } - + public boolean isLowerBoundClosed() { - return hasLowerBound() && hasMask(LOWER_INCLUSIVE); + return hasLowerBound() && hasMask(LOWER_INCLUSIVE); } - + public boolean isUpperBoundClosed() { - return hasUpperBound() && hasMask(UPPER_INCLUSIVE); + return hasUpperBound() && hasMask(UPPER_INCLUSIVE); } public boolean hasLowerBound() { @@ -488,10 +488,10 @@ public String asString() { StringBuilder sb = new StringBuilder(); sb.append(hasMask(LOWER_INCLUSIVE) ? '[' : '(') - .append(hasLowerBound() ? boundToString().apply(lower) : "") - .append(",") - .append(hasUpperBound() ? boundToString().apply(upper) : "") - .append(hasMask(UPPER_INCLUSIVE) ? ']' : ')'); + .append(hasLowerBound() ? boundToString().apply(lower) : "") + .append(",") + .append(hasUpperBound() ? boundToString().apply(upper) : "") + .append(hasMask(UPPER_INCLUSIVE) ? ']' : ')'); return sb.toString(); } @@ -510,11 +510,11 @@ Class getClazz() { } public interface Function { - + R apply(T t); } - public static > Range emptyRange(Class clazz) { + public static > Range emptyRange(Class clazz) { return new Range( null, null, diff --git a/hibernate-types-52/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java b/hibernate-types-52/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java index aff8356e2..976b8a3e7 100644 --- a/hibernate-types-52/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java +++ b/hibernate-types-52/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java @@ -27,7 +27,7 @@ * @author Edgar Asatryan * @author Vlad Mihalcea */ -public final class Range implements Serializable { +public final class Range> implements Serializable { public static final int LOWER_INCLUSIVE = 1 << 1; public static final int LOWER_EXCLUSIVE = 1 << 2; @@ -88,7 +88,7 @@ private Range(T lower, T upper, int mask, Class clazz) { * @return The closed range. */ @SuppressWarnings("unchecked") - public static > Range closed(T lower, T upper) { + public static > Range closed(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range<>(lower, upper, LOWER_INCLUSIVE | UPPER_INCLUSIVE, (Class) lower.getClass()); @@ -109,7 +109,7 @@ public static > Range closed(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range open(T lower, T upper) { + public static > Range open(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range<>(lower, upper, LOWER_EXCLUSIVE | UPPER_EXCLUSIVE, (Class) lower.getClass()); @@ -130,7 +130,7 @@ public static > Range open(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range openClosed(T lower, T upper) { + public static > Range openClosed(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range<>(lower, upper, LOWER_EXCLUSIVE | UPPER_INCLUSIVE, (Class) lower.getClass()); @@ -151,7 +151,7 @@ public static > Range openClosed(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range closedOpen(T lower, T upper) { + public static > Range closedOpen(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range<>(lower, upper, LOWER_INCLUSIVE | UPPER_EXCLUSIVE, (Class) lower.getClass()); @@ -171,7 +171,7 @@ public static > Range closedOpen(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range openInfinite(T lower) { + public static > Range openInfinite(T lower) { Objects.requireNonNull(lower); return new Range<>(lower, null, LOWER_EXCLUSIVE | UPPER_INFINITE, (Class) lower.getClass()); } @@ -190,9 +190,9 @@ public static > Range openInfinite(T lower) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range closedInfinite(T lower) { + public static > Range closedInfinite(T lower) { Objects.requireNonNull(lower); - return new Range(lower, null, LOWER_INCLUSIVE | UPPER_INFINITE, lower.getClass()); + return new Range<>(lower, null, LOWER_INCLUSIVE | UPPER_INFINITE, (Class) lower.getClass()); } /** @@ -209,7 +209,7 @@ public static > Range closedInfinite(T lower) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range infiniteOpen(T upper) { + public static > Range infiniteOpen(T upper) { Objects.requireNonNull(upper); return new Range<>(null, upper, UPPER_EXCLUSIVE | LOWER_INFINITE, (Class) upper.getClass()); } @@ -228,7 +228,7 @@ public static > Range infiniteOpen(T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range infiniteClosed(T upper) { + public static > Range infiniteClosed(T upper) { Objects.requireNonNull(upper); return new Range<>(null, upper, UPPER_INCLUSIVE | LOWER_INFINITE, (Class) upper.getClass()); } @@ -246,13 +246,11 @@ public static > Range infiniteClosed(T upper) { * * @return The infinite range. */ - @SuppressWarnings("unchecked") - public static > Range infinite(Class cls) { + public static > Range infinite(Class cls) { return new Range<>(null, null, LOWER_INFINITE | UPPER_INFINITE, cls); } - @SuppressWarnings("unchecked") - public static Range ofString(String str, Function converter, Class clazz) { + public static > Range ofString(String str, Function converter, Class clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } @@ -485,9 +483,9 @@ public boolean equals(Object o) { if (!(o instanceof Range)) return false; Range range = (Range) o; return mask == range.mask && - Objects.equals(lower, range.lower) && - Objects.equals(upper, range.upper) && - Objects.equals(clazz, range.clazz); + Objects.equals(lower, range.lower) && + Objects.equals(upper, range.upper) && + Objects.equals(clazz, range.clazz); } @Override @@ -498,22 +496,22 @@ public int hashCode() { @Override public String toString() { return "Range{" + "lower=" + lower + - ", upper=" + upper + - ", mask=" + mask + - ", clazz=" + clazz + - '}'; + ", upper=" + upper + + ", mask=" + mask + + ", clazz=" + clazz + + '}'; } public boolean hasMask(int flag) { return (mask & flag) == flag; } - + public boolean isLowerBoundClosed() { - return hasLowerBound() && hasMask(LOWER_INCLUSIVE); + return hasLowerBound() && hasMask(LOWER_INCLUSIVE); } - + public boolean isUpperBoundClosed() { - return hasUpperBound() && hasMask(UPPER_INCLUSIVE); + return hasUpperBound() && hasMask(UPPER_INCLUSIVE); } public boolean hasLowerBound() { @@ -562,7 +560,6 @@ public T upper() { * * @return Whether {@code point} in this range or not. */ - @SuppressWarnings("unchecked") public boolean contains(T point) { boolean l = hasLowerBound(); boolean u = hasUpperBound(); @@ -606,10 +603,10 @@ public String asString() { StringBuilder sb = new StringBuilder(); sb.append(hasMask(LOWER_INCLUSIVE) ? '[' : '(') - .append(hasLowerBound() ? boundToString().apply(lower) : "") - .append(",") - .append(hasUpperBound() ? boundToString().apply(upper) : "") - .append(hasMask(UPPER_INCLUSIVE) ? ']' : ')'); + .append(hasLowerBound() ? boundToString().apply(lower) : "") + .append(",") + .append(hasUpperBound() ? boundToString().apply(upper) : "") + .append(hasMask(UPPER_INCLUSIVE) ? ']' : ')'); return sb.toString(); } @@ -628,8 +625,8 @@ Class getClazz() { return clazz; } - public static > Range emptyRange(Class clazz) { - return new Range( + public static > Range emptyRange(Class clazz) { + return new Range<>( null, null, LOWER_INFINITE|UPPER_INFINITE, diff --git a/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java b/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java index aff8356e2..976b8a3e7 100644 --- a/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java +++ b/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java @@ -27,7 +27,7 @@ * @author Edgar Asatryan * @author Vlad Mihalcea */ -public final class Range implements Serializable { +public final class Range> implements Serializable { public static final int LOWER_INCLUSIVE = 1 << 1; public static final int LOWER_EXCLUSIVE = 1 << 2; @@ -88,7 +88,7 @@ private Range(T lower, T upper, int mask, Class clazz) { * @return The closed range. */ @SuppressWarnings("unchecked") - public static > Range closed(T lower, T upper) { + public static > Range closed(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range<>(lower, upper, LOWER_INCLUSIVE | UPPER_INCLUSIVE, (Class) lower.getClass()); @@ -109,7 +109,7 @@ public static > Range closed(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range open(T lower, T upper) { + public static > Range open(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range<>(lower, upper, LOWER_EXCLUSIVE | UPPER_EXCLUSIVE, (Class) lower.getClass()); @@ -130,7 +130,7 @@ public static > Range open(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range openClosed(T lower, T upper) { + public static > Range openClosed(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range<>(lower, upper, LOWER_EXCLUSIVE | UPPER_INCLUSIVE, (Class) lower.getClass()); @@ -151,7 +151,7 @@ public static > Range openClosed(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range closedOpen(T lower, T upper) { + public static > Range closedOpen(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range<>(lower, upper, LOWER_INCLUSIVE | UPPER_EXCLUSIVE, (Class) lower.getClass()); @@ -171,7 +171,7 @@ public static > Range closedOpen(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range openInfinite(T lower) { + public static > Range openInfinite(T lower) { Objects.requireNonNull(lower); return new Range<>(lower, null, LOWER_EXCLUSIVE | UPPER_INFINITE, (Class) lower.getClass()); } @@ -190,9 +190,9 @@ public static > Range openInfinite(T lower) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range closedInfinite(T lower) { + public static > Range closedInfinite(T lower) { Objects.requireNonNull(lower); - return new Range(lower, null, LOWER_INCLUSIVE | UPPER_INFINITE, lower.getClass()); + return new Range<>(lower, null, LOWER_INCLUSIVE | UPPER_INFINITE, (Class) lower.getClass()); } /** @@ -209,7 +209,7 @@ public static > Range closedInfinite(T lower) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range infiniteOpen(T upper) { + public static > Range infiniteOpen(T upper) { Objects.requireNonNull(upper); return new Range<>(null, upper, UPPER_EXCLUSIVE | LOWER_INFINITE, (Class) upper.getClass()); } @@ -228,7 +228,7 @@ public static > Range infiniteOpen(T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range infiniteClosed(T upper) { + public static > Range infiniteClosed(T upper) { Objects.requireNonNull(upper); return new Range<>(null, upper, UPPER_INCLUSIVE | LOWER_INFINITE, (Class) upper.getClass()); } @@ -246,13 +246,11 @@ public static > Range infiniteClosed(T upper) { * * @return The infinite range. */ - @SuppressWarnings("unchecked") - public static > Range infinite(Class cls) { + public static > Range infinite(Class cls) { return new Range<>(null, null, LOWER_INFINITE | UPPER_INFINITE, cls); } - @SuppressWarnings("unchecked") - public static Range ofString(String str, Function converter, Class clazz) { + public static > Range ofString(String str, Function converter, Class clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } @@ -485,9 +483,9 @@ public boolean equals(Object o) { if (!(o instanceof Range)) return false; Range range = (Range) o; return mask == range.mask && - Objects.equals(lower, range.lower) && - Objects.equals(upper, range.upper) && - Objects.equals(clazz, range.clazz); + Objects.equals(lower, range.lower) && + Objects.equals(upper, range.upper) && + Objects.equals(clazz, range.clazz); } @Override @@ -498,22 +496,22 @@ public int hashCode() { @Override public String toString() { return "Range{" + "lower=" + lower + - ", upper=" + upper + - ", mask=" + mask + - ", clazz=" + clazz + - '}'; + ", upper=" + upper + + ", mask=" + mask + + ", clazz=" + clazz + + '}'; } public boolean hasMask(int flag) { return (mask & flag) == flag; } - + public boolean isLowerBoundClosed() { - return hasLowerBound() && hasMask(LOWER_INCLUSIVE); + return hasLowerBound() && hasMask(LOWER_INCLUSIVE); } - + public boolean isUpperBoundClosed() { - return hasUpperBound() && hasMask(UPPER_INCLUSIVE); + return hasUpperBound() && hasMask(UPPER_INCLUSIVE); } public boolean hasLowerBound() { @@ -562,7 +560,6 @@ public T upper() { * * @return Whether {@code point} in this range or not. */ - @SuppressWarnings("unchecked") public boolean contains(T point) { boolean l = hasLowerBound(); boolean u = hasUpperBound(); @@ -606,10 +603,10 @@ public String asString() { StringBuilder sb = new StringBuilder(); sb.append(hasMask(LOWER_INCLUSIVE) ? '[' : '(') - .append(hasLowerBound() ? boundToString().apply(lower) : "") - .append(",") - .append(hasUpperBound() ? boundToString().apply(upper) : "") - .append(hasMask(UPPER_INCLUSIVE) ? ']' : ')'); + .append(hasLowerBound() ? boundToString().apply(lower) : "") + .append(",") + .append(hasUpperBound() ? boundToString().apply(upper) : "") + .append(hasMask(UPPER_INCLUSIVE) ? ']' : ')'); return sb.toString(); } @@ -628,8 +625,8 @@ Class getClazz() { return clazz; } - public static > Range emptyRange(Class clazz) { - return new Range( + public static > Range emptyRange(Class clazz) { + return new Range<>( null, null, LOWER_INFINITE|UPPER_INFINITE, diff --git a/hibernate-types-60/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java b/hibernate-types-60/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java index aff8356e2..3311f8682 100644 --- a/hibernate-types-60/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java +++ b/hibernate-types-60/src/main/java/com/vladmihalcea/hibernate/type/range/Range.java @@ -27,7 +27,7 @@ * @author Edgar Asatryan * @author Vlad Mihalcea */ -public final class Range implements Serializable { +public final class Range> implements Serializable { public static final int LOWER_INCLUSIVE = 1 << 1; public static final int LOWER_EXCLUSIVE = 1 << 2; @@ -88,7 +88,7 @@ private Range(T lower, T upper, int mask, Class clazz) { * @return The closed range. */ @SuppressWarnings("unchecked") - public static > Range closed(T lower, T upper) { + public static > Range closed(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range<>(lower, upper, LOWER_INCLUSIVE | UPPER_INCLUSIVE, (Class) lower.getClass()); @@ -109,7 +109,7 @@ public static > Range closed(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range open(T lower, T upper) { + public static > Range open(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range<>(lower, upper, LOWER_EXCLUSIVE | UPPER_EXCLUSIVE, (Class) lower.getClass()); @@ -130,7 +130,7 @@ public static > Range open(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range openClosed(T lower, T upper) { + public static > Range openClosed(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range<>(lower, upper, LOWER_EXCLUSIVE | UPPER_INCLUSIVE, (Class) lower.getClass()); @@ -151,7 +151,7 @@ public static > Range openClosed(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range closedOpen(T lower, T upper) { + public static > Range closedOpen(T lower, T upper) { Objects.requireNonNull(lower); Objects.requireNonNull(upper); return new Range<>(lower, upper, LOWER_INCLUSIVE | UPPER_EXCLUSIVE, (Class) lower.getClass()); @@ -171,7 +171,7 @@ public static > Range closedOpen(T lower, T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range openInfinite(T lower) { + public static > Range openInfinite(T lower) { Objects.requireNonNull(lower); return new Range<>(lower, null, LOWER_EXCLUSIVE | UPPER_INFINITE, (Class) lower.getClass()); } @@ -190,9 +190,9 @@ public static > Range openInfinite(T lower) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range closedInfinite(T lower) { + public static > Range closedInfinite(T lower) { Objects.requireNonNull(lower); - return new Range(lower, null, LOWER_INCLUSIVE | UPPER_INFINITE, lower.getClass()); + return new Range<>(lower, null, LOWER_INCLUSIVE | UPPER_INFINITE, (Class) lower.getClass()); } /** @@ -209,7 +209,7 @@ public static > Range closedInfinite(T lower) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range infiniteOpen(T upper) { + public static > Range infiniteOpen(T upper) { Objects.requireNonNull(upper); return new Range<>(null, upper, UPPER_EXCLUSIVE | LOWER_INFINITE, (Class) upper.getClass()); } @@ -228,7 +228,7 @@ public static > Range infiniteOpen(T upper) { * @return The range. */ @SuppressWarnings("unchecked") - public static > Range infiniteClosed(T upper) { + public static > Range infiniteClosed(T upper) { Objects.requireNonNull(upper); return new Range<>(null, upper, UPPER_INCLUSIVE | LOWER_INFINITE, (Class) upper.getClass()); } @@ -246,13 +246,11 @@ public static > Range infiniteClosed(T upper) { * * @return The infinite range. */ - @SuppressWarnings("unchecked") - public static > Range infinite(Class cls) { + public static > Range infinite(Class cls) { return new Range<>(null, null, LOWER_INFINITE | UPPER_INFINITE, cls); } - @SuppressWarnings("unchecked") - public static Range ofString(String str, Function converter, Class clazz) { + public static > Range ofString(String str, Function converter, Class clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } @@ -562,7 +560,6 @@ public T upper() { * * @return Whether {@code point} in this range or not. */ - @SuppressWarnings("unchecked") public boolean contains(T point) { boolean l = hasLowerBound(); boolean u = hasUpperBound(); @@ -628,8 +625,8 @@ Class getClazz() { return clazz; } - public static > Range emptyRange(Class clazz) { - return new Range( + public static > Range emptyRange(Class clazz) { + return new Range<>( null, null, LOWER_INFINITE|UPPER_INFINITE,