No effective change - code tidy, remove unused

This commit is contained in:
rbygrave
2015-05-13 22:30:40 +12:00
parent 8cb0b13ccb
commit 8c12fc762c
2 changed files with 22 additions and 107 deletions
@@ -120,7 +120,6 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
* Map of BeanProperty Linked so as to preserve order.
*/
private final LinkedHashMap<String, BeanProperty> propMap;
private final LinkedHashMap<String, BeanProperty> propMapByDbColumn;
/**
* The type of bean this describes.
@@ -215,7 +214,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
private final BeanPropertyAssocOne<?>[] propertiesOneImportedSave;
private final BeanPropertyAssocOne<?>[] propertiesOneImportedDelete;
private final BeanPropertyAssocOne<?>[] propertiesOneExported;
//private final BeanPropertyAssocOne<?>[] propertiesOneExported;
private final BeanPropertyAssocOne<?>[] propertiesOneExportedSave;
private final BeanPropertyAssocOne<?>[] propertiesOneExportedDelete;
@@ -346,7 +345,6 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
this.idProperty = listHelper.getId();
this.versionProperty = listHelper.getVersionProperty();
this.propMap = listHelper.getPropertyMap();
this.propMapByDbColumn = getReverseMap(propMap);
this.propertiesTransient = listHelper.getTransients();
this.propertiesNonTransient = listHelper.getNonTransients();
this.propertiesBaseScalar = listHelper.getBaseScalar();
@@ -356,7 +354,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
this.propertiesMutable = listHelper.getMutable();
this.unidirectional = listHelper.getUnidirectional();
this.propertiesOne = listHelper.getOnes();
this.propertiesOneExported = listHelper.getOneExported();
//this.propertiesOneExported = listHelper.getOneExported();
this.propertiesOneExportedSave = listHelper.getOneExportedSave();
this.propertiesOneExportedDelete = listHelper.getOneExportedDelete();
this.propertiesOneImported = listHelper.getOneImported();
@@ -639,10 +637,6 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
return (queryUseCache != null) ? queryUseCache.booleanValue() : isBeanCaching();
}
public T cacheNaturalKey(SpiQuery<T> query, SpiTransaction t) {
return cacheHelp.naturalKeyLookup(query, t);
}
/**
* Return the cache options.
*/
@@ -708,13 +702,6 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
cacheHelp.setUseCache(useCache);
}
/**
* Return true if there is currently query caching for this type of bean.
*/
public boolean isQueryCaching() {
return cacheHelp.isQueryCaching();
}
/**
* Return true if there is currently bean caching for this type of bean.
*/
@@ -776,20 +763,6 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
cacheHelp.manyPropClear(propertyName);
}
/**
* Return the CachedManyIds for a given bean and property. Returns null if not in the cache.
*/
public CachedManyIds cacheManyPropGet(Object parentId, String propertyName) {
return cacheHelp.manyPropGet(parentId, propertyName);
}
/**
* Clear the bean cache.
*/
public void cacheBeanClear() {
cacheHelp.beanCacheClear();
}
public void cacheBeanPut(T bean) {
cacheBeanPutData((EntityBean)bean);
}
@@ -1552,26 +1525,6 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
return queryAdapter;
}
/**
* De-register the BeanPersistListener.
*/
@SuppressWarnings("unchecked")
public void deregister(BeanPersistListener listener) {
// volatile read...
BeanPersistListener currListener = persistListener;
if (currListener == null) {
// nothing to deregister
} else {
BeanPersistListener deregListener = listener;
if (currListener instanceof ChainedBeanPersistListener) {
// remove it from the existing chain
persistListener = ((ChainedBeanPersistListener) currListener).deregister(deregListener);
} else if (currListener.equals(deregListener)) {
persistListener = null;
}
}
}
/**
* De-register the BeanPersistController.
*/
@@ -1699,13 +1652,6 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
return selectLastInsertedId;
}
/**
* Return the IdGenerator.
*/
public IdGenerator getIdGenerator() {
return idGenerator;
}
/**
* Return the TableJoins.
* <p>
@@ -1798,14 +1744,13 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
public void checkMutableProperties(EntityBeanIntercept ebi) {
for (int i = 0; i < propertiesMutable.length; i++) {
BeanProperty beanProperty = propertiesMutable[i];
if (ebi.isDirtyProperty(beanProperty.getPropertyIndex())) {
// already marked as dirty
} else if (ebi.isLoadedProperty(beanProperty.getPropertyIndex())) {
int propertyIndex = beanProperty.getPropertyIndex();
if (!ebi.isDirtyProperty(propertyIndex) && ebi.isLoadedProperty(propertyIndex)) {
Object value = beanProperty.getValue(ebi.getOwner());
if (value == null || beanProperty.isDirtyValue(value)) {
// mutable scalar value which is considered dirty so mark
// it as such so that it is included in an update
ebi.markPropertyAsChanged(beanProperty.getPropertyIndex());
ebi.markPropertyAsChanged(propertyIndex);
}
}
}
@@ -104,8 +104,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
private List<BeanDescriptor<?>> immutableDescriptorList;
private final Set<Integer> descriptorUniqueIds = new HashSet<Integer>();
private final DbIdentity dbIdentity;
private final DataSource dataSource;
@@ -286,9 +284,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
for (BeanDescriptor<?> desc : descMap.values()) {
String baseTable = desc.getBaseTable();
if (baseTable == null) {
} else {
if (baseTable != null) {
baseTable = baseTable.toLowerCase();
List<BeanDescriptor<?>> list = tableToDescMap.get(baseTable);
@@ -363,8 +359,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
BeanDescriptor<?> idBeanDescriptor = embId.getIdBeanDescriptor();
Class<?> idType = idBeanDescriptor.getBeanType();
try {
idType.getDeclaredMethod("hashCode", new Class[] {});
idType.getDeclaredMethod("equals", new Class[] { Object.class });
idType.getDeclaredMethod("hashCode");
idType.getDeclaredMethod("equals", Object.class);
} catch (NoSuchMethodException e) {
checkMissingHashCodeOrEquals(e, idType, d.getBeanType());
}
@@ -385,18 +381,10 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
return immutableDescriptorList;
}
public Map<Class<?>, BeanTable> getBeanTables() {
return beanTableMap;
}
public BeanTable getBeanTable(Class<?> type) {
return beanTableMap.get(type);
}
public Map<String, BeanDescriptor<?>> getBeanDescriptors() {
return descMap;
}
@SuppressWarnings("unchecked")
public <T> BeanManager<T> getBeanManager(Class<T> entityType) {
@@ -539,9 +527,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
BeanDescriptor<?> desc = getBeanDescriptor(deployDesc.getBeanType());
for (DRawSqlMeta rawSqlMeta : deployDesc.getRawSqlMeta()) {
if (rawSqlMeta.getQuery() == null) {
} else {
if (rawSqlMeta.getQuery() != null) {
DeployNamedQuery nq = new DRawSqlSelectBuilder(namingConvention, desc, rawSqlMeta).parse();
desc.addNamedQuery(nq);
}
@@ -603,15 +589,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
private Integer getUniqueHash(DeployBeanDescriptor<?> deployBeanDescriptor) {
int hashCode = deployBeanDescriptor.getFullName().hashCode();
for (int i = 0; i < 100000; i++) {
Integer key = Integer.valueOf(hashCode + i);
if (!descriptorUniqueIds.contains(key)) {
return key;
}
}
throw new RuntimeException("Failed to generate a unique hash for " + deployBeanDescriptor.getFullName());
return deployBeanDescriptor.getFullName().hashCode();
}
private void secondaryPropsJoins(DeployBeanInfo<?> info) {
@@ -646,7 +624,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
for (DeployBeanPropertyAssocOne<?> oneProp : info.getDescriptor().propertiesAssocOne()) {
if (!oneProp.isTransient()) {
if (oneProp.getMappedBy() != null) {
checkMappedByOneToOne(info, oneProp);
checkMappedByOneToOne(oneProp);
}
}
}
@@ -654,7 +632,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
for (DeployBeanPropertyAssocMany<?> manyProp : info.getDescriptor().propertiesAssocMany()) {
if (!manyProp.isTransient()) {
if (manyProp.isManyToMany()) {
checkMappedByManyToMany(info, manyProp);
checkMappedByManyToMany(manyProp);
} else {
checkMappedByOneToMany(info, manyProp);
}
@@ -724,7 +702,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
// search for this in the possible matches
for (String possibleMappedBy : matchSet) {
String possibleLower = possibleMappedBy.toLowerCase();
if (possibleLower.indexOf(searchName) > -1) {
if (possibleLower.contains(searchName)) {
// we have a match..
prop.setMappedBy(possibleMappedBy);
@@ -809,7 +787,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
}
private void checkMappedByOneToOne(DeployBeanInfo<?> info, DeployBeanPropertyAssocOne<?> prop) {
private void checkMappedByOneToOne(DeployBeanPropertyAssocOne<?> prop) {
// check that the mappedBy property is valid and read
// its associated join information if it is available
@@ -901,7 +879,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
/**
* For mappedBy copy the joins from the other side.
*/
private void checkMappedByManyToMany(DeployBeanInfo<?> info, DeployBeanPropertyAssocMany<?> prop) {
private void checkMappedByManyToMany(DeployBeanPropertyAssocMany<?> prop) {
// get the bean descriptor that holds the mappedBy property
String mappedBy = prop.getMappedBy();
@@ -1029,10 +1007,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
private <T> IdType setIdGeneration(DeployBeanDescriptor<T> desc) {
if (desc.propertiesId().size() == 0) {
// bean doen't have an Id property
if (!desc.isBaseTableType() || desc.getBeanFinder() != null) {
// using BeanFinder so perhaps valid without an id
} else {
// bean doesn't have an Id property
if (desc.isBaseTableType() && desc.getBeanFinder() == null) {
// expecting an id property
logger.warn(Message.msg("deploy.nouid", desc.getFullName()));
}
@@ -1120,7 +1096,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
private void setScalarType(DeployBeanDescriptor<?> deployDesc) {
for (DeployBeanProperty prop : deployDesc.propertiesAll()) {
if (prop instanceof DeployBeanPropertyAssoc<?> == false) {
if (!(prop instanceof DeployBeanPropertyAssoc<?>)) {
deployUtil.setScalarType(prop);
}
}
@@ -1228,7 +1204,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
for (Dnode namedQueryXml : namedQueries) {
String name = (String) namedQueryXml.getAttribute("name");
String name = namedQueryXml.getAttribute("name");
Dnode query = namedQueryXml.find("query");
if (query == null) {
logger.warn("orm.xml " + deployDesc.getFullName() + " named-query missing query element?");
@@ -1282,7 +1258,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
}
} else {
int propertyIndex = pos.intValue();
final int propertyIndex = pos;
prop.setPropertyIndex(propertyIndex);
prop.setGetter(beanReflect.getGetter(propName, propertyIndex));
prop.setSetter(beanReflect.getSetter(propName, propertyIndex));
@@ -1294,16 +1270,10 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
* Return true if this is a persistent field (not transient or static).
*/
private boolean isPersistentField(DeployBeanProperty prop) {
Field field = prop.getField();
int modifiers = field.getModifiers();
if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers)) {
return false;
}
if (field.isAnnotationPresent(Transient.class)) {
return false;
}
return true;
return !(Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers)) && !field.isAnnotationPresent(Transient.class);
}
/**