From 7efbffb46dc7b8efb62c6fbd18531f7ef0bb90bc Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Sat, 1 Aug 2015 09:11:04 +1200 Subject: [PATCH] No effective change - format only --- .../util/DefaultExpressionList.java | 4 +- .../ebeaninternal/util/ParamTypeHelper.java | 164 +++++++++--------- .../ebeaninternal/util/SortByClause.java | 144 +++++++-------- .../util/SortByClauseParser.java | 162 ++++++++--------- .../avaje/ebeaninternal/util/ValueUtil.java | 120 ++++++------- .../com/avaje/ebeaninternal/util/package.html | 6 +- 6 files changed, 300 insertions(+), 300 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/util/DefaultExpressionList.java b/src/main/java/com/avaje/ebeaninternal/util/DefaultExpressionList.java index edafc330b..ce1386529 100644 --- a/src/main/java/com/avaje/ebeaninternal/util/DefaultExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/util/DefaultExpressionList.java @@ -43,7 +43,7 @@ public class DefaultExpressionList implements SpiExpressionList { public DefaultExpressionList(Query query, ExpressionFactory expr, ExpressionList parentExprList) { this(query, expr, parentExprList, new ArrayList()); } - + protected DefaultExpressionList(Query query, ExpressionFactory expr, ExpressionList parentExprList, List list) { this.list = list; this.query = query; @@ -266,7 +266,7 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public ExpressionList addAll(ExpressionList exprList) { - SpiExpressionList spiList = (SpiExpressionList)exprList; + SpiExpressionList spiList = (SpiExpressionList) exprList; list.addAll(spiList.getUnderlyingList()); return this; } diff --git a/src/main/java/com/avaje/ebeaninternal/util/ParamTypeHelper.java b/src/main/java/com/avaje/ebeaninternal/util/ParamTypeHelper.java index cb25fc911..1c317a79c 100644 --- a/src/main/java/com/avaje/ebeaninternal/util/ParamTypeHelper.java +++ b/src/main/java/com/avaje/ebeaninternal/util/ParamTypeHelper.java @@ -8,97 +8,97 @@ import java.util.Set; public class ParamTypeHelper { - public enum ManyType { - LIST, SET, MAP, NONE + public enum ManyType { + LIST, SET, MAP, NONE + } + + public static class TypeInfo { + + private final ManyType manyType; + private final Class beanType; + + private TypeInfo(ManyType manyType, Class beanType) { + this.manyType = manyType; + this.beanType = beanType; } - public static class TypeInfo { - - private final ManyType manyType; - private final Class beanType; - - private TypeInfo(ManyType manyType, Class beanType) { - this.manyType = manyType; - this.beanType = beanType; - } - - public boolean isManyType() { - return !ManyType.NONE.equals(manyType); - } - - public ManyType getManyType() { - return manyType; - } - - public Class getBeanType() { - return beanType; - } - - public String toString() { - if (isManyType()) { - return manyType + " " + beanType; - } else { - return beanType.toString(); - } - } - + public boolean isManyType() { + return !ManyType.NONE.equals(manyType); } - public static TypeInfo getTypeInfo(Type genericType) { - - if (genericType instanceof ParameterizedType) { - return getParamTypeInfo((ParameterizedType) genericType); - } - - Class entityType = getBeanType(genericType); - if (entityType != null) { - return new TypeInfo(ManyType.NONE, entityType); - } - return null; + public ManyType getManyType() { + return manyType; } - /** - * For Lists Sets and Maps of beans. - */ - private static TypeInfo getParamTypeInfo(ParameterizedType paramType) { - - Type rawType = paramType.getRawType(); - - ManyType manyType = getManyType(rawType); - if (ManyType.NONE.equals(manyType)) { - return null; - } - - Type[] typeArguments = paramType.getActualTypeArguments(); - - if (typeArguments.length == 1) { - Type argType = typeArguments[0]; - Class beanType = getBeanType(argType); - if (beanType != null) { - return new TypeInfo(manyType, beanType); - } - } - - return null; + public Class getBeanType() { + return beanType; } - private static Class getBeanType(Type argType) { - if (argType instanceof Class) { - return (Class) argType; - } - return null; + public String toString() { + if (isManyType()) { + return manyType + " " + beanType; + } else { + return beanType.toString(); + } } - private static ManyType getManyType(Type rawType) { - if (List.class.equals(rawType)) { - return ManyType.LIST; - } - if (Set.class.equals(rawType)) { - return ManyType.SET; - } - if (Map.class.equals(rawType)) { - return ManyType.MAP; - } - return ManyType.NONE; + } + + public static TypeInfo getTypeInfo(Type genericType) { + + if (genericType instanceof ParameterizedType) { + return getParamTypeInfo((ParameterizedType) genericType); } + + Class entityType = getBeanType(genericType); + if (entityType != null) { + return new TypeInfo(ManyType.NONE, entityType); + } + return null; + } + + /** + * For Lists Sets and Maps of beans. + */ + private static TypeInfo getParamTypeInfo(ParameterizedType paramType) { + + Type rawType = paramType.getRawType(); + + ManyType manyType = getManyType(rawType); + if (ManyType.NONE.equals(manyType)) { + return null; + } + + Type[] typeArguments = paramType.getActualTypeArguments(); + + if (typeArguments.length == 1) { + Type argType = typeArguments[0]; + Class beanType = getBeanType(argType); + if (beanType != null) { + return new TypeInfo(manyType, beanType); + } + } + + return null; + } + + private static Class getBeanType(Type argType) { + if (argType instanceof Class) { + return (Class) argType; + } + return null; + } + + private static ManyType getManyType(Type rawType) { + if (List.class.equals(rawType)) { + return ManyType.LIST; + } + if (Set.class.equals(rawType)) { + return ManyType.SET; + } + if (Map.class.equals(rawType)) { + return ManyType.MAP; + } + return ManyType.NONE; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/util/SortByClause.java b/src/main/java/com/avaje/ebeaninternal/util/SortByClause.java index 4c06894e1..c0b2806ac 100644 --- a/src/main/java/com/avaje/ebeaninternal/util/SortByClause.java +++ b/src/main/java/com/avaje/ebeaninternal/util/SortByClause.java @@ -12,84 +12,84 @@ import java.util.List; */ public class SortByClause { - public static final String NULLSHIGH = "nullshigh"; - - public static final String NULLSLOW = "nullslow"; + public static final String NULLSHIGH = "nullshigh"; - /** - * The ascending keyword. - */ - public static final String ASC = "asc"; - - /** - * The descending keyword. - */ - public static final String DESC = "desc"; - - - private final List properties = new ArrayList(); - - /** - * Return the number of properties in the clause. - */ - public int size() { - return properties.size(); - } + public static final String NULLSLOW = "nullslow"; - /** - * Return the properties of the sort by clause. - */ - public List getProperties() { - return properties; - } + /** + * The ascending keyword. + */ + public static final String ASC = "asc"; - /** - * Add a property to the sort by clause. - */ - public void add(Property p){ - properties.add(p); - } + /** + * The descending keyword. + */ + public static final String DESC = "desc"; - /** - * A property of the SortByClause. - */ - public static class Property implements Serializable { - - private static final long serialVersionUID = 7588760362420690963L; - private final String name; - - private final boolean ascending; - - private final Boolean nullsHigh; + private final List properties = new ArrayList(); - public Property(String name, boolean ascending, Boolean nullsHigh) { - this.name = name; - this.ascending = ascending; - this.nullsHigh = nullsHigh; - } - - public String toString() { - return name+" asc:"+ascending; - } - - /** - * Return the property name. - */ - public String getName() { - return name; - } + /** + * Return the number of properties in the clause. + */ + public int size() { + return properties.size(); + } - /** - * Return true if the order should be ascending. - */ - public boolean isAscending() { - return ascending; - } + /** + * Return the properties of the sort by clause. + */ + public List getProperties() { + return properties; + } - public Boolean getNullsHigh() { - return nullsHigh; - } - - } + /** + * Add a property to the sort by clause. + */ + public void add(Property p) { + properties.add(p); + } + + /** + * A property of the SortByClause. + */ + public static class Property implements Serializable { + + private static final long serialVersionUID = 7588760362420690963L; + + private final String name; + + private final boolean ascending; + + private final Boolean nullsHigh; + + public Property(String name, boolean ascending, Boolean nullsHigh) { + this.name = name; + this.ascending = ascending; + this.nullsHigh = nullsHigh; + } + + public String toString() { + return name + " asc:" + ascending; + } + + /** + * Return the property name. + */ + public String getName() { + return name; + } + + /** + * Return true if the order should be ascending. + */ + public boolean isAscending() { + return ascending; + } + + public Boolean getNullsHigh() { + return nullsHigh; + } + + } } diff --git a/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java b/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java index 79341017e..853729b14 100644 --- a/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java +++ b/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java @@ -3,88 +3,88 @@ package com.avaje.ebeaninternal.util; import com.avaje.ebeaninternal.util.SortByClause.Property; public final class SortByClauseParser { - - private final String rawSortBy; - - public static SortByClause parse(String rawSortByClause){ - return new SortByClauseParser(rawSortByClause).parse(); - } - - private SortByClauseParser(String rawSortByClause) { - this.rawSortBy = rawSortByClause.trim(); - } - - private SortByClause parse(){ - - SortByClause sortBy = new SortByClause(); - - String[] sections = rawSortBy.split(","); - for (int i = 0; i < sections.length; i++) { - Property p = parseSection(sections[i].trim()); - if (p == null){ - break; - } else { - sortBy.add(p); - } - - } - - return sortBy; - } - - private Property parseSection(String section){ - if (section.length() == 0){ - return null; - } - String[] words = section.split(" "); - if (words.length < 1 || words.length > 3){ - throw new RuntimeException("Expecting 1 to 3 words in ["+section+"] but got ["+words.length+"]"); - } - - Boolean nullsHigh = null; - boolean ascending = true; - String propName = words[0]; - if (words.length > 1){ - if (words[1].startsWith("nulls")){ - nullsHigh = isNullsHigh(words[1]); - - } else { - ascending = isAscending(words[1]); - } - } - if (words.length > 2){ - if (words[2].startsWith("nulls")){ - nullsHigh = isNullsHigh(words[2]); - - } else { - ascending = isAscending(words[2]); - } - } - - return new Property(propName, ascending, nullsHigh); - } - private Boolean isNullsHigh(String word){ - if (SortByClause.NULLSHIGH.equalsIgnoreCase(word)){ - return Boolean.TRUE; - } - if (SortByClause.NULLSLOW.equalsIgnoreCase(word)){ - return Boolean.FALSE; - } - String m = "Expecting nullsHigh or nullsLow but got ["+word+"] in ["+rawSortBy+"]"; - throw new RuntimeException(m); - } + private final String rawSortBy; - - private boolean isAscending(String word){ - if (SortByClause.ASC.equalsIgnoreCase(word)){ - return true; - } - if (SortByClause.DESC.equalsIgnoreCase(word)){ - return false; - } - String m = "Expection ASC or DESC but got ["+word+"] in ["+rawSortBy+"]"; - throw new RuntimeException(m); - } + public static SortByClause parse(String rawSortByClause) { + return new SortByClauseParser(rawSortByClause).parse(); + } + + private SortByClauseParser(String rawSortByClause) { + this.rawSortBy = rawSortByClause.trim(); + } + + private SortByClause parse() { + + SortByClause sortBy = new SortByClause(); + + String[] sections = rawSortBy.split(","); + for (int i = 0; i < sections.length; i++) { + Property p = parseSection(sections[i].trim()); + if (p == null) { + break; + } else { + sortBy.add(p); + } + + } + + return sortBy; + } + + private Property parseSection(String section) { + if (section.length() == 0) { + return null; + } + String[] words = section.split(" "); + if (words.length < 1 || words.length > 3) { + throw new RuntimeException("Expecting 1 to 3 words in [" + section + "] but got [" + words.length + "]"); + } + + Boolean nullsHigh = null; + boolean ascending = true; + String propName = words[0]; + if (words.length > 1) { + if (words[1].startsWith("nulls")) { + nullsHigh = isNullsHigh(words[1]); + + } else { + ascending = isAscending(words[1]); + } + } + if (words.length > 2) { + if (words[2].startsWith("nulls")) { + nullsHigh = isNullsHigh(words[2]); + + } else { + ascending = isAscending(words[2]); + } + } + + return new Property(propName, ascending, nullsHigh); + } + + private Boolean isNullsHigh(String word) { + if (SortByClause.NULLSHIGH.equalsIgnoreCase(word)) { + return Boolean.TRUE; + } + if (SortByClause.NULLSLOW.equalsIgnoreCase(word)) { + return Boolean.FALSE; + } + String m = "Expecting nullsHigh or nullsLow but got [" + word + "] in [" + rawSortBy + "]"; + throw new RuntimeException(m); + } + + + private boolean isAscending(String word) { + if (SortByClause.ASC.equalsIgnoreCase(word)) { + return true; + } + if (SortByClause.DESC.equalsIgnoreCase(word)) { + return false; + } + String m = "Expection ASC or DESC but got [" + word + "] in [" + rawSortBy + "]"; + throw new RuntimeException(m); + } } diff --git a/src/main/java/com/avaje/ebeaninternal/util/ValueUtil.java b/src/main/java/com/avaje/ebeaninternal/util/ValueUtil.java index dd9b11a55..bfbee88d7 100644 --- a/src/main/java/com/avaje/ebeaninternal/util/ValueUtil.java +++ b/src/main/java/com/avaje/ebeaninternal/util/ValueUtil.java @@ -5,66 +5,66 @@ import java.net.URL; public class ValueUtil { - /** - * Helper method to check if two objects are equal. - */ - @SuppressWarnings("unchecked") - public static boolean areEqual(Object obj1, Object obj2) { - if (obj1 == null) { - return (obj2 == null); - } - if (obj2 == null) { - return false; - } - if (obj1 == obj2) { - return true; - } - if (obj1 instanceof BigDecimal) { - // Use comparable for BigDecimal as equals - // uses scale in comparison... - if (obj2 instanceof BigDecimal) { - Comparable com1 = (Comparable) obj1; - return (com1.compareTo(obj2) == 0); + /** + * Helper method to check if two objects are equal. + */ + @SuppressWarnings("unchecked") + public static boolean areEqual(Object obj1, Object obj2) { + if (obj1 == null) { + return (obj2 == null); + } + if (obj2 == null) { + return false; + } + if (obj1 == obj2) { + return true; + } + if (obj1 instanceof BigDecimal) { + // Use comparable for BigDecimal as equals + // uses scale in comparison... + if (obj2 instanceof BigDecimal) { + Comparable com1 = (Comparable) obj1; + return (com1.compareTo(obj2) == 0); - } else { - return false; - } + } else { + return false; + } - } - if (obj1 instanceof URL){ - // use the string format to determine if dirty - return obj1.toString().equals(obj2.toString()); - } - if (obj1 instanceof byte[] && obj2 instanceof byte[]){ - return areEqualBytes((byte[])obj1, (byte[])obj2); - } - if (obj1 instanceof char[] && obj2 instanceof char[]){ - return areEqualChars((char[])obj1, (char[])obj2); - } - return obj1.equals(obj2); - } - - private static boolean areEqualBytes(byte[] b1, byte[] b2) { - if (b1.length != b2.length){ - return false; - } - for (int i = 0; i < b1.length; i++) { - if (b1[i] != b2[i]){ - return false; - } - } - return true; - } - - private static boolean areEqualChars(char[] b1, char[] b2) { - if (b1.length != b2.length){ - return false; - } - for (int i = 0; i < b1.length; i++) { - if (b1[i] != b2[i]){ - return false; - } - } - return true; - } + } + if (obj1 instanceof URL) { + // use the string format to determine if dirty + return obj1.toString().equals(obj2.toString()); + } + if (obj1 instanceof byte[] && obj2 instanceof byte[]) { + return areEqualBytes((byte[]) obj1, (byte[]) obj2); + } + if (obj1 instanceof char[] && obj2 instanceof char[]) { + return areEqualChars((char[]) obj1, (char[]) obj2); + } + return obj1.equals(obj2); + } + + private static boolean areEqualBytes(byte[] b1, byte[] b2) { + if (b1.length != b2.length) { + return false; + } + for (int i = 0; i < b1.length; i++) { + if (b1[i] != b2[i]) { + return false; + } + } + return true; + } + + private static boolean areEqualChars(char[] b1, char[] b2) { + if (b1.length != b2.length) { + return false; + } + for (int i = 0; i < b1.length; i++) { + if (b1[i] != b2[i]) { + return false; + } + } + return true; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/util/package.html b/src/main/java/com/avaje/ebeaninternal/util/package.html index eb944c53a..1b14ac5e6 100644 --- a/src/main/java/com/avaje/ebeaninternal/util/package.html +++ b/src/main/java/com/avaje/ebeaninternal/util/package.html @@ -1,13 +1,13 @@ - - Utility objects + + Utility objects Utility objects

-For client and server side implmentation. + For client and server side implmentation.