No effective change - format only

This commit is contained in:
Robin Bygrave
2015-08-01 09:11:04 +12:00
parent 559383a810
commit 7efbffb46d
6 changed files with 300 additions and 300 deletions
@@ -43,7 +43,7 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
public DefaultExpressionList(Query<T> query, ExpressionFactory expr, ExpressionList<T> parentExprList) {
this(query, expr, parentExprList, new ArrayList<SpiExpression>());
}
protected DefaultExpressionList(Query<T> query, ExpressionFactory expr, ExpressionList<T> parentExprList, List<SpiExpression> list) {
this.list = list;
this.query = query;
@@ -266,7 +266,7 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
@Override
public ExpressionList<T> addAll(ExpressionList<T> exprList) {
SpiExpressionList<T> spiList = (SpiExpressionList<T>)exprList;
SpiExpressionList<T> spiList = (SpiExpressionList<T>) exprList;
list.addAll(spiList.getUnderlyingList());
return this;
}
@@ -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;
}
}
@@ -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<Property> properties = new ArrayList<Property>();
/**
* 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<Property> 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<Property> properties = new ArrayList<Property>();
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<Property> 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;
}
}
}
@@ -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);
}
}
@@ -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<Object> com1 = (Comparable<Object>) 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<Object> com1 = (Comparable<Object>) 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;
}
}
@@ -1,13 +1,13 @@
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Utility objects</TITLE>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Utility objects</TITLE>
</HEAD>
<Body BGCOLOR="#ffffff">
Utility objects
<p>
For client and server side implmentation.
For client and server side implmentation.
</p>
</Body>