Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 88DFE200BE9 for ; Sun, 11 Dec 2016 09:18:50 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 85CC5160B20; Sun, 11 Dec 2016 08:18:50 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3CB39160B2C for ; Sun, 11 Dec 2016 09:18:49 +0100 (CET) Received: (qmail 11314 invoked by uid 500); 11 Dec 2016 08:18:48 -0000 Mailing-List: contact commits-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list commits@cayenne.apache.org Received: (qmail 11257 invoked by uid 99); 11 Dec 2016 08:18:48 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Dec 2016 08:18:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 41702ED225; Sun, 11 Dec 2016 08:18:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aadamchik@apache.org To: commits@cayenne.apache.org Date: Sun, 11 Dec 2016 08:18:50 -0000 Message-Id: <077772a6dbe94291a0fd39d238dabb26@git.apache.org> In-Reply-To: <2c09163cce2d4e66a0721bb27fc7738d@git.apache.org> References: <2c09163cce2d4e66a0721bb27fc7738d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/4] cayenne git commit: javadocs archived-at: Sun, 11 Dec 2016 08:18:50 -0000 javadocs Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/94d4d839 Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/94d4d839 Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/94d4d839 Branch: refs/heads/master Commit: 94d4d839ce8b3193970c4f4abd008ceca4040439 Parents: bff0e00 Author: Andrus Adamchik Authored: Sun Dec 11 10:41:49 2016 +0300 Committer: Andrus Adamchik Committed: Sun Dec 11 10:41:49 2016 +0300 ---------------------------------------------------------------------- .../java/org/apache/cayenne/exp/Property.java | 966 +++++++++---------- 1 file changed, 479 insertions(+), 487 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cayenne/blob/94d4d839/cayenne-server/src/main/java/org/apache/cayenne/exp/Property.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/main/java/org/apache/cayenne/exp/Property.java b/cayenne-server/src/main/java/org/apache/cayenne/exp/Property.java index 2de19ef..5560014 100644 --- a/cayenne-server/src/main/java/org/apache/cayenne/exp/Property.java +++ b/cayenne-server/src/main/java/org/apache/cayenne/exp/Property.java @@ -32,503 +32,495 @@ import org.apache.cayenne.reflect.PropertyUtils; *

* A property in a DataObject. *

- * + *

*

* Used to construct Expressions quickly and with type-safety, and to construct * Orderings *

- * + *

*

* Instances of this class are immutable *

- * - * @param - * The type this property returns. + * + * @param The type this property returns. * @since 4.0 */ public class Property { - /** - * Name of the property in the object - */ - private final String name; - - /** - * Constructs a new property with the given name. - */ - public Property(String name) { - this.name = name; - } - - /** - * @return Name of the property in the object. - */ - public String getName() { - return name; - } - - @Override - public int hashCode() { - return getName().hashCode(); - } - - @Override - public boolean equals(Object obj) { - return obj instanceof Property && ((Property) obj).getName().equals(getName()); - } - - /** - * @return Constructs a property path by appending the argument to the - * existing property separated by a dot - */ - public Property dot(String property) { - return new Property(getName() + "." + property); - } - - /** - * @return Constructs a property path by appending the argument to the - * existing property separated by a dot - */ - public Property dot(Property property) { - return new Property(getName() + "." + property.getName()); - } - - /** - * Returns a version of this property that represents an OUTER join. It is - * up to caller to ensure that the property corresponds to a relationship, - * as "outer" attributes make no sense. - */ - public Property outer() { - return isOuter() ? this : new Property(name + "+"); - } - - private boolean isOuter() { - return name.endsWith("+"); - } - - /** - * @return An expression representing null. - */ - public Expression isNull() { - return ExpressionFactory.matchExp(getName(), null); - } - - /** - * @return An expression representing a non-null value. - */ - public Expression isNotNull() { - return ExpressionFactory.matchExp(getName(), null).notExp(); - } - - /** - * @return An expression representing equality to TRUE. - */ - public Expression isTrue() { - return ExpressionFactory.matchExp(getName(), Boolean.TRUE); - } - - /** - * @return An expression representing equality to FALSE. - */ - public Expression isFalse() { - return ExpressionFactory.matchExp(getName(), Boolean.FALSE); - } - - /** - * @return An expression representing equality to a value. - */ - public Expression eq(E value) { - return ExpressionFactory.matchExp(getName(), value); - } - - /** - * @return An expression representing equality between two attributes - * (columns). - */ - public Expression eq(Property value) { - return ExpressionFactory.matchExp(getName(), new ASTObjPath(value.getName())); - } - - /** - * @return An expression representing inequality to a value. - */ - public Expression ne(E value) { - return ExpressionFactory.noMatchExp(getName(), value); - } - - /** - * @return An expression representing inequality between two attributes - * (columns). - */ - public Expression ne(Property value) { - return ExpressionFactory.noMatchExp(getName(), new ASTObjPath(value.getName())); - } - - /** - * @param pattern - * a pattern matching property value. Pattern may include "_" and - * "%" wildcard symbols to match any single character or a - * sequence of characters. To prevent "_" and "%" from being - * treated as wildcards, they need to be escaped and escape char - * passed with {@link #like(String, char)} method. - * @return An expression for a Database "LIKE" query. - */ - public Expression like(String pattern) { - return ExpressionFactory.likeExp(getName(), pattern); - } - - /** - * @param pattern - * a properly escaped pattern matching property value. Pattern - * may include "_" and "%" wildcard symbols to match any single - * character or a sequence of characters. - * @param escapeChar - * an escape character used in the pattern to escape "%" and "_". - * - * @return An expression for a Database "LIKE" query. - */ - public Expression like(String pattern, char escapeChar) { - return ExpressionFactory.likeExp(getName(), pattern, escapeChar); - } - - /** - * @return An expression for a case insensitive "LIKE" query. - */ - public Expression likeIgnoreCase(String pattern) { - return ExpressionFactory.likeIgnoreCaseExp(getName(), pattern); - } - - /** - * @return An expression for a Database "NOT LIKE" query. - */ - public Expression nlike(String value) { - return ExpressionFactory.notLikeExp(getName(), value); - } - - /** - * @return An expression for a case insensitive "NOT LIKE" query. - */ - public Expression nlikeIgnoreCase(String value) { - return ExpressionFactory.notLikeIgnoreCaseExp(getName(), value); - } - - /** - * Creates an expression for a database "LIKE" query with the value - * converted to a pattern matching anywhere in the String. - * - * @param substring - * a String to match against property value. "_" and "%" symbols - * are NOT treated as wildcards and are escaped when converted to - * a LIKE expression. - */ - public Expression contains(String substring) { - return ExpressionFactory.containsExp(getName(), substring); - } - - /** - * Creates an expression for a database "LIKE" query with the value - * converted to a pattern matching the beginning of a String. - * - * @param substring - * a String to match against property value. "_" and "%" symbols - * are NOT treated as wildcards and are escaped when converted to - * a LIKE expression. - */ - public Expression startsWith(String value) { - return ExpressionFactory.startsWithExp(getName(), value); - } - - /** - * Creates an expression for a database "LIKE" query with the value - * converted to a pattern matching the tail of a String. - * - * @param substring - * a String to match against property value. "_" and "%" symbols - * are NOT treated as wildcards and are escaped when converted to - * a LIKE expression. - */ - public Expression endsWith(String value) { - return ExpressionFactory.endsWithExp(getName(), value); - } - - /** - * Same as {@link #contains(String)}, only using case-insensitive - * comparison. - */ - public Expression containsIgnoreCase(String value) { - return ExpressionFactory.containsIgnoreCaseExp(getName(), value); - } - - /** - * Same as {@link #startsWith(String)}, only using case-insensitive - * comparison. - */ - public Expression startsWithIgnoreCase(String value) { - return ExpressionFactory.startsWithIgnoreCaseExp(getName(), value); - } - - /** - * Same as {@link #endsWith(String)}, only using case-insensitive - * comparison. - */ - public Expression endsWithIgnoreCase(String value) { - return ExpressionFactory.endsWithIgnoreCaseExp(getName(), value); - } - - /** - * @return An expression checking for objects between a lower and upper - * bound inclusive - * - * @param lower - * The lower bound. - * @param upper - * The upper bound. - */ - public Expression between(E lower, E upper) { - return ExpressionFactory.betweenExp(getName(), lower, upper); - } - - /** - * @return An expression for finding objects with values in the given set. - */ - public Expression in(E firstValue, E... moreValues) { - - int moreValuesLength = moreValues != null ? moreValues.length : 0; - - Object[] values = new Object[moreValuesLength + 1]; - values[0] = firstValue; - - if (moreValuesLength > 0) { - System.arraycopy(moreValues, 0, values, 1, moreValuesLength); - } - - return ExpressionFactory.inExp(getName(), values); - } - - /** - * @return An expression for finding objects with values not in the given - * set. - */ - public Expression nin(E firstValue, E... moreValues) { - - int moreValuesLength = moreValues != null ? moreValues.length : 0; - - Object[] values = new Object[moreValuesLength + 1]; - values[0] = firstValue; - - if (moreValuesLength > 0) { - System.arraycopy(moreValues, 0, values, 1, moreValuesLength); - } - - return ExpressionFactory.notInExp(getName(), values); - } - - /** - * @return An expression for finding objects with values in the given set. - */ - public Expression in(Collection values) { - return ExpressionFactory.inExp(getName(), values); - } - - /** - * @return An expression for finding objects with values not in the given - * set. - */ - public Expression nin(Collection values) { - return ExpressionFactory.notInExp(getName(), values); - } - - /** - * @return A greater than Expression. - */ - public Expression gt(E value) { - return ExpressionFactory.greaterExp(getName(), value); - } - - /** - * @return Represents a greater than relationship between two attributes - * (columns). - */ - public Expression gt(Property value) { - return ExpressionFactory.greaterExp(getName(), new ASTObjPath(value.getName())); - } - - /** - * @return A greater than or equal to Expression. - */ - public Expression gte(E value) { - return ExpressionFactory.greaterOrEqualExp(getName(), value); - } - - /** - * @return Represents a greater than or equal relationship between two - * attributes (columns). - */ - public Expression gte(Property value) { - return ExpressionFactory.greaterOrEqualExp(getName(), new ASTObjPath(value.getName())); - } - - /** - * @return A less than Expression. - */ - public Expression lt(E value) { - return ExpressionFactory.lessExp(getName(), value); - } - - /** - * @return Represents a less than relationship between two attributes - * (columns). - */ - public Expression lt(Property value) { - return ExpressionFactory.lessExp(getName(), new ASTObjPath(value.getName())); - } - - /** - * @return A less than or equal to Expression. - */ - public Expression lte(E value) { - return ExpressionFactory.lessOrEqualExp(getName(), value); - } - - /** - * @return Represents a less than or equal relationship between two - * attributes (columns). - */ - public Expression lte(Property value) { - return ExpressionFactory.lessOrEqualExp(getName(), new ASTObjPath(value.getName())); - } - - /** - * @return Ascending sort orderings on this property. - */ - public Ordering asc() { - return new Ordering(getName(), SortOrder.ASCENDING); - } - - /** - * @return Ascending sort orderings on this property. - */ - public List ascs() { - List result = new ArrayList(1); - result.add(asc()); - return result; - } - - /** - * @return Ascending case insensitive sort orderings on this property. - */ - public Ordering ascInsensitive() { - return new Ordering(getName(), SortOrder.ASCENDING_INSENSITIVE); - } - - /** - * @return Ascending case insensitive sort orderings on this property. - */ - public List ascInsensitives() { - List result = new ArrayList(1); - result.add(ascInsensitive()); - return result; - } - - /** - * @return Descending sort orderings on this property. - */ - public Ordering desc() { - return new Ordering(getName(), SortOrder.DESCENDING); - } - - /** - * @return Descending sort orderings on this property. - */ - public List descs() { - List result = new ArrayList(1); - result.add(desc()); - return result; - } - - /** - * @return Descending case insensitive sort orderings on this property. - */ - public Ordering descInsensitive() { - return new Ordering(getName(), SortOrder.DESCENDING_INSENSITIVE); - } - - /** - * @return Descending case insensitive sort orderings on this property. - */ - public List descInsensitives() { - List result = new ArrayList(1); - result.add(descInsensitive()); - return result; - } - - /** - * Returns a prefetch tree that follows this property path, potentially - * spanning a number of phantom nodes, and having a single leaf with "joint" - * prefetch semantics. - */ - public PrefetchTreeNode joint() { - return PrefetchTreeNode.withPath(name, PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS); - } - - /** - * Returns a prefetch tree that follows this property path, potentially - * spanning a number of phantom nodes, and having a single leaf with - * "disjoint" prefetch semantics. - */ - public PrefetchTreeNode disjoint() { - return PrefetchTreeNode.withPath(name, PrefetchTreeNode.DISJOINT_PREFETCH_SEMANTICS); - } - - /** - * Returns a prefetch tree that follows this property path, potentially - * spanning a number of phantom nodes, and having a single leaf with - * "disjoint by id" prefetch semantics. - */ - public PrefetchTreeNode disjointById() { - return PrefetchTreeNode.withPath(name, PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS); - } - - /** - * Extracts property value from an object using JavaBean-compatible - * introspection with one addition - a property can be a dot-separated - * property name path. - */ - @SuppressWarnings("unchecked") - public E getFrom(Object bean) { - return (E) PropertyUtils.getProperty(bean, getName()); - } - - /** - * Extracts property value from a collection of objects using - * JavaBean-compatible introspection with one addition - a property can be a - * dot-separated property name path. - */ - public List getFromAll(Collection beans) { - List result = new ArrayList(beans.size()); - for (Object bean : beans) { - result.add(getFrom(bean)); - } - return result; - } - - /** - * Sets a property value in 'obj' using JavaBean-compatible introspection - * with one addition - a property can be a dot-separated property name path. - */ - public void setIn(Object bean, E value) { - PropertyUtils.setProperty(bean, getName(), value); - } - - /** - * Sets a property value in a collection of objects using - * JavaBean-compatible introspection with one addition - a property can be a - * dot-separated property name path. - */ - public void setInAll(Collection beans, E value) { - for (Object bean : beans) { - setIn(bean, value); - } - } + /** + * Name of the property in the object + */ + private final String name; + + /** + * Constructs a new property with the given name. + */ + public Property(String name) { + this.name = name; + } + + /** + * @return Name of the property in the object. + */ + public String getName() { + return name; + } + + @Override + public int hashCode() { + return getName().hashCode(); + } + + @Override + public boolean equals(Object obj) { + return obj instanceof Property && ((Property) obj).getName().equals(getName()); + } + + /** + * @return Constructs a property path by appending the argument to the + * existing property separated by a dot + */ + public Property dot(String property) { + return new Property(getName() + "." + property); + } + + /** + * @return Constructs a property path by appending the argument to the + * existing property separated by a dot + */ + public Property dot(Property property) { + return new Property(getName() + "." + property.getName()); + } + + /** + * Returns a version of this property that represents an OUTER join. It is + * up to caller to ensure that the property corresponds to a relationship, + * as "outer" attributes make no sense. + */ + public Property outer() { + return isOuter() ? this : new Property(name + "+"); + } + + private boolean isOuter() { + return name.endsWith("+"); + } + + /** + * @return An expression representing null. + */ + public Expression isNull() { + return ExpressionFactory.matchExp(getName(), null); + } + + /** + * @return An expression representing a non-null value. + */ + public Expression isNotNull() { + return ExpressionFactory.matchExp(getName(), null).notExp(); + } + + /** + * @return An expression representing equality to TRUE. + */ + public Expression isTrue() { + return ExpressionFactory.matchExp(getName(), Boolean.TRUE); + } + + /** + * @return An expression representing equality to FALSE. + */ + public Expression isFalse() { + return ExpressionFactory.matchExp(getName(), Boolean.FALSE); + } + + /** + * @return An expression representing equality to a value. + */ + public Expression eq(E value) { + return ExpressionFactory.matchExp(getName(), value); + } + + /** + * @return An expression representing equality between two attributes + * (columns). + */ + public Expression eq(Property value) { + return ExpressionFactory.matchExp(getName(), new ASTObjPath(value.getName())); + } + + /** + * @return An expression representing inequality to a value. + */ + public Expression ne(E value) { + return ExpressionFactory.noMatchExp(getName(), value); + } + + /** + * @return An expression representing inequality between two attributes + * (columns). + */ + public Expression ne(Property value) { + return ExpressionFactory.noMatchExp(getName(), new ASTObjPath(value.getName())); + } + + /** + * @param pattern a pattern matching property value. Pattern may include "_" and + * "%" wildcard symbols to match any single character or a + * sequence of characters. To prevent "_" and "%" from being + * treated as wildcards, they need to be escaped and escape char + * passed with {@link #like(String, char)} method. + * @return An expression for a Database "LIKE" query. + */ + public Expression like(String pattern) { + return ExpressionFactory.likeExp(getName(), pattern); + } + + /** + * @param pattern a properly escaped pattern matching property value. Pattern + * may include "_" and "%" wildcard symbols to match any single + * character or a sequence of characters. + * @param escapeChar an escape character used in the pattern to escape "%" and "_". + * @return An expression for a Database "LIKE" query. + */ + public Expression like(String pattern, char escapeChar) { + return ExpressionFactory.likeExp(getName(), pattern, escapeChar); + } + + /** + * @return An expression for a case insensitive "LIKE" query. + */ + public Expression likeIgnoreCase(String pattern) { + return ExpressionFactory.likeIgnoreCaseExp(getName(), pattern); + } + + /** + * @return An expression for a Database "NOT LIKE" query. + */ + public Expression nlike(String value) { + return ExpressionFactory.notLikeExp(getName(), value); + } + + /** + * @return An expression for a case insensitive "NOT LIKE" query. + */ + public Expression nlikeIgnoreCase(String value) { + return ExpressionFactory.notLikeIgnoreCaseExp(getName(), value); + } + + /** + * Creates an expression for a database "LIKE" query with the value converted to a pattern matching anywhere in the + * String. + * + * @param substring a String to match against property value. "_" and "%" symbols + * are NOT treated as wildcards and are escaped when converted to + * a LIKE expression. + * @return a newly created expression. + */ + public Expression contains(String substring) { + return ExpressionFactory.containsExp(getName(), substring); + } + + /** + * Creates an expression for a database "LIKE" query with the value converted to a pattern matching the beginning of + * a String. + * + * @param value a String to match against property value. "_" and "%" symbols + * are NOT treated as wildcards and are escaped when converted to + * a LIKE expression. + * @return a newly created expression. + */ + public Expression startsWith(String value) { + return ExpressionFactory.startsWithExp(getName(), value); + } + + /** + * Creates an expression for a database "LIKE" query with the value + * converted to a pattern matching the tail of a String. + * + * @param value a String to match against property value. "_" and "%" symbols + * are NOT treated as wildcards and are escaped when converted to + * a LIKE expression. + * @return a newly created expression. + */ + public Expression endsWith(String value) { + return ExpressionFactory.endsWithExp(getName(), value); + } + + /** + * Same as {@link #contains(String)}, only using case-insensitive + * comparison. + */ + public Expression containsIgnoreCase(String value) { + return ExpressionFactory.containsIgnoreCaseExp(getName(), value); + } + + /** + * Same as {@link #startsWith(String)}, only using case-insensitive + * comparison. + */ + public Expression startsWithIgnoreCase(String value) { + return ExpressionFactory.startsWithIgnoreCaseExp(getName(), value); + } + + /** + * Same as {@link #endsWith(String)}, only using case-insensitive + * comparison. + */ + public Expression endsWithIgnoreCase(String value) { + return ExpressionFactory.endsWithIgnoreCaseExp(getName(), value); + } + + /** + * @param lower The lower bound. + * @param upper The upper bound. + * @return An expression checking for objects between a lower and upper + * bound inclusive + */ + public Expression between(E lower, E upper) { + return ExpressionFactory.betweenExp(getName(), lower, upper); + } + + /** + * @return An expression for finding objects with values in the given set. + */ + public Expression in(E firstValue, E... moreValues) { + + int moreValuesLength = moreValues != null ? moreValues.length : 0; + + Object[] values = new Object[moreValuesLength + 1]; + values[0] = firstValue; + + if (moreValuesLength > 0) { + System.arraycopy(moreValues, 0, values, 1, moreValuesLength); + } + + return ExpressionFactory.inExp(getName(), values); + } + + /** + * @return An expression for finding objects with values not in the given + * set. + */ + public Expression nin(E firstValue, E... moreValues) { + + int moreValuesLength = moreValues != null ? moreValues.length : 0; + + Object[] values = new Object[moreValuesLength + 1]; + values[0] = firstValue; + + if (moreValuesLength > 0) { + System.arraycopy(moreValues, 0, values, 1, moreValuesLength); + } + + return ExpressionFactory.notInExp(getName(), values); + } + + /** + * @return An expression for finding objects with values in the given set. + */ + public Expression in(Collection values) { + return ExpressionFactory.inExp(getName(), values); + } + + /** + * @return An expression for finding objects with values not in the given + * set. + */ + public Expression nin(Collection values) { + return ExpressionFactory.notInExp(getName(), values); + } + + /** + * @return A greater than Expression. + */ + public Expression gt(E value) { + return ExpressionFactory.greaterExp(getName(), value); + } + + /** + * @return Represents a greater than relationship between two attributes + * (columns). + */ + public Expression gt(Property value) { + return ExpressionFactory.greaterExp(getName(), new ASTObjPath(value.getName())); + } + + /** + * @return A greater than or equal to Expression. + */ + public Expression gte(E value) { + return ExpressionFactory.greaterOrEqualExp(getName(), value); + } + + /** + * @return Represents a greater than or equal relationship between two + * attributes (columns). + */ + public Expression gte(Property value) { + return ExpressionFactory.greaterOrEqualExp(getName(), new ASTObjPath(value.getName())); + } + + /** + * @return A less than Expression. + */ + public Expression lt(E value) { + return ExpressionFactory.lessExp(getName(), value); + } + + /** + * @return Represents a less than relationship between two attributes + * (columns). + */ + public Expression lt(Property value) { + return ExpressionFactory.lessExp(getName(), new ASTObjPath(value.getName())); + } + + /** + * @return A less than or equal to Expression. + */ + public Expression lte(E value) { + return ExpressionFactory.lessOrEqualExp(getName(), value); + } + + /** + * @return Represents a less than or equal relationship between two + * attributes (columns). + */ + public Expression lte(Property value) { + return ExpressionFactory.lessOrEqualExp(getName(), new ASTObjPath(value.getName())); + } + + /** + * @return Ascending sort orderings on this property. + */ + public Ordering asc() { + return new Ordering(getName(), SortOrder.ASCENDING); + } + + /** + * @return Ascending sort orderings on this property. + */ + public List ascs() { + List result = new ArrayList(1); + result.add(asc()); + return result; + } + + /** + * @return Ascending case insensitive sort orderings on this property. + */ + public Ordering ascInsensitive() { + return new Ordering(getName(), SortOrder.ASCENDING_INSENSITIVE); + } + + /** + * @return Ascending case insensitive sort orderings on this property. + */ + public List ascInsensitives() { + List result = new ArrayList(1); + result.add(ascInsensitive()); + return result; + } + + /** + * @return Descending sort orderings on this property. + */ + public Ordering desc() { + return new Ordering(getName(), SortOrder.DESCENDING); + } + + /** + * @return Descending sort orderings on this property. + */ + public List descs() { + List result = new ArrayList(1); + result.add(desc()); + return result; + } + + /** + * @return Descending case insensitive sort orderings on this property. + */ + public Ordering descInsensitive() { + return new Ordering(getName(), SortOrder.DESCENDING_INSENSITIVE); + } + + /** + * @return Descending case insensitive sort orderings on this property. + */ + public List descInsensitives() { + List result = new ArrayList(1); + result.add(descInsensitive()); + return result; + } + + /** + * Returns a prefetch tree that follows this property path, potentially + * spanning a number of phantom nodes, and having a single leaf with "joint" + * prefetch semantics. + */ + public PrefetchTreeNode joint() { + return PrefetchTreeNode.withPath(name, PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS); + } + + /** + * Returns a prefetch tree that follows this property path, potentially + * spanning a number of phantom nodes, and having a single leaf with + * "disjoint" prefetch semantics. + */ + public PrefetchTreeNode disjoint() { + return PrefetchTreeNode.withPath(name, PrefetchTreeNode.DISJOINT_PREFETCH_SEMANTICS); + } + + /** + * Returns a prefetch tree that follows this property path, potentially + * spanning a number of phantom nodes, and having a single leaf with + * "disjoint by id" prefetch semantics. + */ + public PrefetchTreeNode disjointById() { + return PrefetchTreeNode.withPath(name, PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS); + } + + /** + * Extracts property value from an object using JavaBean-compatible + * introspection with one addition - a property can be a dot-separated + * property name path. + */ + @SuppressWarnings("unchecked") + public E getFrom(Object bean) { + return (E) PropertyUtils.getProperty(bean, getName()); + } + + /** + * Extracts property value from a collection of objects using + * JavaBean-compatible introspection with one addition - a property can be a + * dot-separated property name path. + */ + public List getFromAll(Collection beans) { + List result = new ArrayList(beans.size()); + for (Object bean : beans) { + result.add(getFrom(bean)); + } + return result; + } + + /** + * Sets a property value in 'obj' using JavaBean-compatible introspection + * with one addition - a property can be a dot-separated property name path. + */ + public void setIn(Object bean, E value) { + PropertyUtils.setProperty(bean, getName(), value); + } + + /** + * Sets a property value in a collection of objects using + * JavaBean-compatible introspection with one addition - a property can be a + * dot-separated property name path. + */ + public void setInAll(Collection beans, E value) { + for (Object bean : beans) { + setIn(bean, value); + } + } } \ No newline at end of file