diff --git a/querydsl-core/src/main/java/com/mysema/query/types/expr/EDateOrTime.java b/querydsl-core/src/main/java/com/mysema/query/types/expr/EDateOrTime.java index 50084ef1a..915c51da7 100644 --- a/querydsl-core/src/main/java/com/mysema/query/types/expr/EDateOrTime.java +++ b/querydsl-core/src/main/java/com/mysema/query/types/expr/EDateOrTime.java @@ -20,18 +20,42 @@ public abstract class EDateOrTime extends EComparable { super(type); } + /** + * Create a this > right expression + * + * @param right + * @return + */ public EBoolean after(D right) { return gt(right); } + /** + * Create a this > right expression + * + * @param right + * @return + */ public EBoolean after(Expr right) { return gt(right); } + /** + * Create a this < right expression + * + * @param right + * @return + */ public EBoolean before(D right) { return lt(right); } + /** + * Create a this < right expression + * + * @param right + * @return + */ public EBoolean before(Expr right) { return lt(right); } diff --git a/querydsl-core/src/main/java/com/mysema/query/types/expr/ENumber.java b/querydsl-core/src/main/java/com/mysema/query/types/expr/ENumber.java index 661ffdd1a..da7ab8d6a 100644 --- a/querydsl-core/src/main/java/com/mysema/query/types/expr/ENumber.java +++ b/querydsl-core/src/main/java/com/mysema/query/types/expr/ENumber.java @@ -116,19 +116,21 @@ public abstract class ENumber> extends ECompara return random; } - private volatile ENumber abs, sum, min, max; + private volatile ENumber abs, sum, min, max, floor, ceil; private volatile ENumber avg, sqrt; private volatile ENumber negation; - private volatile ENumber round, floor, ceil; + private volatile ENumber round; public ENumber(Class type) { super(type); } /** + * Get the absolute value of this expression + * * @return abs(this) */ public ENumber abs() { @@ -139,6 +141,8 @@ public abstract class ENumber> extends ECompara } /** + * Get the sum of this and right + * * @param right * @return this + right */ @@ -147,6 +151,8 @@ public abstract class ENumber> extends ECompara } /** + * Get the sum of this and right + * * @param right * @return this + right */ @@ -155,6 +161,8 @@ public abstract class ENumber> extends ECompara } /** + * Get the average value of this expression (aggregation) + * * @return avg(this) */ public ENumber avg(){ @@ -211,6 +219,10 @@ public abstract class ENumber> extends ECompara } /** + * Returns the smallest (closest to negative infinity) + * double value that is greater than or equal to the + * argument and is equal to a mathematical integer + * * @return ceil(this) * @see java.lang.Math#ceil(double) */ @@ -222,18 +234,22 @@ public abstract class ENumber> extends ECompara } /** + * Get the result of the operation this / right + * * @param right * @return this / right */ - public > ENumber div(Expr right) { + public > ENumber divide(Expr right) { return ONumber.create(Double.class, Ops.DIV, this, right); } /** + * Get the result of the operation this / right + * * @param right * @return this / right */ - public > ENumber div(N right) { + public > ENumber divide(N right) { return ONumber.create(Double.class, Ops.DIV, this, ENumber.create(right)); } @@ -259,6 +275,10 @@ public abstract class ENumber> extends ECompara } /** + * Returns the largest (closest to positive infinity) + * double value that is less than or equal to the + * argument and is equal to a mathematical integer. + * * @return floor(this) * @see java.lang.Math#floor(double) */ @@ -386,6 +406,8 @@ public abstract class ENumber> extends ECompara } /** + * Get the maximum value of this expression (aggregation) + * * @return max(this) */ public ENumber max(){ @@ -396,6 +418,8 @@ public abstract class ENumber> extends ECompara } /** + * Get the minimum value of this expression (aggregation) + * * @return min(this) */ public ENumber min(){ @@ -406,18 +430,22 @@ public abstract class ENumber> extends ECompara } /** + * Get the result of the operation this * right + * * @param right * @return this * right */ - public > ENumber mult(Expr right) { + public > ENumber multiply(Expr right) { return ONumber.create(getType(), Ops.MULT, this, right); } /** + * Get the result of the operation this * right + * * @param right * @return this * right */ - public ENumber mult(Number right) { + public ENumber multiply(Number right) { return ONumber.create(getType(), Ops.MULT, this, ENumber.create(right)); } @@ -428,19 +456,21 @@ public abstract class ENumber> extends ECompara */ public ENumber negate(){ if (negation == null){ - negation = mult(-1); + negation = multiply(-1); } return negation; } /** + * Returns the closest int to the argument. + * * @return round(this) * @see java.lang.Math#round(double) * @see java.lang.Math#round(float) */ - public ENumber round() { + public ENumber round() { if (round == null){ - round = ONumber.create(getType(), MathOps.ROUND, this); + round = ONumber.create(Integer.class, MathOps.ROUND, this); } return round; } @@ -456,7 +486,8 @@ public abstract class ENumber> extends ECompara } /** - * Returns the square root of this numeric expressions + * Get the square root of this numeric expressions + * * @return sqrt(this) */ public ENumber sqrt(){ @@ -467,22 +498,28 @@ public abstract class ENumber> extends ECompara } /** + * Get the difference of this and right + * * @param right * @return this - right */ - public > ENumber sub(Expr right) { + public > ENumber subtract(Expr right) { return ONumber.create(getType(), Ops.SUB, this, right); } - + /** + * Get the difference of this and right + * * @param right * @return this - right */ - public ENumber sub(Number right) { + public ENumber subtract(Number right) { return ONumber.create(getType(), Ops.SUB, this, ENumber.create(right)); } /** + * Get the sum of this expression (aggregation) + * * @return sum(this) */ public ENumber sum(){ diff --git a/querydsl-core/src/main/java/com/mysema/query/types/expr/ENumberConst.java b/querydsl-core/src/main/java/com/mysema/query/types/expr/ENumberConst.java index 0e80701bd..ef8f1eaf3 100644 --- a/querydsl-core/src/main/java/com/mysema/query/types/expr/ENumberConst.java +++ b/querydsl-core/src/main/java/com/mysema/query/types/expr/ENumberConst.java @@ -72,17 +72,17 @@ public class ENumberConst> extends ENumber i } @Override - public ENumber sub(Number right) { + public ENumber subtract(Number right) { return ENumber.create(MathUtils.difference(constant, right)); } @SuppressWarnings("unchecked") @Override - public > ENumber sub(Expr right) { + public > ENumber subtract(Expr right) { if (right instanceof Constant){ - return sub(((Constant)right).getConstant()); + return subtract(((Constant)right).getConstant()); }else{ - return super.sub(right); + return super.subtract(right); } } diff --git a/querydsl-core/src/main/java/com/mysema/query/types/expr/EString.java b/querydsl-core/src/main/java/com/mysema/query/types/expr/EString.java index 828704e4d..397155bc4 100644 --- a/querydsl-core/src/main/java/com/mysema/query/types/expr/EString.java +++ b/querydsl-core/src/main/java/com/mysema/query/types/expr/EString.java @@ -75,6 +75,8 @@ public abstract class EString extends EComparable { } /** + * Get the concatenation of this and str + * * @param str * @return this + str */ @@ -83,6 +85,8 @@ public abstract class EString extends EComparable { } /** + * Get the concatenation of this and str + * * @param str * @return this + str */ @@ -91,6 +95,8 @@ public abstract class EString extends EComparable { } /** + * Get the character at the given index + * * @param i * @return this.charAt(i) * @see java.lang.String#charAt(int) @@ -100,6 +106,8 @@ public abstract class EString extends EComparable { } /** + * Get the character at the given index + * * @param i * @return this.charAt(i) * @see java.lang.String#charAt(int) @@ -109,6 +117,8 @@ public abstract class EString extends EComparable { } /** + * Get the concatenation of this and str + * * @param str * @return this + str */ @@ -117,6 +127,8 @@ public abstract class EString extends EComparable { } /** + * Get the concatenation of this and str + * * @param str * @return this + str */ @@ -125,6 +137,8 @@ public abstract class EString extends EComparable { } /** + * Returns true if the given String is contained + * * @param str * @return this.contains(str) * @see java.lang.String#contains(CharSequence) @@ -134,6 +148,8 @@ public abstract class EString extends EComparable { } /** + * Returns true if the given String is contained + * * @param str * @return this.contains(str) * @see java.lang.String#contains(CharSequence) @@ -143,6 +159,8 @@ public abstract class EString extends EComparable { } /** + * Returns true if this ends with str + * * @param str * @return this.endsWith(str) * @see java.lang.String#endsWith(String) @@ -152,8 +170,10 @@ public abstract class EString extends EComparable { } /** + * Returns true if this ends with str + * * @param str - * @param caseSensitive + * @param caseSensitive case sensitivity of operation * @return * @see java.lang.String#endsWith(String) */ @@ -166,6 +186,8 @@ public abstract class EString extends EComparable { } /** + * Returns true if this ends with str + * * @param str * @return this.endsWith(str) * @see java.lang.String#endsWith(String) @@ -175,6 +197,8 @@ public abstract class EString extends EComparable { } /** + * Returns true if this ends with str + * * @param str * @param caseSensitive * @return @@ -185,6 +209,9 @@ public abstract class EString extends EComparable { } /** + * Compares this {@code EString} to another {@code EString}, ignoring case + * considerations. + * * @param str * @return this.equalsIgnoreCase(str) * @see java.lang.String#equalsIgnoreCase(String) @@ -194,6 +221,9 @@ public abstract class EString extends EComparable { } /** + * Compares this {@code EString} to another {@code EString}, ignoring case + * considerations. + * * @param str * @return this.equalsIgnoreCase(str) * @see java.lang.String#equalsIgnoreCase(String) @@ -203,6 +233,8 @@ public abstract class EString extends EComparable { } /** + * Get the index of the given substring in this String + * * @param str * @return this.indexOf(str) * @see java.lang.String#indexOf(String) @@ -212,6 +244,8 @@ public abstract class EString extends EComparable { } /** + * Get the index of the given substring in this String + * * @param str * @return this.indexOf(str) * @see java.lang.String#indexOf(String) @@ -221,6 +255,8 @@ public abstract class EString extends EComparable { } /** + * Get the index of the given substring in this String, starting from the given index + * * @param str * @param i * @return this.indexOf(str, i) @@ -232,6 +268,8 @@ public abstract class EString extends EComparable { /** + * Get the index of the given substring in this String, starting from the given index + * * @param str * @param i * @return @@ -239,7 +277,10 @@ public abstract class EString extends EComparable { public ENumber indexOf(Expr str, int i) { return ONumber.create(Integer.class, Ops.INDEX_OF_2ARGS, this, str, ENumber.create(i)); } + /** + * Return true if this String is empty + * * @return this.isEmpty() * @see java.lang.String#isEmpty() */ @@ -251,6 +292,8 @@ public abstract class EString extends EComparable { } /** + * Return true if this String is not empty + * * @return !this.isEmpty() * @see java.lang.String#isEmpty() */ @@ -258,8 +301,9 @@ public abstract class EString extends EComparable { return isEmpty().not(); } - /** + * Return the length of this String + * * @return this.length() * @see java.lang.String#length() */ @@ -291,6 +335,7 @@ public abstract class EString extends EComparable { } /** + * Get the lower case form * * @return this.toLowerCase() * @see java.lang.String#toLowerCase() @@ -303,6 +348,8 @@ public abstract class EString extends EComparable { } /** + * Return true if this String matches the given regular expression + * * @param regex * @return this.matches(right) * @see java.lang.String#matches(String) @@ -312,6 +359,8 @@ public abstract class EString extends EComparable { } /** + * Return true if this String matches the given regular expression + * * @param regex * @return this.matches(regex) * @see java.lang.String#matches(String) @@ -321,6 +370,8 @@ public abstract class EString extends EComparable { } /** + * Prepend the given String and return the result + * * @param str * @return str + this */ @@ -329,6 +380,8 @@ public abstract class EString extends EComparable { } /** + * Prepend the given String and return the result + * * @param str * @return str + this */ @@ -348,6 +401,8 @@ public abstract class EString extends EComparable { } /** + * Return true if this starts with str + * * @param str * @return this.startsWith(str) * @see java.lang.String#startsWith(String) @@ -357,6 +412,8 @@ public abstract class EString extends EComparable { } /** + * Return true if this starts with str + * * @param str * @param caseSensitive * @return @@ -371,6 +428,8 @@ public abstract class EString extends EComparable { } /** + * Return true if this starts with str + * * @param str * @return this.startsWith(str) * @see java.lang.String#startsWith(String) @@ -380,6 +439,8 @@ public abstract class EString extends EComparable { } /** + * Return true if this starts with str + * * @param str * @param caseSensitive * @return @@ -397,6 +458,8 @@ public abstract class EString extends EComparable { } /** + * Get the given substring + * * @param beginIndex * @return this.substring(beginIndex) * @see java.lang.String#substring(int) @@ -406,6 +469,8 @@ public abstract class EString extends EComparable { } /** + * Get the given substring + * * @param beginIndex * @param endIndex * @return this.substring(beginIndex, endIndex) @@ -416,6 +481,7 @@ public abstract class EString extends EComparable { } /** + * Get the lower case form * * @return this.toLowerCase() * @see java.lang.String#toLowerCase() @@ -425,6 +491,7 @@ public abstract class EString extends EComparable { } /** + * Get the upper case form * * @return * @see java.lang.String#toUpperCase() @@ -434,6 +501,9 @@ public abstract class EString extends EComparable { } /** + * Get a copy of the string, with leading and trailing whitespace + * omitted. + * * @return * @see java.lang.String#trim() */ @@ -445,6 +515,8 @@ public abstract class EString extends EComparable { } /** + * Get the upper case form + * * @return * @see java.lang.String#toUpperCase() */ diff --git a/querydsl-core/src/test/java/com/mysema/query/MatchingFilters.java b/querydsl-core/src/test/java/com/mysema/query/MatchingFilters.java index 2ddbe716c..9580439f1 100644 --- a/querydsl-core/src/test/java/com/mysema/query/MatchingFilters.java +++ b/querydsl-core/src/test/java/com/mysema/query/MatchingFilters.java @@ -131,8 +131,8 @@ public class MatchingFilters { HashSet rv = new HashSet(); rv.add(expr.eq(other)); rv.add(expr.goe(other)); - rv.add(expr.gt(other.sub(1))); - rv.add(expr.gt(other.sub(2))); + rv.add(expr.gt(other.subtract(1))); + rv.add(expr.gt(other.subtract(2))); rv.add(expr.loe(other)); rv.add(expr.lt(other.add(1))); rv.add(expr.lt(other.add(2))); diff --git a/querydsl-core/src/test/java/com/mysema/query/Projections.java b/querydsl-core/src/test/java/com/mysema/query/Projections.java index 8efe959b3..7f77d471c 100644 --- a/querydsl-core/src/test/java/com/mysema/query/Projections.java +++ b/querydsl-core/src/test/java/com/mysema/query/Projections.java @@ -82,10 +82,10 @@ public class Projections { HashSet> rv = new HashSet>(); rv.add(expr.abs()); rv.add(expr.add(other)); - rv.add(expr.div(other)); - rv.add(expr.mult(other)); + rv.add(expr.divide(other)); + rv.add(expr.multiply(other)); rv.add(expr.sqrt()); - rv.add(expr.sub(other)); + rv.add(expr.subtract(other)); return rv; } diff --git a/querydsl-hql/src/test/java/com/mysema/query/hql/FeaturesTest.java b/querydsl-hql/src/test/java/com/mysema/query/hql/FeaturesTest.java index 819ce57a1..288739035 100644 --- a/querydsl-hql/src/test/java/com/mysema/query/hql/FeaturesTest.java +++ b/querydsl-hql/src/test/java/com/mysema/query/hql/FeaturesTest.java @@ -247,9 +247,9 @@ public class FeaturesTest extends AbstractQueryTest{ // toString("cat.kittens as kitten", cat.kittens.as(kitten)); toString("cat.bodyWeight + :a1", cat.bodyWeight.add(10)); - toString("cat.bodyWeight - :a1", cat.bodyWeight.sub(10)); - toString("cat.bodyWeight * :a1", cat.bodyWeight.mult(10)); - toString("cat.bodyWeight / :a1", cat.bodyWeight.div(10)); + toString("cat.bodyWeight - :a1", cat.bodyWeight.subtract(10)); + toString("cat.bodyWeight * :a1", cat.bodyWeight.multiply(10)); + toString("cat.bodyWeight / :a1", cat.bodyWeight.divide(10)); // toString("cat.bodyWeight as bw", cat.bodyWeight.as("bw")); diff --git a/querydsl-hql/src/test/java/com/mysema/query/hql/MathTest.java b/querydsl-hql/src/test/java/com/mysema/query/hql/MathTest.java index 8c3372696..8687bbe4a 100644 --- a/querydsl-hql/src/test/java/com/mysema/query/hql/MathTest.java +++ b/querydsl-hql/src/test/java/com/mysema/query/hql/MathTest.java @@ -15,32 +15,32 @@ public class MathTest extends AbstractQueryTest{ @Test public void test(){ PNumber path = QCat.cat.bodyWeight; - toString("(cat.bodyWeight - sum(cat.bodyWeight)) * cat.bodyWeight", path.sub(path.sum()).mult(path)); + toString("(cat.bodyWeight - sum(cat.bodyWeight)) * cat.bodyWeight", path.subtract(path.sum()).multiply(path)); } @Test public void testArithmeticOperationsInFunctionalWay() { toString("cat.bodyWeight + :a1", cat.bodyWeight.add(10)); - toString("cat.bodyWeight - :a1", cat.bodyWeight.sub(10)); - toString("cat.bodyWeight * :a1", cat.bodyWeight.mult(10)); - toString("cat.bodyWeight / :a1", cat.bodyWeight.div(10)); + toString("cat.bodyWeight - :a1", cat.bodyWeight.subtract(10)); + toString("cat.bodyWeight * :a1", cat.bodyWeight.multiply(10)); + toString("cat.bodyWeight / :a1", cat.bodyWeight.divide(10)); toString("cat.bodyWeight + :a1 < :a1", cat.bodyWeight.add(10).lt(10)); - toString("cat.bodyWeight - :a1 < :a1", cat.bodyWeight.sub(10).lt(10)); - toString("cat.bodyWeight * :a1 < :a1", cat.bodyWeight.mult(10).lt(10)); - toString("cat.bodyWeight / :a1 < :a2", cat.bodyWeight.div(10).lt(10d)); + toString("cat.bodyWeight - :a1 < :a1", cat.bodyWeight.subtract(10).lt(10)); + toString("cat.bodyWeight * :a1 < :a1", cat.bodyWeight.multiply(10).lt(10)); + toString("cat.bodyWeight / :a1 < :a2", cat.bodyWeight.divide(10).lt(10d)); - toString("(cat.bodyWeight + :a1) * :a2", cat.bodyWeight.add(10).mult(20)); - toString("(cat.bodyWeight - :a1) * :a2", cat.bodyWeight.sub(10).mult(20)); - toString("cat.bodyWeight * :a1 + :a2", cat.bodyWeight.mult(10).add(20)); - toString("cat.bodyWeight * :a1 - :a2", cat.bodyWeight.mult(10).sub(20)); + toString("(cat.bodyWeight + :a1) * :a2", cat.bodyWeight.add(10).multiply(20)); + toString("(cat.bodyWeight - :a1) * :a2", cat.bodyWeight.subtract(10).multiply(20)); + toString("cat.bodyWeight * :a1 + :a2", cat.bodyWeight.multiply(10).add(20)); + toString("cat.bodyWeight * :a1 - :a2", cat.bodyWeight.multiply(10).subtract(20)); QCat c1 = new QCat("c1"); QCat c2 = new QCat("c2"); QCat c3 = new QCat("c3"); - toString("c1.id + c2.id * c3.id", c1.id.add(c2.id.mult(c3.id))); - toString("c1.id * (c2.id + c3.id)", c1.id.mult(c2.id.add(c3.id))); - toString("(c1.id + c2.id) * c3.id", c1.id.add(c2.id).mult(c3.id)); + toString("c1.id + c2.id * c3.id", c1.id.add(c2.id.multiply(c3.id))); + toString("c1.id * (c2.id + c3.id)", c1.id.multiply(c2.id.add(c3.id))); + toString("(c1.id + c2.id) * c3.id", c1.id.add(c2.id).multiply(c3.id)); } @@ -48,9 +48,9 @@ public class MathTest extends AbstractQueryTest{ public void testMathematicalOperations() { // mathematical operators +, -, *, / cat.bodyWeight.add(kitten.bodyWeight); - cat.bodyWeight.sub(kitten.bodyWeight); - cat.bodyWeight.mult(kitten.bodyWeight); - cat.bodyWeight.div(kitten.bodyWeight); + cat.bodyWeight.subtract(kitten.bodyWeight); + cat.bodyWeight.multiply(kitten.bodyWeight); + cat.bodyWeight.divide(kitten.bodyWeight); } } diff --git a/querydsl-hql/src/test/java/com/mysema/query/hql/ParserTest.java b/querydsl-hql/src/test/java/com/mysema/query/hql/ParserTest.java index a9ba9ff20..6a613a9aa 100644 --- a/querydsl-hql/src/test/java/com/mysema/query/hql/ParserTest.java +++ b/querydsl-hql/src/test/java/com/mysema/query/hql/ParserTest.java @@ -397,7 +397,7 @@ public class ParserTest implements Constants { // parse( "select item from Item item, Order ord\n" // + "where ord.items[ size(ord.items) - 1 ] = item" ); query().select(item).from(item, ord).where( - ord.items(ord.items.size().sub(1)).eq(item)) + ord.items(ord.items.size().subtract(1)).eq(item)) .parse(); // // parse( "from eg.DomesticCat cat where upper(cat.name) like 'FRI%'" ); @@ -681,7 +681,7 @@ public class ParserTest implements Constants { // parse( "from Animal an where sqrt(an.bodyWeight)/2 > 10" ); query().from(an).where(an.bodyWeight.sqrt().gt(10.0)).parse(); - query().from(an).where(an.bodyWeight.sqrt().div(2d).gt(10.0)) + query().from(an).where(an.bodyWeight.sqrt().divide(2d).gt(10.0)) .parse(); // parse( // "from Animal an where (an.bodyWeight > 10 and an.bodyWeight < 100) or an.bodyWeight is null" @@ -708,7 +708,7 @@ public class ParserTest implements Constants { query().from(qat).orderBy(qat.toes.avg().asc()).parse(); // parse( "from Animal an order by sqrt(an.bodyWeight)/2" ); - query().from(qat).orderBy(an.bodyWeight.sqrt().div(2.0).asc()).parse(); + query().from(qat).orderBy(an.bodyWeight.sqrt().divide(2.0).asc()).parse(); } @Test