Refactor - tidy up in com.avaje.ebeaninternal util, no effective change

This commit is contained in:
Rob Bygrave
2016-11-05 23:01:03 +13:00
parent e83556cada
commit e5356e7118
4 changed files with 8 additions and 69 deletions
@@ -1,43 +0,0 @@
package com.avaje.ebeaninternal.server.util;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import com.avaje.ebean.bean.BeanCollection;
import com.avaje.ebean.common.BeanList;
import com.avaje.ebean.common.BeanMap;
import com.avaje.ebean.common.BeanSet;
import com.avaje.ebeaninternal.api.SpiQuery;
/**
* Creates the BeanCollections.
* <p>
* Creates the BeanSet BeanMap and BeanList objects.
* </p>
*/
public class BeanCollectionFactory {
private static final int defaultListInitialCapacity = 20;
private static final int defaultSetInitialCapacity = 32;
private static final int defaultMapInitialCapacity = 32;
/**
* Create a BeanCollection for the given parameters.
*/
public static BeanCollection<?> create(SpiQuery.Type manyType) {
switch (manyType) {
case MAP:
return new BeanMap<>(new LinkedHashMap<>(defaultMapInitialCapacity));
case LIST:
return new BeanList<>(new ArrayList<>(defaultListInitialCapacity));
case SET:
return new BeanSet<>(new LinkedHashSet<>(defaultSetInitialCapacity));
default:
throw new RuntimeException("Invalid Arg " + manyType);
}
}
}
@@ -18,8 +18,8 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
*/
public class BindParamsParser {
public static final String ENCRYPTKEY_PREFIX = "encryptkey_";
public static final String ENCRYPTKEY_GAP = "___";
private static final String ENCRYPTKEY_PREFIX = "encryptkey_";
private static final String ENCRYPTKEY_GAP = "___";
private static final int ENCRYPTKEY_PREFIX_LEN = ENCRYPTKEY_PREFIX.length();
private static final int ENCRYPTKEY_GAP_LEN = ENCRYPTKEY_GAP.length();
@@ -47,30 +47,12 @@ public class BindParamsParser {
return new BindParamsParser(params, sql, beanDescriptor).parseSql();
}
public static OrderedList parseNamedParams(BindParams params, String sql) {
return new BindParamsParser(params, sql, null).parseSqlNamedParams();
}
private BindParamsParser(BindParams params, String sql, BeanDescriptor<?> beanDescriptor) {
this.params = params;
this.sql = sql;
this.beanDescriptor = beanDescriptor;
}
/**
* Used for parsing having clauses with named parameters.
* <p>
* The issue here is that BindParams contains named parameters for
* both where and having clauses. BindParams.positionedParameters is
* used for the where and the OrderedList for the having.
* </p>
*/
private OrderedList parseSqlNamedParams() {
OrderedList orderedList = new OrderedList();
parseNamedParams(orderedList);
return orderedList;
}
/**
* Parse the sql changed named parameters to positioned parameters if required.
* <p>
@@ -12,22 +12,22 @@ import java.util.List;
*/
public class SortByClause {
public static final String NULLSHIGH = "nullshigh";
static final String NULLSHIGH = "nullshigh";
public static final String NULLSLOW = "nullslow";
static final String NULLSLOW = "nullslow";
/**
* The ascending keyword.
*/
public static final String ASC = "asc";
static final String ASC = "asc";
/**
* The descending keyword.
*/
public static final String DESC = "desc";
static final String DESC = "desc";
private final List<Property> properties = new ArrayList<Property>();
private final List<Property> properties = new ArrayList<>();
/**
* Return the number of properties in the clause.
@@ -83,7 +83,7 @@ public final class SortByClauseParser {
if (SortByClause.DESC.equalsIgnoreCase(word)) {
return false;
}
String m = "Expection ASC or DESC but got [" + word + "] in [" + rawSortBy + "]";
String m = "Expect ASC or DESC but got [" + word + "] in [" + rawSortBy + "]";
throw new RuntimeException(m);
}