No effective change - code cleanup - removed unused BeanCollectionParams

This commit is contained in:
Robin Bygrave
2015-08-01 19:30:06 +12:00
parent 430b3cff96
commit 21b33bb9cd
4 changed files with 22 additions and 87 deletions
@@ -62,7 +62,7 @@ public class AnnotationAssocOnes extends AnnotationParser {
}
Embedded embedded = get(prop, Embedded.class);
if (embedded != null) {
readEmbedded(embedded, prop);
readEmbedded(prop);
}
EmbeddedId emId = get(prop, EmbeddedId.class);
if (emId != null) {
@@ -191,7 +191,7 @@ public class AnnotationAssocOnes extends AnnotationParser {
prop.setBeanTable(assoc);
}
private void readEmbedded(Embedded propAnn, DeployBeanPropertyAssocOne<?> prop) {
private void readEmbedded(DeployBeanPropertyAssocOne<?> prop) {
prop.setEmbedded(true);
prop.setDbInsertable(true);
@@ -6,7 +6,6 @@ import com.avaje.ebeaninternal.api.SpiQuery;
import com.avaje.ebeaninternal.server.core.RelationalQueryRequest;
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
import com.avaje.ebeaninternal.server.util.BeanCollectionFactory;
import com.avaje.ebeaninternal.server.util.BeanCollectionParams;
import java.util.Collection;
import java.util.Map;
@@ -24,11 +23,6 @@ public final class BeanCollectionWrapper {
*/
private final boolean isMap;
/**
* The type.
*/
private final SpiQuery.Type queryType;
/**
* A property name used as key for a Map.
*/
@@ -62,7 +56,7 @@ public final class BeanCollectionWrapper {
public BeanCollectionWrapper(RelationalQueryRequest request) {
this.desc = null;
this.queryType = request.getQueryType();
SpiQuery.Type queryType = request.getQueryType();
this.mapKey = request.getQuery().getMapKey();
this.isMap = SpiQuery.Type.MAP.equals(queryType);
@@ -92,8 +86,7 @@ public final class BeanCollectionWrapper {
* Create a BeanCollection of the correct type.
*/
private BeanCollection<?> createBeanCollection(SpiQuery.Type manyType) {
BeanCollectionParams p = new BeanCollectionParams(manyType);
return BeanCollectionFactory.create(p);
return BeanCollectionFactory.create(manyType);
}
/**
@@ -18,58 +18,26 @@ import com.avaje.ebeaninternal.api.SpiQuery;
*/
public class BeanCollectionFactory {
private static class BeanCollectionFactoryHolder {
private static final BeanCollectionFactory me = new BeanCollectionFactory();
}
private static final int defaultListInitialCapacity = 20;
private static final int defaultSetInitialCapacity = 32;
private static final int defaultMapInitialCapacity = 32;
private static final int defaultListInitialCapacity = 20;
private static final int defaultSetInitialCapacity = 32;
private static final int defaultMapInitialCapacity = 32;
private BeanCollectionFactory() {
/**
* Create a BeanCollection for the given parameters.
*/
public static BeanCollection<?> create(SpiQuery.Type manyType) {
}
/**
* Create a BeanCollection for the given parameters.
*/
public static BeanCollection<?> create(BeanCollectionParams params) {
return BeanCollectionFactoryHolder.me.createMany(params);
}
private BeanCollection<?> createMany(BeanCollectionParams params) {
SpiQuery.Type manyType = params.getManyType();
switch (manyType) {
case MAP:
return createMap(params);
case LIST:
return createList(params);
case SET:
return createSet(params);
default:
throw new RuntimeException("Invalid Arg " + manyType);
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private BeanMap createMap(BeanCollectionParams params) {
return new BeanMap(new LinkedHashMap(defaultMapInitialCapacity));
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private BeanSet createSet(BeanCollectionParams params) {
return new BeanSet(new LinkedHashSet(defaultSetInitialCapacity));
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private BeanList createList(BeanCollectionParams params) {
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);
}
}
}
@@ -1,26 +0,0 @@
package com.avaje.ebeaninternal.server.util;
import com.avaje.ebeaninternal.api.SpiQuery;
/**
* Parameters used to create the specific Map Set or List object.
*/
public class BeanCollectionParams {
private final SpiQuery.Type manyType;
/**
* Construct without a specific capacity.
*/
public BeanCollectionParams(SpiQuery.Type manyType) {
this.manyType = manyType;
}
/**
* Return the type Map Set or List.
*/
public SpiQuery.Type getManyType() {
return manyType;
}
}