mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor - tidy up in com.avaje.ebeaninternal util, no effective change
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user