diff --git a/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java b/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java index 1c4e0e623..43a96a191 100644 --- a/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java +++ b/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java @@ -48,9 +48,9 @@ final class DRawSqlColumnsParser { String[] split = colInfo.split("\\s(?=[^\\)]*(?:\\(|$))"); if (split.length > 1) { ArrayList tmp = new ArrayList<>(split.length); - for (int i = 0; i < split.length; i++) { - if (!split[i].trim().isEmpty()) { - tmp.add(split[i].trim()); + for (String aSplit : split) { + if (!aSplit.trim().isEmpty()) { + tmp.add(aSplit.trim()); } } split = tmp.toArray(new String[tmp.size()]); @@ -66,8 +66,8 @@ final class DRawSqlColumnsParser { if (split.length == 2) { return new ColumnMapping.Column(indexPos++, split[0], split[1]); } - // Ok, we now expect/require the AS keyword and it should be the - // second to last word in the colInfo content + // Ok, we now expect/require the AS keyword and it should be the + // second to last word in the colInfo content if (!split[split.length - 2].equalsIgnoreCase("as")) { throw new PersistenceException("Expecting AS keyword as second to last word when parsing column " + colInfo); } diff --git a/src/main/java/com/avaje/ebean/OrderBy.java b/src/main/java/com/avaje/ebean/OrderBy.java index 5ccd42bf8..b342fb23a 100644 --- a/src/main/java/com/avaje/ebean/OrderBy.java +++ b/src/main/java/com/avaje/ebean/OrderBy.java @@ -30,7 +30,7 @@ public final class OrderBy implements Serializable { public OrderBy() { this.list = new ArrayList<>(3); } - + private OrderBy(List list) { this.list = list; } @@ -60,8 +60,8 @@ public final class OrderBy implements Serializable { * Reverse the ascending/descending order on all the properties. */ public void reverse() { - for (int i = 0; i < list.size(); i++) { - list.get(i).reverse(); + for (Property aList : list) { + aList.reverse(); } } @@ -88,8 +88,8 @@ public final class OrderBy implements Serializable { */ public boolean containsProperty(String propertyName) { - for (int i = 0; i < list.size(); i++) { - if (propertyName.equals(list.get(i).getProperty())) { + for (Property aList : list) { + if (propertyName.equals(aList.getProperty())) { return true; } } @@ -101,12 +101,12 @@ public final class OrderBy implements Serializable { */ public OrderBy copyWithTrim(String path) { List newList = new ArrayList<>(list.size()); - for (int i = 0; i < list.size(); i++) { - newList.add(list.get(i).copyWithTrim(path)); + for (Property aList : list) { + newList.add(aList.copyWithTrim(path)); } return new OrderBy<>(newList); } - + /** * Return the properties for this OrderBy. */ @@ -142,8 +142,8 @@ public final class OrderBy implements Serializable { public OrderBy copy() { OrderBy copy = new OrderBy<>(); - for (int i = 0; i < list.size(); i++) { - copy.add(list.get(i).copy()); + for (Property aList : list) { + copy.add(aList.copy()); } return copy; } @@ -192,7 +192,7 @@ public final class OrderBy implements Serializable { if (!(obj instanceof OrderBy)) { return false; } - + OrderBy e = (OrderBy) obj; return e.list.equals(list); } @@ -356,8 +356,8 @@ public final class OrderBy implements Serializable { } String[] chunks = orderByClause.split(","); - for (int i = 0; i < chunks.length; i++) { - String[] pairs = chunks[i].split(" "); + for (String chunk : chunks) { + String[] pairs = chunk.split(" "); Property p = parseProperty(pairs); if (p != null) { list.add(p); @@ -371,9 +371,9 @@ public final class OrderBy implements Serializable { } ArrayList wordList = new ArrayList<>(pairs.length); - for (int i = 0; i < pairs.length; i++) { - if (!isEmptyString(pairs[i])) { - wordList.add(pairs[i]); + for (String pair : pairs) { + if (!isEmptyString(pair)) { + wordList.add(pair); } } if (wordList.isEmpty()) { diff --git a/src/main/java/com/avaje/ebean/RawSql.java b/src/main/java/com/avaje/ebean/RawSql.java index 54cf268f5..f2727e398 100644 --- a/src/main/java/com/avaje/ebean/RawSql.java +++ b/src/main/java/com/avaje/ebean/RawSql.java @@ -53,37 +53,37 @@ import com.avaje.ebean.util.CamelCaseHelper; *

* *

Example OrderAggregate

- * + * *
{@code
  *  ...
  *  // @Sql indicates to that this bean
  *  // is based on RawSql rather than a table
- * 
+ *
  * @Entity
  * @Sql
  * public class OrderAggregate {
- * 
+ *
  *  @OneToOne
  *  Order order;
- *      
+ *
  *  Double totalAmount;
- *  
+ *
  *  Double totalItems;
- *  
+ *
  *  // getters and setters
  *  ...
  *
  * }
* *

Example 1:

- * + * *
{@code
  *
  *   String sql = " select order_id, o.status, c.id, c.name, sum(d.order_qty*d.unit_price) as totalAmount"
  *     + " from o_order o"
  *     + " join o_customer c on c.id = o.kcustomer_id "
  *     + " join o_order_detail d on d.order_id = o.id " + " group by order_id, o.status ";
- * 
+ *
  *   RawSql rawSql = RawSqlBuilder.parse(sql)
  *     // map the sql result columns to bean properties
  *     .columnMapping("order_id", "order.id")
@@ -93,35 +93,35 @@ import com.avaje.ebean.util.CamelCaseHelper;
  *     // we don't need to map this one due to the sql column alias
  *     // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount")
  *     .create();
- * 
+ *
  *   List list = Ebean.find(OrderAggregate.class)
  *       .setRawSql(rawSql)
  *       .where().gt("order.id", 0)
  *       .having().gt("totalAmount", 20)
  *       .findList();
- * 
+ *
  *
  * }
- * + * *

Example 2:

- * + * *

* The following example uses a FetchConfig().query() so that after the initial * RawSql query is executed Ebean executes a secondary query to fetch the * associated order status, orderDate along with the customer name. *

- * + * *
{@code
  *
  *  String sql = " select order_id, 'ignoreMe', sum(d.order_qty*d.unit_price) as totalAmount "
  *     + " from o_order_detail d"
  *     + " group by order_id ";
- * 
+ *
  *   RawSql rawSql = RawSqlBuilder.parse(sql)
  *     .columnMapping("order_id", "order.id")
  *     .columnMappingIgnore("'ignoreMe'")
  *     .create();
- * 
+ *
  *   List orders = Ebean.find(OrderAggregate.class)
  *     .setRawSql(rawSql)
  *     .fetch("order", "status,orderDate", new FetchConfig().query())
@@ -131,7 +131,7 @@ import com.avaje.ebean.util.CamelCaseHelper;
  *     .order().desc("totalAmount")
  *     .setMaxRows(10)
  *     .findList();
- * 
+ *
  * }
* * @@ -167,14 +167,14 @@ import com.avaje.ebean.util.CamelCaseHelper; *

* Note that lazy loading also works with object graphs built with RawSql. *

- * + * */ public final class RawSql implements Serializable { private static final long serialVersionUID = 1L; private final ResultSet resultSet; - + private final Sql sql; private final ColumnMapping columnMapping; @@ -192,7 +192,7 @@ public final class RawSql implements Serializable { this.sql = null; this.columnMapping = new ColumnMapping(propertyNames); } - + protected RawSql(ResultSet resultSet, Sql sql, ColumnMapping columnMapping) { this.resultSet = resultSet; this.sql = sql; @@ -214,7 +214,7 @@ public final class RawSql implements Serializable { String unParsedSql = (sql == null) ? "" : sql.unparsedSql; return new Key(parsed, unParsedSql, columnMapping); } - + /** * Return the resultSet if this is a ResultSet based RawSql. */ @@ -386,7 +386,7 @@ public final class RawSql implements Serializable { private final LinkedHashMap dbColumnMap; private final Map propertyMap; - + private final Map propertyColumnMap; private final boolean parsed; @@ -402,8 +402,7 @@ public final class RawSql implements Serializable { this.propertyMap = null; this.propertyColumnMap = null; this.dbColumnMap = new LinkedHashMap<>(); - for (int i = 0; i < columns.size(); i++) { - Column c = columns.get(i); + for (Column c : columns) { dbColumnMap.put(c.getDbColumnKey(), c); } } @@ -418,7 +417,7 @@ public final class RawSql implements Serializable { this.propertyColumnMap = null; this.dbColumnMap = new LinkedHashMap<>(); } - + /** * Construct for ResultSet use. */ @@ -476,7 +475,7 @@ public final class RawSql implements Serializable { /** * Creates an immutable copy of this ColumnMapping. - * + * * @throws IllegalStateException * when a propertyName has not been defined for a column. */ diff --git a/src/main/java/com/avaje/ebean/TxScope.java b/src/main/java/com/avaje/ebean/TxScope.java index 36c6f0633..cd8ac0c50 100644 --- a/src/main/java/com/avaje/ebean/TxScope.java +++ b/src/main/java/com/avaje/ebean/TxScope.java @@ -296,8 +296,8 @@ public final class TxScope { if (rollbackFor == null) { rollbackFor = new ArrayList<>(rollbackThrowables.length); } - for (int i = 0; i < rollbackThrowables.length; i++) { - rollbackFor.add((Class) rollbackThrowables[i]); + for (Class rollbackThrowable : rollbackThrowables) { + rollbackFor.add((Class) rollbackThrowable); } return this; } @@ -330,8 +330,8 @@ public final class TxScope { if (noRollbackFor == null) { noRollbackFor = new ArrayList<>(noRollbacks.length); } - for (int i = 0; i < noRollbacks.length; i++) { - noRollbackFor.add((Class) noRollbacks[i]); + for (Class noRollback : noRollbacks) { + noRollbackFor.add((Class) noRollback); } return this; } diff --git a/src/main/java/com/avaje/ebean/bean/CallStack.java b/src/main/java/com/avaje/ebean/bean/CallStack.java index 3d0f61f86..bc93b7206 100644 --- a/src/main/java/com/avaje/ebean/bean/CallStack.java +++ b/src/main/java/com/avaje/ebean/bean/CallStack.java @@ -34,12 +34,12 @@ public final class CallStack implements Serializable { public int hashCode() { int hc = 0; - for (int i = 0; i < callStack.length; i++) { - hc = 31 * hc + callStack[i].hashCode(); + for (StackTraceElement aCallStack : callStack) { + hc = 31 * hc + aCallStack.hashCode(); } return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -88,8 +88,8 @@ public final class CallStack implements Serializable { */ public String description(String newLine) { StringBuilder sb = new StringBuilder(400); - for (int i = 0; i < callStack.length; i++) { - sb.append(callStack[i].toString()).append(newLine); + for (StackTraceElement aCallStack : callStack) { + sb.append(aCallStack.toString()).append(newLine); } return sb.toString(); } diff --git a/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java b/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java index 3cef1e723..0025abfb1 100644 --- a/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java +++ b/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java @@ -30,7 +30,7 @@ public final class EntityBeanIntercept implements Serializable { private static final int STATE_NEW = 0; private static final int STATE_REFERENCE = 1; private static final int STATE_LOADED = 2; - + private transient NodeUsageCollector nodeUsageCollector; private transient PropertyChangeSupport pcs; @@ -55,11 +55,11 @@ public final class EntityBeanIntercept implements Serializable { * One of NEW, REF, UPD. */ private int state; - + private boolean readOnly; - + private boolean dirty; - + /** * Flag set to disable lazy loading - typically for SQL "report" type entity beans. */ @@ -74,14 +74,14 @@ public final class EntityBeanIntercept implements Serializable { * Used when a bean is partially filled. */ private final boolean[] loadedProps; - + private boolean fullyLoadedBean; /** * Set of changed properties. */ private boolean[] changedProps; - + /** * Flags indicating if a property is a dirty embedded bean. Used to distingush * between an embedded bean being completely overwritten and one of its @@ -180,7 +180,7 @@ public final class EntityBeanIntercept implements Serializable { public Object getEmbeddedOwner() { return embeddedOwner; } - + /** * Return the property index (for the parent) of this embedded bean. */ @@ -240,8 +240,8 @@ public final class EntityBeanIntercept implements Serializable { * Check each property to see if the bean is partially loaded. */ public boolean isPartial() { - for (int i = 0; i < loadedProps.length; i++) { - if (!loadedProps[i]) { + for (boolean loadedProp : loadedProps) { + if (!loadedProp) { return true; } } @@ -263,7 +263,7 @@ public final class EntityBeanIntercept implements Serializable { this.dirty = true; setEmbeddedPropertyDirty(embeddedProperty); } - + public void setDirty(boolean dirty) { this.dirty = dirty; } @@ -290,12 +290,12 @@ public final class EntityBeanIntercept implements Serializable { if (i == idIndex) { if (!loadedProps[i]) return false; } else if (loadedProps[i]) { - return false; + return false; } } return true; } - + /** * Return true if the entity is a reference. */ @@ -312,7 +312,7 @@ public final class EntityBeanIntercept implements Serializable { // For cases where properties are set on constructor // set every non Id property to unloaded (for lazy loading) for (int i=0; i< loadedProps.length; i++) { - if (i != idPos) { + if (i != idPos) { loadedProps[i] = false; } } @@ -448,7 +448,7 @@ public final class EntityBeanIntercept implements Serializable { } return origValues[propertyIndex]; } - + /** * Finds the index position of a given property. Returns -1 if the property * can not be found. @@ -462,7 +462,7 @@ public final class EntityBeanIntercept implements Serializable { } return -1; } - + /** * Return the property name for the given property. */ @@ -472,7 +472,7 @@ public final class EntityBeanIntercept implements Serializable { } return owner._ebean_getPropertyName(propertyIndex); } - + /** * Return the number of properties.s */ @@ -498,7 +498,7 @@ public final class EntityBeanIntercept implements Serializable { public void setPropertyUnloaded(int propertyIndex) { loadedProps[propertyIndex] = false; } - + /** * Set the property to be loaded. */ @@ -525,7 +525,7 @@ public final class EntityBeanIntercept implements Serializable { * embedded properties is dirty. */ public boolean isDirtyProperty(int propertyIndex) { - return (changedProps != null && changedProps[propertyIndex] + return (changedProps != null && changedProps[propertyIndex] || embeddedDirty != null && embeddedDirty[propertyIndex]); } @@ -536,7 +536,7 @@ public final class EntityBeanIntercept implements Serializable { setChangedProperty(propertyIndex); setDirty(true); } - + public void setChangedProperty(int propertyIndex) { if (changedProps == null) { changedProps = new boolean[owner._ebean_getPropertyNames().length]; @@ -553,7 +553,7 @@ public final class EntityBeanIntercept implements Serializable { } embeddedDirty[propertyIndex] = true; } - + private void setOriginalValue(int propertyIndex, Object value) { if (origValues == null) { origValues = new Object[owner._ebean_getPropertyNames().length]; @@ -567,19 +567,19 @@ public final class EntityBeanIntercept implements Serializable { * For forced update on a 'New' bean set all the loaded properties to changed. */ public void setNewBeanForUpdate() { - + if (changedProps == null) { changedProps = new boolean[owner._ebean_getPropertyNames().length]; } - + for (int i=0; i< loadedProps.length; i++) { if (loadedProps[i]) { - changedProps[i] = true; + changedProps[i] = true; } } setDirty(true); } - + /** * Return the set of property names for a partially loaded bean. */ @@ -621,7 +621,7 @@ public final class EntityBeanIntercept implements Serializable { addDirtyPropertyNames(props, null); return props; } - + /** * Recursively add dirty properties. */ @@ -670,7 +670,7 @@ public final class EntityBeanIntercept implements Serializable { addDirtyPropertyValues(dirtyValues, null); return dirtyValues; } - + /** * Recursively add dirty properties. */ @@ -684,7 +684,7 @@ public final class EntityBeanIntercept implements Serializable { Object oldVal = getOrigValue(i); dirtyValues.put(propName, new ValuePair(newVal, oldVal)); - + } else if (embeddedDirty != null && embeddedDirty[i]) { // an embedded property has been changed - recurse EntityBean embeddedBean = (EntityBean)owner._ebean_getField(i); @@ -692,14 +692,14 @@ public final class EntityBeanIntercept implements Serializable { } } } - + /** * Return a dirty property hash taking into account embedded beans. */ public int getDirtyPropertyHash() { return addDirtyPropertyHash(37); } - + /** * Add and return a dirty property hash recursing into embedded beans. */ @@ -749,7 +749,7 @@ public final class EntityBeanIntercept implements Serializable { public int getLazyLoadPropertyIndex() { return lazyLoadProperty; } - + /** * Return the property that triggered the lazy load. */ @@ -849,7 +849,7 @@ public final class EntityBeanIntercept implements Serializable { } return obj1.equals(obj2); } - + /** * Called when a BeanCollection is initialised automatically. */ @@ -920,7 +920,7 @@ public final class EntityBeanIntercept implements Serializable { if (readOnly) { throw new IllegalStateException("This bean is readOnly"); } - + setLoadedProperty(propertyIndex); // Bean itself not considered dirty when many changed @@ -930,7 +930,7 @@ public final class EntityBeanIntercept implements Serializable { return null; } } - + private void setChangedPropertyValue(int propertyIndex, boolean setDirtyState, Object origValue) { if (readOnly) { @@ -941,7 +941,7 @@ public final class EntityBeanIntercept implements Serializable { if (setDirtyState) { setOriginalValue(propertyIndex, origValue); if (!dirty) { - dirty = true; + dirty = true; if (embeddedOwner != null) { // Cascade dirty state from Embedded bean to parent bean embeddedOwner._ebean_getIntercept().setEmbeddedDirty(embeddedOwnerIndex); @@ -952,7 +952,7 @@ public final class EntityBeanIntercept implements Serializable { } } } - + /** * Check to see if the values are not equal. If they are not equal then create * the old values for use with ConcurrencyMode.ALL. @@ -962,15 +962,15 @@ public final class EntityBeanIntercept implements Serializable { if (state == STATE_NEW) { setLoadedProperty(propertyIndex); } else if (!areEqual(oldValue, newValue)) { - setChangedPropertyValue(propertyIndex, intercept, oldValue); + setChangedPropertyValue(propertyIndex, intercept, oldValue); } else { return null; } - - return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); + + return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); } - - + + /** * Check for primitive boolean. */ @@ -1007,13 +1007,13 @@ public final class EntityBeanIntercept implements Serializable { public PropertyChangeEvent preSetter(boolean intercept, int propertyIndex, long oldValue, long newValue) { if (state == STATE_NEW) { - setLoadedProperty(propertyIndex); + setLoadedProperty(propertyIndex); } else if (oldValue != newValue) { setChangedPropertyValue(propertyIndex, intercept, oldValue); } else { return null; } - + return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); } @@ -1025,7 +1025,7 @@ public final class EntityBeanIntercept implements Serializable { if (state == STATE_NEW) { setLoadedProperty(propertyIndex); } else if (oldValue != newValue) { - setChangedPropertyValue(propertyIndex, intercept, oldValue); + setChangedPropertyValue(propertyIndex, intercept, oldValue); } else { return null; } diff --git a/src/main/java/com/avaje/ebean/common/BeanList.java b/src/main/java/com/avaje/ebean/common/BeanList.java index 663154fd1..37fd9c309 100644 --- a/src/main/java/com/avaje/ebean/common/BeanList.java +++ b/src/main/java/com/avaje/ebean/common/BeanList.java @@ -261,8 +261,8 @@ public final class BeanList extends AbstractBeanCollection implements List // and fetch just the Id's initClear(); if (modifyRemoveListening) { - for (int i = 0; i < list.size(); i++) { - getModifyHolder().modifyRemoval(list.get(i)); + for (E aList : list) { + getModifyHolder().modifyRemoval(aList); } } list.clear(); diff --git a/src/main/java/com/avaje/ebean/config/DbConstraintNormalise.java b/src/main/java/com/avaje/ebean/config/DbConstraintNormalise.java index 8779af15f..7a4ac320c 100644 --- a/src/main/java/com/avaje/ebean/config/DbConstraintNormalise.java +++ b/src/main/java/com/avaje/ebean/config/DbConstraintNormalise.java @@ -78,8 +78,8 @@ public class DbConstraintNormalise { public boolean notQuoted(String tableName) { // remove quoted identifier characters - for (int i = 0; i < quotedIdentifiers.length; i++) { - if (tableName.contains(quotedIdentifiers[i])) { + for (String quotedIdentifier : quotedIdentifiers) { + if (tableName.contains(quotedIdentifier)) { return false; } } @@ -95,8 +95,8 @@ public class DbConstraintNormalise { return ""; } // remove quoted identifier characters - for (int i = 0; i < quotedIdentifiers.length; i++) { - tableName = tableName.replace(quotedIdentifiers[i], ""); + for (String quotedIdentifier : quotedIdentifiers) { + tableName = tableName.replace(quotedIdentifier, ""); } return tableName; } diff --git a/src/main/java/com/avaje/ebean/config/ServerConfig.java b/src/main/java/com/avaje/ebean/config/ServerConfig.java index 599a2b813..7ca2590ea 100644 --- a/src/main/java/com/avaje/ebean/config/ServerConfig.java +++ b/src/main/java/com/avaje/ebean/config/ServerConfig.java @@ -2117,7 +2117,7 @@ public class ServerConfig { */ public void add(BeanPostConstructListener listener) { postConstructListeners.add(listener); - } + } /** * Return the list of BeanFindController instances. */ @@ -2524,8 +2524,8 @@ public class ServerConfig { List> classes = new ArrayList<>(); String[] split = classNames.split("[ ,;]"); - for (int i = 0; i < split.length; i++) { - String cn = split[i].trim(); + for (String aSplit : split) { + String cn = aSplit.trim(); if (!cn.isEmpty() && !"class".equalsIgnoreCase(cn)) { try { classes.add(Class.forName(cn)); @@ -2545,8 +2545,8 @@ public class ServerConfig { if (searchPackages != null) { String[] entries = searchPackages.split("[ ,;]"); - for (int i = 0; i < entries.length; i++) { - hitList.add(entries[i].trim()); + for (String entry : entries) { + hitList.add(entry.trim()); } } return hitList; diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java index cc74d7478..6724d35fd 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java @@ -159,8 +159,8 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { } synchronized (monitor) { - for (int i = 0; i < newIds.size(); i++) { - idList.add(newIds.get(i)); + for (Long newId : newIds) { + idList.add(newId); } } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java index 64902be84..d8cf688d4 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java @@ -47,8 +47,8 @@ public class MsSqlServerDdl extends PlatformDdl { sb.append(columns[i]); } sb.append(") where"); - for (int i = 0; i < columns.length; i++) { - sb.append(" ").append(columns[i]).append(" is not null"); + for (String column : columns) { + sb.append(" ").append(column).append(" is not null"); } return sb.toString(); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexSet.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexSet.java index 3e8148542..42c098b7b 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexSet.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexSet.java @@ -36,8 +36,8 @@ public class IndexSet { */ public boolean add(String[] columns) { IndexColumns newIndex = new IndexColumns(columns); - for (int i = 0; i < indexes.size(); i++) { - if (indexes.get(i).isMatch(newIndex)) { + for (IndexColumns indexe : indexes) { + if (indexe.isMatch(newIndex)) { return false; } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java index f7c122954..27f38d287 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java @@ -60,7 +60,7 @@ public class ModelBuildIntersectionTable { intersectionTable.checkDuplicateForeignKeys(); } - + private void buildFkConstraints(BeanDescriptor desc, TableJoinColumn[] columns, boolean direction) { String tableName = intersectionTableJoin.getTable(); @@ -71,11 +71,11 @@ public class ModelBuildIntersectionTable { MCompoundForeignKey foreignKey = new MCompoundForeignKey(fkName, desc.getBaseTable(), fkIndex); intersectionTable.addForeignKey(foreignKey); - for (int i = 0; i < columns.length; i++) { - String localCol = direction ? columns[i].getForeignDbColumn() : columns[i].getLocalDbColumn(); - String refCol = !direction ? columns[i].getForeignDbColumn() : columns[i].getLocalDbColumn(); + for (TableJoinColumn column : columns) { + String localCol = direction ? column.getForeignDbColumn() : column.getLocalDbColumn(); + String refCol = !direction ? column.getForeignDbColumn() : column.getLocalDbColumn(); foreignKey.addColumnPair(localCol, refCol); - } + } } private MTable createTable() { @@ -93,14 +93,14 @@ public class ModelBuildIntersectionTable { table.setPkName(ctx.primaryKeyName(tableName)); TableJoinColumn[] columns = intersectionTableJoin.columns(); - for (int i = 0; i < columns.length; i++) { - addColumn(table, localDesc, columns[i].getForeignDbColumn(), columns[i].getLocalDbColumn()); - } + for (TableJoinColumn column : columns) { + addColumn(table, localDesc, column.getForeignDbColumn(), column.getLocalDbColumn()); + } TableJoinColumn[] otherColumns = tableJoin.columns(); - for (int i = 0; i < otherColumns.length; i++) { - addColumn(table, targetDesc, otherColumns[i].getLocalDbColumn(), otherColumns[i].getForeignDbColumn()); - } + for (TableJoinColumn otherColumn : otherColumns) { + addColumn(table, targetDesc, otherColumn.getLocalDbColumn(), otherColumn.getForeignDbColumn()); + } return table; } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java index 7e66c16ed..339bec4c5 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java @@ -54,8 +54,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { private void addIndexes(IndexDefinition[] indexes) { if (indexes != null) { - for (int i = 0; i < indexes.length; i++) { - IndexDefinition index = indexes[i]; + for (IndexDefinition index : indexes) { String[] columns = index.getColumns(); indexSet.add(columns); @@ -178,9 +177,9 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { table.addForeignKey(compoundKey); } - for (int i = 0; i < columns.length; i++) { + for (TableJoinColumn column : columns) { - String dbCol = columns[i].getLocalDbColumn(); + String dbCol = column.getLocalDbColumn(); BeanProperty importedProperty = importedId.findMatchImport(dbCol); if (importedProperty == null) { throw new RuntimeException("Imported BeanProperty not found?"); @@ -369,4 +368,4 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { return val != null && !val.isEmpty(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/visitor/VisitAllUsing.java b/src/main/java/com/avaje/ebean/dbmigration/model/visitor/VisitAllUsing.java index b25add8e5..2f35f0410 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/visitor/VisitAllUsing.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/visitor/VisitAllUsing.java @@ -64,8 +64,7 @@ public class VisitAllUsing { } BeanProperty[] propertiesNonTransient = desc.propertiesNonTransient(); - for (int i = 0; i < propertiesNonTransient.length; i++) { - BeanProperty p = propertiesNonTransient[i]; + for (BeanProperty p : propertiesNonTransient) { if (p.isDDLColumn()) { visit(propertyVisitor, p); } @@ -91,8 +90,8 @@ public class VisitAllUsing { // Embedded bean pv.visitEmbedded(assocOne); BeanProperty[] embProps = assocOne.getProperties(); - for (int i = 0; i < embProps.length; i++) { - pv.visitEmbeddedScalar(embProps[i], assocOne); + for (BeanProperty embProp : embProps) { + pv.visitEmbeddedScalar(embProp, assocOne); } } else if (assocOne.isOneToOneExported()) { @@ -110,8 +109,8 @@ public class VisitAllUsing { pv.visitCompound(compound); BeanProperty[] properties = compound.getScalarProperties(); - for (int i = 0; i < properties.length; i++) { - pv.visitCompoundScalar(compound, properties[i]); + for (BeanProperty property : properties) { + pv.visitCompoundScalar(compound, property); } } else { @@ -151,8 +150,8 @@ public class VisitAllUsing { public void visit(InheritInfo inheritInfo) { BeanProperty[] propertiesLocal = inheritInfo.desc().propertiesLocal(); - for (int i = 0; i < propertiesLocal.length; i++) { - owner.visit(pv, propertiesLocal[i]); + for (BeanProperty aPropertiesLocal : propertiesLocal) { + owner.visit(pv, aPropertiesLocal); } } } diff --git a/src/main/java/com/avaje/ebean/util/StringHelper.java b/src/main/java/com/avaje/ebean/util/StringHelper.java index 3eed6135c..947a4bb1d 100644 --- a/src/main/java/com/avaje/ebean/util/StringHelper.java +++ b/src/main/java/com/avaje/ebean/util/StringHelper.java @@ -111,7 +111,7 @@ public class StringHelper { * Parses out a list of Name Value pairs that are delimited together. Will * always return a StringMap. If allNameValuePairs is null, or no name values * can be parsed out an empty StringMap is returned. - * + * * @param allNameValuePairs * the entire string to be parsed. * @param listDelimiter @@ -133,7 +133,7 @@ public class StringHelper { /** * Trims off recurring strings from the front of a string. - * + * * @param source * the source string * @param trim @@ -219,7 +219,7 @@ public class StringHelper { * Convert a string that has delimited values (say comma delimited) in a * String[]. You must explicitly choose whether or not to include empty values * (say two commas that a right beside each other. - * + * *

* e.g. "alpha,beta,,theta"
* With keepEmpties true, this results in a String[] of size 4 with the third @@ -272,7 +272,7 @@ public class StringHelper { * This returns the FIRST string in str that is bounded on the left by * leftBound, and bounded on the right by rightBound. This will return null if * the leftBound is not found within str. - * + * *

* If leftBound can't be found this returns null. *

@@ -280,7 +280,7 @@ public class StringHelper { * This rightBound can't be found then this throws a * StringIndexOutOfBoundsException. *

- * + * * @param str * the base string that we will search for the bounded string. * @param leftBound @@ -364,7 +364,7 @@ public class StringHelper { /** * This method takes a String and will replace all occurrences of the match * String with that of the replace String. - * + * * @param source * the source string * @param match @@ -462,7 +462,7 @@ public class StringHelper { *

* Useful when converting CRNL CR and NL all to a BR tag for example. *

- * + * *
    * 
    * String[] multi = { "\r\n", "\r", "\n" };
@@ -580,8 +580,8 @@ public class StringHelper {
   }
 
   private static boolean charMatch(int iChr, char[] chr) {
-    for (int i = 0; i < chr.length; i++) {
-      if (iChr == chr[i]) {
+    for (char aChr : chr) {
+      if (iChr == aChr) {
         return true;
       }
     }
diff --git a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java
index 8a049de7f..ecb4c4afe 100644
--- a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java
+++ b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java
@@ -23,7 +23,7 @@ public class BindParams implements Serializable {
 	private final List positionedParameters = new ArrayList<>();
 
 	private final Map namedParameters = new LinkedHashMap<>();
-	
+
 	/**
 	 * This is the sql. For named parameters this is the sql after the named
 	 * parameters have been replaced with question mark place holders and the
@@ -37,14 +37,14 @@ public class BindParams implements Serializable {
    */
   private int[] bindHash;
 
-	public BindParams() {  
+	public BindParams() {
 	}
-	
+
   public int queryBindHash() {
      int hc = namedParameters.hashCode();
-     for (int i = 0; i < positionedParameters.size(); i++) {
-       hc = hc * 31 + positionedParameters.get(i).hashCode();
-     }
+    for (Param positionedParameter : positionedParameters) {
+      hc = hc * 31 + positionedParameter.hashCode();
+    }
      return hc;
    }
 
@@ -97,14 +97,14 @@ public class BindParams implements Serializable {
 		}
 		return copy;
 	}
-	
+
 	/**
 	 * Return true if there are no bind parameters.
 	 */
 	public boolean isEmpty() {
 		return positionedParameters.isEmpty() && namedParameters.isEmpty();
 	}
-	
+
 	/**
 	 * Return a Natural Key bind param if supported.
 	 */
@@ -209,7 +209,7 @@ public class BindParams implements Serializable {
 	 * Set a named In parameter that is not null.
 	 */
 	public Param setParameter(String name, Object value) {
-	    
+
 	  Param p = getParam(name);
 		p.setInValue(value);
 		return p;
@@ -302,62 +302,62 @@ public class BindParams implements Serializable {
 	 * 

*/ public static final class OrderedList { - + private final List paramList; - + private final StringBuilder preparedSql; public OrderedList() { this(new ArrayList<>()); } - + public OrderedList(List paramList) { this.paramList = paramList; this.preparedSql = new StringBuilder(); } - + /** * Add a parameter in the correct binding order. */ public void add(Param param) { paramList.add(param); } - + /** * Return the number of bind parameters in this list. */ public int size() { return paramList.size(); } - + /** * Returns the ordered list of bind parameters. */ public List list() { return paramList; } - + /** * Append parsedSql that has named parameters converted into ?. */ public void appendSql(String parsedSql) { preparedSql.append(parsedSql); } - + public String getPreparedSql() { return preparedSql.toString(); } } - + /** * A In Out capable parameter for the CallableStatement. */ public static final class Param implements Serializable { private static final long serialVersionUID = 1L; - + private boolean encryptionKey; - + private boolean isInParam; private boolean isOutParam; @@ -381,9 +381,9 @@ public class BindParams implements Serializable { if (inValue instanceof Collection){ return ((Collection)inValue).size(); } - return 1; + return 1; } - + /** * Create a deep copy of the Param. */ @@ -396,20 +396,20 @@ public class BindParams implements Serializable { copy.outValue = outValue; return copy; } - + public int hashCode() { int hc = getClass().hashCode(); hc = hc * 31 + (isInParam ? 0 : 1); hc = hc * 31 + (isOutParam ? 0 : 1); hc = hc * 31 + (type); - hc = hc * 31 + (inValue == null ? 0 : inValue.hashCode()); + hc = hc * 31 + (inValue == null ? 0 : inValue.hashCode()); return hc; } public boolean equals(Object o) { return o != null && (o == this || (o instanceof Param) && hashCode() == o.hashCode()); } - + /** * Return true if this is an In parameter that needs to be bound before * execution. @@ -458,7 +458,7 @@ public class BindParams implements Serializable { this.isInParam = true; this.encryptionKey = true; } - + /** * Specify that the In parameter is NULL and the specific type that it * is. diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java index 48499ee40..09e796aac 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java @@ -98,8 +98,7 @@ public class LoadBeanRequest extends LoadRequest { List idList = new ArrayList<>(batchSize); BeanDescriptor desc = loadBuffer.getBeanDescriptor(); - for (int i = 0; i < batch.size(); i++) { - EntityBeanIntercept ebi = batch.get(i); + for (EntityBeanIntercept ebi : batch) { EntityBean bean = ebi.getOwner(); idList.add(desc.getId(bean)); } @@ -154,8 +153,8 @@ public class LoadBeanRequest extends LoadRequest { BeanDescriptor desc = loadBuffer.getBeanDescriptor(); // collect Ids and maybe load bean cache - for (int i = 0; i < list.size(); i++) { - EntityBean loadedBean = (EntityBean) list.get(i); + for (Object aList : list) { + EntityBean loadedBean = (EntityBean) aList; loadedIds.add(desc.getId(loadedBean)); if (isLoadCache()) { desc.cacheBeanPut(loadedBean); @@ -163,10 +162,9 @@ public class LoadBeanRequest extends LoadRequest { } if (lazyLoadProperty != null) { - for (int i = 0; i < batch.size(); i++) { + for (EntityBeanIntercept ebi : batch) { // check if the underlying row in DB was deleted. Mark the bean as 'failed' if // necessary but allow processing to continue until it is accessed by client code - EntityBeanIntercept ebi = batch.get(i); Object id = desc.getId(ebi.getOwner()); if (!loadedIds.contains(id)) { if (desc.isSoftDelete()) { diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java index 20de44756..3f6172422 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java @@ -104,8 +104,7 @@ public class LoadManyRequest extends LoadRequest { ArrayList idList = new ArrayList<>(batchSize); BeanPropertyAssocMany many = getMany(); - for (int i = 0; i < batch.size(); i++) { - BeanCollection bc = batch.get(i); + for (BeanCollection bc : batch) { idList.add(many.getParentId(bc.getOwnerBean())); } int extraIds = batchSize - batch.size(); @@ -177,8 +176,7 @@ public class LoadManyRequest extends LoadRequest { // check for BeanCollection's that where never processed // in the +query or +lazy load due to no rows (predicates) - for (int i = 0; i < batch.size(); i++) { - BeanCollection bc = batch.get(i); + for (BeanCollection bc : batch) { if (bc.checkEmptyLazyLoad()) { if (logger.isDebugEnabled()) { EntityBean ownerBean = bc.getOwnerBean(); diff --git a/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java b/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java index c2eda8690..734099800 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java @@ -221,8 +221,8 @@ public class ScopeTrans implements Thread.UncaughtExceptionHandler { } if (noRollbackFor != null) { - for (int i = 0; i < noRollbackFor.size(); i++) { - if (noRollbackFor.get(i).equals(e.getClass())) { + for (Class aNoRollbackFor : noRollbackFor) { + if (aNoRollbackFor.equals(e.getClass())) { // explicit no rollback for this one return false; @@ -231,8 +231,8 @@ public class ScopeTrans implements Thread.UncaughtExceptionHandler { } if (rollbackFor != null) { - for (int i = 0; i < rollbackFor.size(); i++) { - if (rollbackFor.get(i).equals(e.getClass())) { + for (Class aRollbackFor : rollbackFor) { + if (aRollbackFor.equals(e.getClass())) { // explicit rollback for this one return true; } diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java index 845431bb5..6f81f9aa1 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java @@ -126,8 +126,8 @@ public class TransactionEvent implements Serializable { List> persistRequestBeans = getPersistRequestBeans(); if (persistRequestBeans != null) { - for (int i=0; i< persistRequestBeans.size(); i++) { - persistRequestBeans.get(i).addDocStoreUpdates(docStoreUpdates); + for (PersistRequestBean persistRequestBean : persistRequestBeans) { + persistRequestBean.addDocStoreUpdates(docStoreUpdates); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java index 1fd704b14..3b770ce92 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java @@ -36,9 +36,9 @@ public class TransactionEventBeans { * Collect the cache changes. */ public void notifyCache(CacheChangeSet changeSet) { - for (int i = 0; i < requests.size(); i++) { - requests.get(i).notifyCache(changeSet); - } + for (PersistRequestBean request : requests) { + request.notifyCache(changeSet); + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java index 46b19524b..7927f20bd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java @@ -27,8 +27,7 @@ public class CachedBeanDataFromBean { BeanProperty[] props = desc.propertiesNonMany(); // extract all the non-many properties - for (int i = 0; i < props.length; i++) { - BeanProperty prop = props[i]; + for (BeanProperty prop : props) { if (ebi.isLoadedProperty(prop.getPropertyIndex())) { data.put(prop.getName(), prop.getCacheDataValue(bean)); } @@ -56,9 +55,9 @@ public class CachedBeanDataFromBean { idProp.setValue(sharableBean, v); } BeanProperty[] propertiesNonTransient = desc.propertiesNonTransient(); - for (int i = 0; i < propertiesNonTransient.length; i++) { - Object v = propertiesNonTransient[i].getValue(bean); - propertiesNonTransient[i].setValue(sharableBean, v); + for (BeanProperty aPropertiesNonTransient : propertiesNonTransient) { + Object v = aPropertiesNonTransient.getValue(bean); + aPropertiesNonTransient.setValue(sharableBean, v); } EntityBeanIntercept intercept = sharableBean._ebean_intercept(); intercept.setReadOnly(true); @@ -67,4 +66,4 @@ public class CachedBeanDataFromBean { } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataToBean.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataToBean.java index f324409cc..35e9bf52b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataToBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataToBean.java @@ -22,13 +22,13 @@ public class CachedBeanDataToBean { // load the non-many properties BeanProperty[] props = desc.propertiesNonMany(); - for (int i = 0; i < props.length; i++) { - loadProperty(bean, cacheBeanData, ebi, props[i], context); + for (BeanProperty prop : props) { + loadProperty(bean, cacheBeanData, ebi, prop, context); } BeanPropertyAssocMany[] many = desc.propertiesMany(); - for (int i = 0; i < many.length; i++) { - many[i].createReferenceIfNull(bean); + for (BeanPropertyAssocMany aMany : many) { + aMany.createReferenceIfNull(bean); } ebi.setLoadedLazy(); @@ -44,4 +44,4 @@ public class CachedBeanDataToBean { } } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java index fc963cc88..76c3cb0b8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java @@ -87,13 +87,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private static final Logger logger = LoggerFactory.getLogger(DefaultServer.class); private static final int IGNORE_LEADING_ELEMENTS = 5; - + private static final String COM_AVAJE_EBEAN = "com.avaje.ebean"; private static final String ORG_AVAJE_EBEAN = "org.avaje.ebean"; private final ServerConfig serverConfig; - + private final String serverName; private final DatabasePlatform databasePlatform; @@ -113,7 +113,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { * false; */ private final boolean rollbackOnChecked; - + /** * Handles the save, delete, updateSql CallableSql. */ @@ -152,7 +152,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private final DocumentStore documentStore; private final MetaInfoManager metaInfoManager; - + /** * The default PersistenceContextScope used if it is not explicitly set on a query. */ @@ -162,21 +162,21 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { * Flag set when the server has shutdown. */ private boolean shutdown; - + /** * The default batch size for lazy loading beans or collections. */ private final int lazyLoadBatchSize; - /** - * The query batch size + /** + * The query batch size */ private final int queryBatchSize; private final boolean updateAllPropertiesInBatch; private final boolean collectQueryOrigins; - + private final boolean collectQueryStatsByNode; /** @@ -235,7 +235,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { this.ddlGenerator = new DdlGenerator(this, serverConfig); configureServerPlugins(); - + // Register with the JVM Shutdown hook ShutdownManager.registerEbeanServer(this); } @@ -273,7 +273,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { public int getLazyLoadBatchSize() { return lazyLoadBatchSize; } - + public int getQueryBatchSize() { return queryBatchSize; } @@ -798,23 +798,23 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { *

*

* Code example:
- * + * *

    * <code>
    * Ebean.startTransaction();
    * try {
    * 	// do some fetching and or persisting
-   * 
+   *
    * 	// commit at the end
    * 	Ebean.commitTransaction();
-   * 
+   *
    * } finally {
    * 	// if commit didn't occur then rollback the transaction
    * 	Ebean.endTransaction();
    * }
    * </code>
    * 
- * + * *

*/ public void endTransaction() { @@ -1205,7 +1205,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { try { request.initTransIfRequired(); return request.findIds(); - + } finally { request.endTransIfRequired(); } @@ -1374,7 +1374,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { try { request.initTransIfRequired(); return request.findList(); - + } finally { request.endTransIfRequired(); } @@ -1445,18 +1445,18 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { throw new IllegalArgumentException("This bean is not an EntityBean?"); } // mark the bean as dirty (so that an update will not get skipped) - ((EntityBean)bean)._ebean_getIntercept().setDirty(true); + ((EntityBean)bean)._ebean_getIntercept().setDirty(true); } /** - * Update the bean using the default 'updatesDeleteMissingChildren' setting. + * Update the bean using the default 'updatesDeleteMissingChildren' setting. */ public void update(Object bean) { update(bean, null); } /** - * Update the bean using the default 'updatesDeleteMissingChildren' setting. + * Update the bean using the default 'updatesDeleteMissingChildren' setting. */ public void update(Object bean, Transaction t) { persister.update(checkEntityBean(bean), t); @@ -1483,7 +1483,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { // Nothing to update? return; } - + TransWrapper wrap = initTransIfRequired(t); try { SpiTransaction trans = wrap.transaction; @@ -1491,13 +1491,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { update(checkEntityBean(bean), trans); } wrap.commitIfCreated(); - + } catch (RuntimeException e) { wrap.rollbackIfCreated(); throw e; } } - + /** * Insert the bean. */ @@ -1528,7 +1528,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { // Nothing to insert? return; } - + TransWrapper wrap = initTransIfRequired(t); try { SpiTransaction trans = wrap.transaction; @@ -1536,7 +1536,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { persister.insert(checkEntityBean(bean), trans); } wrap.commitIfCreated(); - + } catch (RuntimeException e) { wrap.rollbackIfCreated(); throw e; @@ -1621,7 +1621,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } return (EntityBean)bean; } - + @Override public int saveAll(Collection beans, Transaction transaction) throws OptimisticLockException { return saveAllInternal(beans.iterator(), transaction); @@ -1853,15 +1853,15 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { public void register(BeanPersistController c) { List> list = beanDescriptorManager.getBeanDescriptorList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).register(c); + for (BeanDescriptor aList : list) { + aList.register(c); } } public void deregister(BeanPersistController c) { List> list = beanDescriptorManager.getBeanDescriptorList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).deregister(c); + for (BeanDescriptor aList : list) { + aList.deregister(c); } } @@ -2041,14 +2041,14 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { // immutable thread safe so return shared instance return jsonContext; } - + @Override public void collectQueryStats(ObjectGraphNode node, long loadedBeanCount, long timeMicros) { - + if (collectQueryStatsByNode) { CObjectGraphNodeStatistics nodeStatistics = objectGraphStats.get(node); if (nodeStatistics == null) { - // race condition here but I actually don't care too much if we miss a + // race condition here but I actually don't care too much if we miss a // few early statistics - especially when the server is warming up etc nodeStatistics = new CObjectGraphNodeStatistics(node); objectGraphStats.put(node, nodeStatistics); @@ -2056,5 +2056,5 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { nodeStatistics.add(loadedBeanCount, timeMicros); } } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java index 74520d382..0ba67bfeb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java @@ -303,8 +303,8 @@ public final class PersistRequestBean extends PersistRequest implements BeanP */ public boolean hasDirtyProperty(int[] propertyPositions) { - for (int i = 0; i < propertyPositions.length; i++) { - if (dirtyProperties[propertyPositions[i]]) { + for (int propertyPosition : propertyPositions) { + if (dirtyProperties[propertyPosition]) { return true; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java index 56ae7e7b3..9028d0949 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java @@ -33,12 +33,12 @@ public final class PersistRequestCallableSql extends PersistRequest { */ public PersistRequestCallableSql(SpiEbeanServer server, CallableSql cs, SpiTransaction t, PersistExecute persistExecute) { - + super(server, t, persistExecute); this.type = PersistRequest.Type.CALLABLESQL; this.callableSql = (SpiCallableSql)cs; } - + @Override public int executeOrQueue() { return executeStatement(); @@ -88,7 +88,7 @@ public final class PersistRequestCallableSql extends PersistRequest { // register table modifications with the transaction event TransactionEventTable tableEvents = callableSql.getTransactionEventTable(); - + if (tableEvents != null && !tableEvents.isEmpty()) { transaction.getEvent().add(tableEvents); } else { @@ -134,14 +134,14 @@ public final class PersistRequestCallableSql extends PersistRequest { List list = bindParam.positionedParameters(); int pos = 0; - for (int i = 0; i < list.size(); i++) { - pos++; - BindParams.Param param = list.get(i); - if (param.isOutParam()) { - Object outValue = cstmt.getObject(pos); - param.setOutValue(outValue); - } - } + for (Param aList : list) { + pos++; + Param param = aList; + if (param.isOutParam()) { + Object outValue = cstmt.getObject(pos); + param.setOutValue(outValue); + } + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java b/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java index 901603485..95f9e6e12 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java @@ -191,10 +191,10 @@ public final class RelationalQueryRequest { SqlRow sqlRow = new DefaultSqlRow(estimateCapacity, 0.75f, dbTrueValue); int index = 0; - for (int i = 0; i < propertyNames.length; i++) { + for (String propertyName : propertyNames) { index++; Object value = resultSet.getObject(index); - sqlRow.set(propertyNames[i], value); + sqlRow.set(propertyName, value); } return sqlRow; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java index 1bb50c71d..6dbfb865a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java @@ -38,8 +38,8 @@ class DistillPackages { */ private static boolean notAlreadyContained(List distilled, String pack) { - for (int i = 0; i < distilled.size(); i++) { - if (pack.startsWith(distilled.get(i))) { + for (String aDistilled : distilled) { + if (pack.startsWith(aDistilled)) { return false; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java index 7098786f7..a9ce63945 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java @@ -74,8 +74,8 @@ class ManifestReader { */ private void add(String packages) { String[] split = packages.split(",|;| "); - for (int i = 0; i implements MetaBeanInfo, BeanType { this.docStoreQueueId = docStoreAdapter.getQueueId(); // Check if there are no cascade save associated beans ( subject to change - // in initialiseOther()). Note that if we are in an inheritance hierarchy - // then we also need to check every BeanDescriptors in the InheritInfo as + // in initialiseOther()). Note that if we are in an inheritance hierarchy + // then we also need to check every BeanDescriptors in the InheritInfo as // well. We do that later in initialiseOther(). saveRecurseSkippable = (0 == (propertiesOneExportedSave.length + propertiesOneImportedSave.length + propertiesManySave.length)); @@ -588,9 +588,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ public void setEbeanServer(SpiEbeanServer ebeanServer) { this.ebeanServer = ebeanServer; - for (int i = 0; i < propertiesMany.length; i++) { + for (BeanPropertyAssocMany aPropertiesMany : propertiesMany) { // used for creating lazy loading lists etc - propertiesMany[i].setLoader(ebeanServer); + aPropertiesMany.setLoader(ebeanServer); } } @@ -661,18 +661,18 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ public void initialiseOther(Map asOfTableMap, String asOfViewSuffix, Map draftTableMap) { - for (int i = 0; i < propertiesManyToMany.length; i++) { + for (BeanPropertyAssocMany aPropertiesManyToMany1 : propertiesManyToMany) { // register associated draft table for M2M intersection - propertiesManyToMany[i].registerDraftIntersectionTable(draftTableMap); + aPropertiesManyToMany1.registerDraftIntersectionTable(draftTableMap); } if (historySupport) { // history support on this bean so check all associated intersection tables // and if they are not excluded register the associated 'with history' table - for (int i = 0; i < propertiesManyToMany.length; i++) { + for (BeanPropertyAssocMany aPropertiesManyToMany : propertiesManyToMany) { // register associated history table for M2M intersection - if (!propertiesManyToMany[i].isExcludedFromHistory()) { - TableJoin intersectionTableJoin = propertiesManyToMany[i].getIntersectionTableJoin(); + if (!aPropertiesManyToMany.isExcludedFromHistory()) { + TableJoin intersectionTableJoin = aPropertiesManyToMany.getIntersectionTableJoin(); String intersectionTableName = intersectionTableJoin.getTable(); asOfTableMap.put(intersectionTableName, intersectionTableName + asOfViewSuffix); } @@ -716,8 +716,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ @SuppressWarnings("unchecked") public void initialiseDocMapping() { - for (int i = 0; i < propertiesMany.length; i++) { - propertiesMany[i].initialisePostTarget(); + for (BeanPropertyAssocMany aPropertiesMany : propertiesMany) { + aPropertiesMany.initialisePostTarget(); } if (inheritInfo != null && !inheritInfo.isRoot()) { docStoreAdapter = (DocStoreBeanAdapter) inheritInfo.getRoot().desc().docStoreAdapter(); @@ -835,8 +835,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { sb.append(inClause); DefaultSqlUpdate delete = new DefaultSqlUpdate(sb.toString()); - for (int i = 0; i < idList.size(); i++) { - idBinder.bindId(delete, idList.get(i)); + for (Object anIdList : idList) { + idBinder.bindId(delete, anIdList); } return delete; } @@ -851,8 +851,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { DefaultSqlUpdate sqlDelete = new DefaultSqlUpdate(baseSql); Object[] bindValues = idBinder.getBindValues(id); - for (int i = 0; i < bindValues.length; i++) { - sqlDelete.addParameter(bindValues[i]); + for (Object bindValue : bindValues) { + sqlDelete.addParameter(bindValue); } return sqlDelete; @@ -867,8 +867,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { } public void initialiseFkeys() { - for (int i = 0; i < propertiesOneImported.length; i++) { - propertiesOneImported[i].addFkey(); + for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { + aPropertiesOneImported.addFkey(); } } @@ -1469,9 +1469,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ private BeanProperty findWhenCreatedProperty() { - for (int i = 0; i < propertiesBaseScalar.length; i++) { - if (propertiesBaseScalar[i].isGeneratedWhenCreated()) { - return propertiesBaseScalar[i]; + for (BeanProperty aPropertiesBaseScalar : propertiesBaseScalar) { + if (aPropertiesBaseScalar.isGeneratedWhenCreated()) { + return aPropertiesBaseScalar; } } return null; @@ -1482,9 +1482,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ private BeanProperty findWhenModifiedProperty() { - for (int i = 0; i < propertiesBaseScalar.length; i++) { - if (propertiesBaseScalar[i].isGeneratedWhenModified()) { - return propertiesBaseScalar[i]; + for (BeanProperty aPropertiesBaseScalar : propertiesBaseScalar) { + if (aPropertiesBaseScalar.isGeneratedWhenModified()) { + return aPropertiesBaseScalar; } } return null; @@ -1496,9 +1496,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { public BeanPropertyAssocMany getManyProperty(SpiQuery query) { OrmQueryDetail detail = query.getDetail(); - for (int i = 0; i < propertiesMany.length; i++) { - if (detail.includesPath(propertiesMany[i].getName())) { - return propertiesMany[i]; + for (BeanPropertyAssocMany aPropertiesMany : propertiesMany) { + if (detail.includesPath(aPropertiesMany.getName())) { + return aPropertiesMany; } } @@ -1565,8 +1565,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Creates a new EntityBean. * The parameter isNew controls either this is a new bean (then * {@link BeanPostConstructListener#postCreate(Object)} will be invoked) or - * a reference (then {@link BeanPostLoad#postLoad(Object)} will be invoked - * on first access (lazy load) or immediately (eager load) + * a reference (then {@link BeanPostLoad#postLoad(Object)} will be invoked + * on first access (lazy load) or immediately (eager load) */ @SuppressWarnings("unchecked") public EntityBean createEntityBean(boolean isNew) { @@ -1577,12 +1577,12 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { beanPostConstructListener.autowire(bean); // calls all registered listeners beanPostConstructListener.postConstruct(bean); // calls first the @PostConstruct method and then the listeners } - + if (unloadProperties.length > 0) { // 'unload' any properties initialised in the default constructor EntityBeanIntercept ebi = bean._ebean_getIntercept(); - for (int i = 0; i < unloadProperties.length; i++) { - ebi.setPropertyUnloaded(unloadProperties[i]); + for (int unloadProperty : unloadProperties) { + ebi.setPropertyUnloaded(unloadProperty); } } if (beanPostConstructListener != null && isNew) { @@ -1595,7 +1595,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { throw new PersistenceException(ex); } } - + /** * Creates a new entitybean without invoking {@link BeanPostConstructListener#postCreate(Object)} */ @@ -1938,11 +1938,11 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { // load the List/Set/Map proxy objects (deferred fetching of lists) BeanPropertyAssocMany[] manys = propertiesMany(); - for (int i = 0; i < manys.length; i++) { - if (!ebi.isLoadedProperty(manys[i].getPropertyIndex())) { - BeanCollection ref = manys[i].createReferenceIfNull(bean); + for (BeanPropertyAssocMany many : manys) { + if (!ebi.isLoadedProperty(many.getPropertyIndex())) { + BeanCollection ref = many.createReferenceIfNull(bean); if (ref != null && !ref.isRegisteredWithLoadContext()) { - String path = SplitName.add(prefix, manys[i].getName()); + String path = SplitName.add(prefix, many.getName()); loadContext.register(path, ref); } } @@ -2147,9 +2147,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { public void resetManyProperties(Object dbBean) { EntityBean bean = (EntityBean) dbBean; - for (int i = 0; i < propertiesMany.length; i++) { - if (propertiesMany[i].isCascadeRefresh()) { - propertiesMany[i].resetMany(bean); + for (BeanPropertyAssocMany aPropertiesMany : propertiesMany) { + if (aPropertiesMany.isCascadeRefresh()) { + aPropertiesMany.resetMany(bean); } } } @@ -2600,8 +2600,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Set the embedded owner on any embedded bean properties. */ public void setEmbeddedOwner(EntityBean bean) { - for (int i = 0; i < propertiesEmbedded.length; i++) { - propertiesEmbedded[i].setEmbeddedOwner(bean); + for (BeanPropertyAssocOne aPropertiesEmbedded : propertiesEmbedded) { + aPropertiesEmbedded.setEmbeddedOwner(bean); } } @@ -2624,7 +2624,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { } if (idProperty.isEmbedded()) { - // not using Id generator so just base on isLoaded() + // not using Id generator so just base on isLoaded() return !ebi.isLoaded(); } if (!hasIdValue(ebi.getOwner())) { @@ -2674,8 +2674,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Check for mutable scalar types and mark as dirty if necessary. */ public void checkMutableProperties(EntityBeanIntercept ebi) { - for (int i = 0; i < propertiesMutable.length; i++) { - BeanProperty beanProperty = propertiesMutable[i]; + for (BeanProperty beanProperty : propertiesMutable) { int propertyIndex = beanProperty.getPropertyIndex(); if (!ebi.isDirtyProperty(propertyIndex) && ebi.isLoadedProperty(propertyIndex)) { Object value = beanProperty.getValue(ebi.getOwner()); @@ -2725,14 +2724,14 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Populate the diff for inserts with flattened non-null property values. */ public void diffForInsert(String prefix, Map map, EntityBean newBean) { - for (int i = 0; i < propertiesBaseScalar.length; i++) { - propertiesBaseScalar[i].diffForInsert(prefix, map, newBean); + for (BeanProperty aPropertiesBaseScalar : propertiesBaseScalar) { + aPropertiesBaseScalar.diffForInsert(prefix, map, newBean); } - for (int i = 0; i < propertiesOne.length; i++) { - propertiesOne[i].diffForInsert(prefix, map, newBean); + for (BeanPropertyAssocOne aPropertiesOne : propertiesOne) { + aPropertiesOne.diffForInsert(prefix, map, newBean); } - for (int i = 0; i < propertiesEmbedded.length; i++) { - propertiesEmbedded[i].diffForInsert(prefix, map, newBean); + for (BeanPropertyAssocOne aPropertiesEmbedded : propertiesEmbedded) { + aPropertiesEmbedded.diffForInsert(prefix, map, newBean); } } @@ -2750,14 +2749,14 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ public void diff(String prefix, Map map, EntityBean newBean, EntityBean oldBean) { - for (int i = 0; i < propertiesBaseScalar.length; i++) { - propertiesBaseScalar[i].diff(prefix, map, newBean, oldBean); + for (BeanProperty aPropertiesBaseScalar : propertiesBaseScalar) { + aPropertiesBaseScalar.diff(prefix, map, newBean, oldBean); } - for (int i = 0; i < propertiesOne.length; i++) { - propertiesOne[i].diff(prefix, map, newBean, oldBean); + for (BeanPropertyAssocOne aPropertiesOne : propertiesOne) { + aPropertiesOne.diff(prefix, map, newBean, oldBean); } - for (int i = 0; i < propertiesEmbedded.length; i++) { - propertiesEmbedded[i].diff(prefix, map, newBean, oldBean); + for (BeanPropertyAssocOne aPropertiesEmbedded : propertiesEmbedded) { + aPropertiesEmbedded.diff(prefix, map, newBean, oldBean); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java index 9cba445a0..888ad0d71 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java @@ -125,8 +125,8 @@ final class BeanDescriptorCacheHelp { * that does have bean caching enabled. */ private boolean isNotifyOnDeletes() { - for (int i = 0; i < propertiesOneImported.length; i++) { - if (propertiesOneImported[i].isCacheNotify()) { + for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { + if (aPropertiesOneImported.isCacheNotify()) { return true; } } @@ -264,8 +264,7 @@ final class BeanDescriptorCacheHelp { List idList = entry.getIdList(); bc.checkEmptyLazyLoad(); - for (int i = 0; i < idList.size(); i++) { - Object id = idList.get(i); + for (Object id : idList) { Object refBean = targetDescriptor.createReference(readOnly, false, id, persistenceContext); many.add(bc, (EntityBean) refBean); } @@ -320,7 +319,7 @@ final class BeanDescriptorCacheHelp { // check if it is a find by unique id (using the natural key) NaturalKeyBindParam keyBindParam = query.getNaturalKeyBindParam(); if (keyBindParam == null || !isNaturalKey(keyBindParam.getName())) { - // query is not appropriate + // query is not appropriate return null; } @@ -545,8 +544,8 @@ final class BeanDescriptorCacheHelp { } beanCache.remove(id); } - for (int i = 0; i < propertiesOneImported.length; i++) { - propertiesOneImported[i].cacheClear(); + for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { + aPropertiesOneImported.cacheClear(); } } @@ -608,8 +607,8 @@ final class BeanDescriptorCacheHelp { } private void cacheDeleteImported(boolean clear, EntityBean entityBean, CacheChangeSet changeSet) { - for (int i = 0; i < propertiesOneImported.length; i++) { - propertiesOneImported[i].cacheDelete(clear, entityBean, changeSet); + for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { + aPropertiesOneImported.cacheDelete(clear, entityBean, changeSet); } } @@ -627,8 +626,7 @@ final class BeanDescriptorCacheHelp { List> manyCollections = updateRequest.getUpdatedManyCollections(); if (manyCollections != null) { - for (int i = 0; i < manyCollections.size(); i++) { - BeanPropertyAssocMany many = manyCollections.get(i); + for (BeanPropertyAssocMany many : manyCollections) { Object details = many.getValue(updateRequest.getEntityBean()); CachedManyIds entry = createManyIds(many, details); if (entry != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java index a3e26d057..70f35ec56 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java @@ -85,14 +85,14 @@ public final class BeanDescriptorDraftHelp { } BeanProperty[] props = desc.propertiesNonMany(); - for (int i = 0; i < props.length; i++) { - props[i].publish(draft, live); + for (BeanProperty prop : props) { + prop.publish(draft, live); } BeanPropertyAssocMany[] many = desc.propertiesMany(); - for (int i = 0; i < many.length; i++) { - if (many[i].getTargetDescriptor().isDraftable()) { - many[i].publishMany(draft, live); + for (BeanPropertyAssocMany aMany : many) { + if (aMany.getTargetDescriptor().isDraftable()) { + aMany.publishMany(draft, live); } } @@ -105,16 +105,16 @@ public final class BeanDescriptorDraftHelp { public void draftQueryOptimise(Query query) { BeanPropertyAssocOne[] one = desc.propertiesOne(); - for (int i = 0; i < one.length; i++) { - if (one[i].getTargetDescriptor().isDraftableElement()) { - query.fetch(one[i].getName()); + for (BeanPropertyAssocOne anOne : one) { + if (anOne.getTargetDescriptor().isDraftableElement()) { + query.fetch(anOne.getName()); } } BeanPropertyAssocMany[] many = desc.propertiesMany(); - for (int i = 0; i < many.length; i++) { - if (many[i].getTargetDescriptor().isDraftableElement()) { - query.fetch(many[i].getName()); + for (BeanPropertyAssocMany aMany : many) { + if (aMany.getTargetDescriptor().isDraftableElement()) { + query.fetch(aMany.getName()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java index 7046cee77..6dbf2e357 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java @@ -63,9 +63,9 @@ public class BeanDescriptorJsonHelp { writeJson.writeStartObject(null); // render the dirty properties BeanProperty[] props = desc.propertiesNonTransient(); - for (int j = 0; j < props.length; j++) { - if (dirtyProps[props[j].getPropertyIndex()]) { - props[j].jsonWrite(writeJson, bean); + for (BeanProperty prop : props) { + if (dirtyProps[prop.getPropertyIndex()]) { + prop.jsonWrite(writeJson, bean); } } writeJson.writeEndObject(); @@ -103,7 +103,7 @@ public class BeanDescriptorJsonHelp { String propName = parser.getCurrentName(); if (!propName.equalsIgnoreCase(discColumn)) { - // just try to assume this is the correct bean type in the inheritance + // just try to assume this is the correct bean type in the inheritance BeanProperty property = desc.getBeanProperty(propName); if (property != null) { EntityBean bean = desc.createEntityBean(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java index 478dd2cc8..a153569ba 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -423,15 +423,15 @@ public class BeanDescriptorManager implements BeanDescriptorMap { List> normalBeanTypes = tableToDescMap.get(tableName); if (normalBeanTypes != null) { // 'normal' entity beans based on a "base table" - for (int i = 0; i < normalBeanTypes.size(); i++) { - normalBeanTypes.get(i).cacheHandleBulkUpdate(tableIUD); + for (BeanDescriptor normalBeanType : normalBeanTypes) { + normalBeanType.cacheHandleBulkUpdate(tableIUD); } } List> viewBeans = tableToViewDescMap.get(tableName); if (viewBeans != null) { // entity beans based on a "view" - for (int i = 0; i < viewBeans.size(); i++) { - viewBeans.get(i).cacheHandleBulkUpdate(tableIUD); + for (BeanDescriptor viewBean : viewBeans) { + viewBean.cacheHandleBulkUpdate(tableIUD); } } } @@ -458,8 +458,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { for (String depTable : viewInvalidation) { List> list = tableToViewDescMap.get(depTable.toLowerCase()); if (list != null) { - for (int i = 0; i < list.size(); i++) { - list.get(i).queryCacheClear(); + for (BeanDescriptor aList : list) { + aList.queryCacheClear(); } } } @@ -663,8 +663,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private void readEmbeddedDeployment() { List> embeddedClasses = bootupClasses.getEmbeddables(); - for (int i = 0; i < embeddedClasses.size(); i++) { - registerBeanDescriptor(createEmbedded(embeddedClasses.get(i))); + for (Class embeddedClass : embeddedClasses) { + registerBeanDescriptor(createEmbedded(embeddedClass)); } } @@ -1395,8 +1395,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { boolean hasVersionProperty = false; List props = desc.propertiesBase(); - for (int i = 0; i < props.size(); i++) { - if (props.get(i).isVersionColumn()) { + for (DeployBeanProperty prop : props) { + if (prop.isVersionColumn()) { hasVersionProperty = true; } } @@ -1407,8 +1407,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private boolean hasEntityBeanInterface(Class beanClass) { Class[] interfaces = beanClass.getInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - if (interfaces[i].equals(EntityBean.class)) { + for (Class anInterface : interfaces) { + if (anInterface.equals(EntityBean.class)) { return true; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanFinderManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanFinderManager.java index a50bd8fe3..c3b65060f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanFinderManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanFinderManager.java @@ -30,8 +30,7 @@ public class BeanFinderManager { */ public void addFindControllers(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanFindController c = list.get(i); + for (BeanFindController c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanFindController on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.setBeanFinder(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java index 6b091e0b8..1bc6c474e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java @@ -176,8 +176,8 @@ public class BeanLifecycleAdapterFactory { } private void invoke(Method[] methods, BeanPersistRequest request) { - for (int i = 0; i < methods.length; i++) { - invoke(methods[i], request.getBean()); + for (Method method : methods) { + invoke(method, request.getBean()); } } @@ -242,12 +242,12 @@ public class BeanLifecycleAdapterFactory { @Override public void postLoad(Object bean) { - for (int i = 0; i < postLoadMethods.length; i++) { - invoke(postLoadMethods[i], bean); + for (Method postLoadMethod : postLoadMethods) { + invoke(postLoadMethod, bean); } } } - + /** * PostConstructAdapter using reflection to invoke lifecycle methods. */ @@ -275,8 +275,8 @@ public class BeanLifecycleAdapterFactory { @Override public void postConstruct(Object bean) { - for (int i = 0; i < postConstructMethods.length; i++) { - invoke(postConstructMethods[i], bean); + for (Method postConstructMethod : postConstructMethods) { + invoke(postConstructMethod, bean); } } @@ -284,7 +284,7 @@ public class BeanLifecycleAdapterFactory { public void autowire(Object bean) { // autowire is done by global PostConstructListener only } - + @Override public void postCreate(Object bean) { // postCreate is done by global PostConstructListener only diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java index 6cd4cd0f0..8745568f2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java @@ -146,8 +146,8 @@ public final class BeanListHelp implements BeanCollectionHelp { if (!list.isEmpty() || ctx.isIncludeEmpty()) { ctx.beginAssocMany(name); - for (int j = 0; j < list.size(); j++) { - targetDescriptor.jsonWrite(ctx, (EntityBean) list.get(j)); + for (Object aList : list) { + targetDescriptor.jsonWrite(ctx, (EntityBean) aList); } ctx.endAssocMany(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java index 24cfb38eb..2e85c8377 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java @@ -362,8 +362,8 @@ public abstract class BeanPropertyAssoc extends BeanProperty { ArrayList list = new ArrayList<>(); - for (int i = 0; i < cols.length; i++) { - list.add(createImportedScalar(owner, cols[i], props, others)); + for (TableJoinColumn col : cols) { + list.add(createImportedScalar(owner, col, props, others)); } return ImportedIdSimple.sort(list); @@ -399,8 +399,8 @@ public abstract class BeanPropertyAssoc extends BeanProperty { } else { EntityBean parent = (EntityBean) parentId; - for (int i = 0; i < exportedProperties.length; i++) { - Object embVal = exportedProperties[i].getValue(parent); + for (ExportedProperty exportedProperty : exportedProperties) { + Object embVal = exportedProperty.getValue(parent); bindValues.add(embVal); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java index 79a5eec7c..1ef618e42 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java @@ -376,8 +376,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { String expr = rawWhere + inClause; List bindValues = new ArrayList<>(); - for (int i = 0; i < parentIdList.size(); i++) { - bindWhereParentId(bindValues, parentIdList.get(i)); + for (Object aParentIdList : parentIdList) { + bindWhereParentId(bindValues, aParentIdList); } EbeanServer server = getBeanDescriptor().getEbeanServer(); @@ -403,8 +403,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { sb.append(inClause); DefaultSqlUpdate delete = new DefaultSqlUpdate(sb.toString()); - for (int i = 0; i < parentIdist.size(); i++) { - bindWhereParendId(delete, parentIdist.get(i)); + for (Object aParentIdist : parentIdist) { + bindWhereParendId(delete, aParentIdist); } return delete; @@ -668,10 +668,10 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { return parentIds; } List expandedList = new ArrayList<>(parentIds.size() * exportedProperties.length); - for (int i = 0; i < parentIds.size(); i++) { - for (int y = 0; y < exportedProperties.length; y++) { - Object compId = parentIds.get(i); - expandedList.add(exportedProperties[y].getValue((EntityBean) compId)); + for (Object parentId : parentIds) { + for (ExportedProperty exportedProperty : exportedProperties) { + Object compId = parentId; + expandedList.add(exportedProperty.getValue((EntityBean) compId)); } } return expandedList; @@ -684,8 +684,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { return; } EntityBean parent = (EntityBean) parentId; - for (int i = 0; i < exportedProperties.length; i++) { - Object embVal = exportedProperties[i].getValue(parent); + for (ExportedProperty exportedProperty : exportedProperties) { + Object embVal = exportedProperty.getValue(parent); sqlUpd.addParameter(embVal); } } @@ -696,8 +696,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { if (alias == null) { alias = "t0"; } - for (int i = 0; i < exportedProperties.length; i++) { - ctx.appendColumn(alias, exportedProperties[i].getForeignDbColumn()); + for (ExportedProperty exportedProperty : exportedProperties) { + ctx.appendColumn(alias, exportedProperty.getForeignDbColumn()); } } @@ -779,8 +779,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { BeanDescriptor targetDesc = one.getTargetDescriptor(); BeanProperty[] emIds = targetDesc.propertiesBaseScalar(); try { - for (int i = 0; i < emIds.length; i++) { - ExportedProperty expProp = findMatch(true, emIds[i]); + for (BeanProperty emId : emIds) { + ExportedProperty expProp = findMatch(true, emId); list.add(expProp); } } catch (PersistenceException e) { @@ -816,11 +816,11 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { columns = tableJoin.columns(); searchTable = tableJoin.getTable(); } - for (int i = 0; i < columns.length; i++) { - String matchTo = columns[i].getLocalDbColumn(); + for (TableJoinColumn column : columns) { + String matchTo = column.getLocalDbColumn(); if (matchColumn.equalsIgnoreCase(matchTo)) { - String foreignCol = columns[i].getForeignDbColumn(); + String foreignCol = column.getForeignDbColumn(); return new ExportedProperty(embedded, foreignCol, prop); } } @@ -849,8 +849,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { BeanDescriptor targetDesc = getTargetDescriptor(); BeanPropertyAssocOne[] ones = targetDesc.propertiesOne(); - for (int i = 0; i < ones.length; i++) { - BeanPropertyAssocOne prop = ones[i]; + for (BeanPropertyAssocOne prop : ones) { if (mappedBy != null) { // match using mappedBy as property name if (mappedBy.equalsIgnoreCase(prop.getName())) { @@ -935,9 +934,9 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { BeanProperty idProp = descriptor.getIdProperty(); parentBean = (EntityBean) idProp.getValue(parentBean); } - for (int i = 0; i < exportedProperties.length; i++) { - Object val = exportedProperties[i].getValue(parentBean); - String fkColumn = exportedProperties[i].getForeignDbColumn(); + for (ExportedProperty exportedProperty : exportedProperties) { + Object val = exportedProperty.getValue(parentBean); + String fkColumn = exportedProperty.getForeignDbColumn(); row.put(fkColumn, val); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java index 51f606895..66b57efed 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java @@ -79,8 +79,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { BeanEmbeddedMeta overrideMeta = BeanEmbeddedMetaFactory.create(owner, deploy); embeddedProps = overrideMeta.getProperties(); embeddedPropsMap = new HashMap<>(); - for (int i = 0; i < embeddedProps.length; i++) { - embeddedPropsMap.put(embeddedProps[i].getName(), embeddedProps[i]); + for (BeanProperty embeddedProp : embeddedProps) { + embeddedPropsMap.put(embeddedProp.getName(), embeddedProp); } } else { @@ -208,8 +208,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { sb.append(inClause); DefaultSqlUpdate delete = new DefaultSqlUpdate(sb.toString()); - for (int i = 0; i < parentIdist.size(); i++) { - targetIdBinder.bindId(delete, parentIdist.get(i)); + for (Object aParentIdist : parentIdist) { + targetIdBinder.bindId(delete, aParentIdist); } return delete; @@ -258,8 +258,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { String expr = rawWhere + inClause; List bindValues = new ArrayList<>(); - for (int i = 0; i < parentIdList.size(); i++) { - bindWhereParentId(bindValues, parentIdList.get(i)); + for (Object aParentIdList : parentIdList) { + bindWhereParentId(bindValues, aParentIdList); } EbeanServer server = getBeanDescriptor().getEbeanServer(); @@ -301,8 +301,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { targetIdBinder.buildRawSqlSelectChain(prefix, selectChain); } else { - for (int i = 0; i < embeddedProps.length; i++) { - embeddedProps[i].buildRawSqlSelectChain(prefix, selectChain); + for (BeanProperty embeddedProp : embeddedProps) { + embeddedProp.buildRawSqlSelectChain(prefix, selectChain); } } } @@ -514,8 +514,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { BeanDescriptor targetDesc = one.getTargetDescriptor(); BeanProperty[] emIds = targetDesc.propertiesBaseScalar(); try { - for (int i = 0; i < emIds.length; i++) { - ExportedProperty expProp = findMatch(true, emIds[i]); + for (BeanProperty emId : emIds) { + ExportedProperty expProp = findMatch(true, emId); list.add(expProp); } } catch (PersistenceException e) { @@ -543,11 +543,11 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { String searchTable = tableJoin.getTable(); TableJoinColumn[] columns = tableJoin.columns(); - for (int i = 0; i < columns.length; i++) { - String matchTo = columns[i].getLocalDbColumn(); + for (TableJoinColumn column : columns) { + String matchTo = column.getLocalDbColumn(); if (matchColumn.equalsIgnoreCase(matchTo)) { - String foreignCol = columns[i].getForeignDbColumn(); + String foreignCol = column.getForeignDbColumn(); return new ExportedProperty(embeddedProp, foreignCol, prop); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java index 8127ce025..57ff681c2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java @@ -46,14 +46,13 @@ public class BeanPropertyCompound extends BeanProperty { BeanPropertyCompoundRoot root = deploy.getFlatProperties(); this.scalarProperties = root.getScalarProperties(); - for (int i = 0; i < scalarProperties.length; i++) { - propertyMap.put(scalarProperties[i].getName(), scalarProperties[i]); + for (BeanProperty scalarProperty : scalarProperties) { + propertyMap.put(scalarProperty.getName(), scalarProperty); } List nonScalarPropsList = root.getNonScalarProperties(); - for (int i = 0; i < nonScalarPropsList.size(); i++) { - CtCompoundProperty ctProp = nonScalarPropsList.get(i); + for (CtCompoundProperty ctProp : nonScalarPropsList) { CtCompoundPropertyElAdapter adapter = new CtCompoundPropertyElAdapter(ctProp); nonScalarMap.put(ctProp.getRelativeName(), adapter); } @@ -102,8 +101,8 @@ public class BeanPropertyCompound extends BeanProperty { @Override public void appendSelect(DbSqlContext ctx, boolean subQuery) { if (!isTransient) { - for (int i = 0; i < scalarProperties.length; i++) { - scalarProperties[i].appendSelect(ctx, subQuery); + for (BeanProperty scalarProperty : scalarProperties) { + scalarProperty.appendSelect(ctx, subQuery); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanQueryAdapterManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanQueryAdapterManager.java index b936781c1..4b54c62c9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanQueryAdapterManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanQueryAdapterManager.java @@ -31,8 +31,7 @@ public class BeanQueryAdapterManager { */ public void addQueryAdapter(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanQueryAdapter c = list.get(i); + for (BeanQueryAdapter c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanQueryAdapter on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.addQueryAdapter(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java index f52116158..6e4a0f4ed 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java @@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory; public class BeanTable { private static final Logger logger = LoggerFactory.getLogger(BeanTable.class); - + private final Class beanType; /** @@ -29,7 +29,7 @@ public class BeanTable { private final String baseTable; private final BeanProperty[] idProperties; - + /** * Create the BeanTable. */ @@ -38,11 +38,11 @@ public class BeanTable { this.baseTable = InternString.intern(mutable.getBaseTable()); this.idProperties = mutable.createIdProperties(owner); } - + public String toString(){ - return baseTable; + return baseTable; } - + /** * Return the base table for this BeanTable. * This is used to determine the join information @@ -51,17 +51,17 @@ public class BeanTable { public String getBaseTable() { return baseTable; } - + /** * Gets the unqualified base table. - * + * * @return the unqualified base table */ public String getUnqualifiedBaseTable(){ final String[] chunks = baseTable.split("\\."); return chunks.length == 2 ? chunks[1] :chunks[0]; } - + /** * Return the Id properties. */ @@ -75,12 +75,12 @@ public class BeanTable { public Class getBeanType() { return beanType; } - + public void createJoinColumn(String foreignKeyPrefix, DeployTableJoin join, boolean reverse) { - + boolean complexKey = false; BeanProperty[] props = idProperties; - + if (idProperties.length == 1){ if (idProperties[0] instanceof BeanPropertyAssocOne) { BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne)idProperties[0]; @@ -88,30 +88,30 @@ public class BeanTable { complexKey = true; } } - - for (int i = 0; i < props.length; i++) { - - String lc = props[i].getDbColumn(); - String fk = lc; - if (foreignKeyPrefix != null){ - fk = foreignKeyPrefix+"_"+fk; - } - - if (complexKey){ - // just to copy the column name rather than prefix with the foreignKeyPrefix. - // I think that with complex keys this is the more common approach. - String msg = "On table["+baseTable+"] foreign key column ["+lc+"]"; - logger.debug(msg); - fk = lc; - } - - DeployTableJoinColumn joinCol = new DeployTableJoinColumn(lc, fk); - if (reverse){ - joinCol = joinCol.reverse(); - } - join.addJoinColumn(joinCol); - } - + + for (BeanProperty prop : props) { + + String lc = prop.getDbColumn(); + String fk = lc; + if (foreignKeyPrefix != null) { + fk = foreignKeyPrefix + "_" + fk; + } + + if (complexKey) { + // just to copy the column name rather than prefix with the foreignKeyPrefix. + // I think that with complex keys this is the more common approach. + String msg = "On table[" + baseTable + "] foreign key column [" + lc + "]"; + logger.debug(msg); + fk = lc; + } + + DeployTableJoinColumn joinCol = new DeployTableJoinColumn(lc, fk); + if (reverse) { + joinCol = joinCol.reverse(); + } + join.addJoinColumn(joinCol); + } + } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java index cf565d1a5..941f59023 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java @@ -16,18 +16,18 @@ import java.util.List; public class ChainedBeanPersistController implements BeanPersistController { private static final Sorter SORTER = new Sorter(); - + private final List list; private final BeanPersistController[] chain; - + /** * Construct adding 2 BeanPersistController's. */ public ChainedBeanPersistController(BeanPersistController c1, BeanPersistController c2) { this(addList(c1, c2)); } - + /** * Helper method used to create a list from 2 BeanPersistController's. */ @@ -37,7 +37,7 @@ public class ChainedBeanPersistController implements BeanPersistController { addList.add(c2); return addList; } - + /** * Construct given the list of BeanPersistController's. */ @@ -65,11 +65,11 @@ public class ChainedBeanPersistController implements BeanPersistController { ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.add(c); - + return new ChainedBeanPersistController(newList); } } - + /** * De-register a BeanPersistController and return the resulting chain. */ @@ -80,11 +80,11 @@ public class ChainedBeanPersistController implements BeanPersistController { ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); - + return new ChainedBeanPersistController(newList); } } - + /** * Always returns 0 (not used for this object). */ @@ -103,69 +103,69 @@ public class ChainedBeanPersistController implements BeanPersistController { @Override public void postDelete(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - chain[i].postDelete(request); - } + for (BeanPersistController aChain : chain) { + aChain.postDelete(request); + } } @Override public void postInsert(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - chain[i].postInsert(request); - } + for (BeanPersistController aChain : chain) { + aChain.postInsert(request); + } } @Override public void postUpdate(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - chain[i].postUpdate(request); - } + for (BeanPersistController aChain : chain) { + aChain.postUpdate(request); + } } @Override public void postSoftDelete(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - chain[i].postSoftDelete(request); - } + for (BeanPersistController aChain : chain) { + aChain.postSoftDelete(request); + } } @Override public boolean preDelete(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - if (!chain[i].preDelete(request)) { - return false; - } - } + for (BeanPersistController aChain : chain) { + if (!aChain.preDelete(request)) { + return false; + } + } return true; } @Override public boolean preSoftDelete(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - if (!chain[i].preSoftDelete(request)) { - return false; - } - } + for (BeanPersistController aChain : chain) { + if (!aChain.preSoftDelete(request)) { + return false; + } + } return true; } @Override public boolean preInsert(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - if (!chain[i].preInsert(request)) { - return false; - } - } + for (BeanPersistController aChain : chain) { + if (!aChain.preInsert(request)) { + return false; + } + } return true; } @Override public boolean preUpdate(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - if (!chain[i].preUpdate(request)) { - return false; - } - } + for (BeanPersistController aChain : chain) { + if (!aChain.preUpdate(request)) { + return false; + } + } return true; } @@ -175,11 +175,11 @@ public class ChainedBeanPersistController implements BeanPersistController { private static class Sorter implements Comparator { public int compare(BeanPersistController o1, BeanPersistController o2) { - + int i1 = o1.getExecutionOrder() ; int i2 = o2.getExecutionOrder() ; return (i1 list; - + private final BeanPersistListener[] chain; - + /** * Construct adding 2 BeanPersistListener's. */ @@ -44,7 +44,7 @@ public class ChainedBeanPersistListener implements BeanPersistListener { addList.add(c2); return addList; } - + /** * Construct given the list of BeanPersistListener's. */ @@ -52,7 +52,7 @@ public class ChainedBeanPersistListener implements BeanPersistListener { this.list = list; this.chain = list.toArray(new BeanPersistListener[list.size()]); } - + /** * Register a new BeanPersistListener and return the resulting chain. */ @@ -63,11 +63,11 @@ public class ChainedBeanPersistListener implements BeanPersistListener { List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); - + return new ChainedBeanPersistListener(newList); } } - + /** * De-register a BeanPersistListener and return the resulting chain. */ @@ -78,32 +78,32 @@ public class ChainedBeanPersistListener implements BeanPersistListener { ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); - + return new ChainedBeanPersistListener(newList); } } public void deleted(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].deleted(bean); - } + for (BeanPersistListener aChain : chain) { + aChain.deleted(bean); + } } public void softDeleted(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].softDeleted(bean); - } + for (BeanPersistListener aChain : chain) { + aChain.softDeleted(bean); + } } public void inserted(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].inserted(bean); - } + for (BeanPersistListener aChain : chain) { + aChain.inserted(bean); + } } public void updated(Object bean, Set updatedProperties) { - for (int i = 0; i < chain.length; i++) { - chain[i].updated(bean, updatedProperties); - } + for (BeanPersistListener aChain : chain) { + aChain.updated(bean, updatedProperties); + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java index 58bdb5f1f..b02d4d945 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java @@ -70,22 +70,22 @@ public class ChainedBeanPostConstructListener implements BeanPostConstructListen */ @Override public void postConstruct(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].postConstruct(bean); + for (BeanPostConstructListener aChain : chain) { + aChain.postConstruct(bean); } } @Override public void autowire(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].autowire(bean); + for (BeanPostConstructListener aChain : chain) { + aChain.autowire(bean); } } @Override public void postCreate(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].postCreate(bean); + for (BeanPostConstructListener aChain : chain) { + aChain.postCreate(bean); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java index 9558d86dc..316b054a4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java @@ -21,7 +21,7 @@ public class ChainedBeanPostLoad implements BeanPostLoad { this.list = list; this.chain = list.toArray(new BeanPostLoad[list.size()]); } - + /** * Register a new BeanPostLoad and return the resulting chain. */ @@ -32,11 +32,11 @@ public class ChainedBeanPostLoad implements BeanPostLoad { List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); - + return new ChainedBeanPostLoad(newList); } } - + /** * De-register a BeanPostLoad and return the resulting chain. */ @@ -47,7 +47,7 @@ public class ChainedBeanPostLoad implements BeanPostLoad { ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); - + return new ChainedBeanPostLoad(newList); } } @@ -70,8 +70,8 @@ public class ChainedBeanPostLoad implements BeanPostLoad { */ @Override public void postLoad(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].postLoad(bean); - } + for (BeanPostLoad aChain : chain) { + aChain.postLoad(bean); + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java index 3987ca537..4d609c0bf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java @@ -14,7 +14,7 @@ import com.avaje.ebean.event.BeanQueryRequest; public class ChainedBeanQueryAdapter implements BeanQueryAdapter { private static final Sorter SORTER = new Sorter(); - + private final List list; private final BeanQueryAdapter[] chain; @@ -28,7 +28,7 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { Arrays.sort(c, SORTER); this.chain = c; } - + /** * Register a new BeanQueryAdapter and return the resulting chain. */ @@ -39,11 +39,11 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); - + return new ChainedBeanQueryAdapter(newList); } } - + /** * De-register a BeanQueryAdapter and return the resulting chain. */ @@ -54,12 +54,12 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); - + return new ChainedBeanQueryAdapter(newList); } } - + /** * Return 0 as not used by this Chained adapter. */ @@ -75,10 +75,10 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { } public void preQuery(BeanQueryRequest request) { - - for (int i = 0; i < chain.length; i++) { - chain[i].preQuery(request); - } + + for (BeanQueryAdapter aChain : chain) { + aChain.preQuery(request); + } } /** * Helper to order the BeanQueryAdapter's in a chain. @@ -86,11 +86,11 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { private static class Sorter implements Comparator { public int compare(BeanQueryAdapter o1, BeanQueryAdapter o2) { - + int i1 = o1.getExecutionOrder() ; int i2 = o2.getExecutionOrder() ; return (i1 bindValues = er.getBindValues(); - for (int i = 0; i < bindValues.size(); i++) { - bindParams.setParameter(++count, bindValues.get(i)); + for (Object bindValue : bindValues) { + bindParams.setParameter(++count, bindValue); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ParamTypeUtil.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ParamTypeUtil.java index 992fb2c6f..efdd8518a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ParamTypeUtil.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ParamTypeUtil.java @@ -20,17 +20,17 @@ public class ParamTypeUtil { * @param matchType the type which has the generic parameter */ public static Class findParamType(Class cls, Class matchType) { - + // search for: implementing a generic interface Type paramType = matchByInterfaces(cls, matchType); if (paramType == null){ // search for: extending a generic class Type genericSuperclass = cls.getGenericSuperclass(); if (genericSuperclass != null){ - paramType = matchParamType(genericSuperclass, matchType); + paramType = matchParamType(genericSuperclass, matchType); } } - + if (paramType instanceof Class){ // only interested in classes return (Class)paramType; @@ -38,7 +38,7 @@ public class ParamTypeUtil { return null; } } - + /** * Check if the type is a generic one with parameters and of the correct type we are * searching for. Return the parameter type if this matches otherwise return null. @@ -60,19 +60,19 @@ public class ParamTypeUtil { } return null; } - + /** * Search the interfaces this class implements. */ private static Type matchByInterfaces(Class cls, Class matchType) { - + Type[] gis = cls.getGenericInterfaces(); - for (int i = 0; i < gis.length; i++) { - Type match = matchParamType(gis[i], matchType); - if (match != null){ - return match; - } - } + for (Type gi : gis) { + Type match = matchParamType(gi, matchType); + if (match != null) { + return match; + } + } return null; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistControllerManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistControllerManager.java index 1c5e09e47..c57eec213 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistControllerManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistControllerManager.java @@ -31,8 +31,7 @@ public class PersistControllerManager { */ public void addPersistControllers(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanPersistController c = list.get(i); + for (BeanPersistController c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanPersistController on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.addPersistController(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistListenerManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistListenerManager.java index c1b0f981d..4cc9771e7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistListenerManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistListenerManager.java @@ -31,13 +31,12 @@ public class PersistListenerManager { */ public void addPersistListeners(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanPersistListener listener = list.get(i); + for (BeanPersistListener listener : list) { if (listener.isRegisterFor(deployDesc.getBeanType())) { - logger.debug("BeanPersistListener on[{}] {}", deployDesc.getFullName(), listener.getClass().getName()); - deployDesc.addPersistListener(listener); - } - } + logger.debug("BeanPersistListener on[{}] {}", deployDesc.getFullName(), listener.getClass().getName()); + deployDesc.addPersistListener(listener); + } + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/PostConstructManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/PostConstructManager.java index 8e7a84041..50c879656 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/PostConstructManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/PostConstructManager.java @@ -30,8 +30,7 @@ public class PostConstructManager { */ public void addPostConstructListeners(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanPostConstructListener c = list.get(i); + for (BeanPostConstructListener c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanPostLoad on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.addPostConstructListener(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/PostLoadManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/PostLoadManager.java index c049b8f15..b4288411c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/PostLoadManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/PostLoadManager.java @@ -30,8 +30,7 @@ public class PostLoadManager { */ public void addPostLoad(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanPostLoad c = list.get(i); + for (BeanPostLoad c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanPostLoad on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.addPostLoad(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java index 2c18c2a03..6241519c6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java @@ -22,7 +22,7 @@ public final class TableJoin { private final SqlJoinType type; private final InheritInfo inheritInfo; - + /** * Columns as an array. */ @@ -57,8 +57,8 @@ public final class TableJoin { private int calcQueryHash() { int hc = type.hashCode(); hc = hc * 92821 + (table == null ? 0 : table.hashCode()); - for (int i = 0; i < columns.length; i++) { - hc = hc * 92821 + columns[i].queryHash(); + for (TableJoinColumn column : columns) { + hc = hc * 92821 + column.queryHash(); } return hc; } @@ -99,8 +99,8 @@ public final class TableJoin { public String toString() { StringBuilder sb = new StringBuilder(30); sb.append(type).append(" ").append(table).append(" "); - for (int i = 0; i < columns.length; i++) { - sb.append(columns[i]).append(" "); + for (TableJoinColumn column : columns) { + sb.append(column).append(" "); } return sb.toString(); } @@ -141,8 +141,8 @@ public final class TableJoin { String joinLiteral = joinType.getLiteral(type); ctx.addJoin(joinLiteral, table, columns(), a1, a2, inheritance); - + return joinType.autoToOuter(type); } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java index 9c421b652..6576e3c7b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java @@ -117,15 +117,15 @@ public final class IdBinderEmbedded implements IdBinder { prefix = SplitName.add(prefix, embIdProperty.getName()); - for (int i = 0; i < props.length; i++) { - props[i].buildRawSqlSelectChain(prefix, selectChain); + for (BeanProperty prop : props) { + prop.buildRawSqlSelectChain(prefix, selectChain); } } public BeanProperty findBeanProperty(String dbColumnName) { - for (int i = 0; i < props.length; i++) { - if (dbColumnName.equalsIgnoreCase(props[i].getDbColumn())) { - return props[i]; + for (BeanProperty prop : props) { + if (dbColumnName.equalsIgnoreCase(prop.getDbColumn())) { + return prop; } } return null; @@ -156,8 +156,8 @@ public final class IdBinderEmbedded implements IdBinder { } public void addIdInBindValue(SpiExpressionRequest request, Object value) { - for (int i = 0; i < props.length; i++) { - request.addBindValue(props[i].getValue((EntityBean) value)); + for (BeanProperty prop : props) { + request.addBindValue(prop.getValue((EntityBean) value)); } } @@ -235,8 +235,8 @@ public final class IdBinderEmbedded implements IdBinder { EntityBean ebValue = (EntityBean)embIdProperty.getValue(bean); Map map = new LinkedHashMap<>(); - for (int i = 0; i < props.length; i++) { - map.put(props[i].getName(), props[i].getValue(ebValue)); + for (BeanProperty prop : props) { + map.put(prop.getName(), prop.getValue(ebValue)); } return map; } @@ -250,26 +250,26 @@ public final class IdBinderEmbedded implements IdBinder { Map map = (Map)value; EntityBean idValue = idDesc.createEntityBean(); - for (int i = 0; i < props.length; i++) { - Object val = map.get(props[i].getName()); - props[i].setValue(idValue, val); + for (BeanProperty prop : props) { + Object val = map.get(prop.getName()); + prop.setValue(idValue, val); } return idValue; } public void bindId(DefaultSqlUpdate sqlUpdate, Object value) { - for (int i = 0; i < props.length; i++) { - Object embFieldValue = props[i].getValue((EntityBean) value); + for (BeanProperty prop : props) { + Object embFieldValue = prop.getValue((EntityBean) value); sqlUpdate.addParameter(embFieldValue); } } public void bindId(DataBind dataBind, Object value) throws SQLException { - for (int i = 0; i < props.length; i++) { - Object embFieldValue = props[i].getValue((EntityBean) value); - props[i].bind(dataBind, embFieldValue); + for (BeanProperty prop : props) { + Object embFieldValue = prop.getValue((EntityBean) value); + prop.bind(dataBind, embFieldValue); } } @@ -278,9 +278,9 @@ public final class IdBinderEmbedded implements IdBinder { EntityBean embId = idDesc.createEntityBean(); boolean notNull = true; - for (int i = 0; i < props.length; i++) { - Object value = props[i].readData(dataInput); - props[i].setValue(embId, value); + for (BeanProperty prop : props) { + Object value = prop.readData(dataInput); + prop.setValue(embId, value); if (value == null) { notNull = false; } @@ -294,15 +294,15 @@ public final class IdBinderEmbedded implements IdBinder { } public void writeData(DataOutput dataOutput, Object idValue) throws IOException { - for (int i = 0; i < props.length; i++) { - Object embFieldValue = props[i].getValue((EntityBean) idValue); - props[i].writeData(dataOutput, embFieldValue); + for (BeanProperty prop : props) { + Object embFieldValue = prop.getValue((EntityBean) idValue); + prop.writeData(dataOutput, embFieldValue); } } public void loadIgnore(DbReadContext ctx) { - for (int i = 0; i < props.length; i++) { - props[i].loadIgnore(ctx); + for (BeanProperty prop : props) { + prop.loadIgnore(ctx); } } @@ -311,8 +311,8 @@ public final class IdBinderEmbedded implements IdBinder { EntityBean embId = idDesc.createEntityBean(); boolean notNull = true; - for (int i = 0; i < props.length; i++) { - Object value = props[i].readSet(ctx, embId); + for (BeanProperty prop : props) { + Object value = prop.readSet(ctx, embId); if (value == null) { notNull = false; } @@ -337,8 +337,8 @@ public final class IdBinderEmbedded implements IdBinder { } public void appendSelect(DbSqlContext ctx, boolean subQuery) { - for (int i = 0; i < props.length; i++) { - props[i].appendSelect(ctx, subQuery); + for (BeanProperty prop : props) { + prop.appendSelect(ctx, subQuery); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java index 099315d9b..dc29e59b3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java @@ -52,15 +52,15 @@ public class ImportedIdEmbedded implements ImportedId { } public void sqlAppend(DbSqlContext ctx) { - for (int i = 0; i < imported.length; i++) { - ctx.appendColumn(imported[i].localDbColumn); + for (ImportedIdSimple anImported : imported) { + ctx.appendColumn(anImported.localDbColumn); } } public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < imported.length; i++) { - request.appendColumn(imported[i].localDbColumn); + for (ImportedIdSimple anImported : imported) { + request.appendColumn(anImported.localDbColumn); } } @@ -83,9 +83,9 @@ public class ImportedIdEmbedded implements ImportedId { int pos = position; EntityBean embedded = (EntityBean) foreignAssocOne.getValue(bean); - for (int i = 0; i < imported.length; i++) { - if (imported[i].owner.isUpdateable()) { - Object scalarValue = imported[i].foreignProperty.getValue(embedded); + for (ImportedIdSimple anImported : imported) { + if (anImported.owner.isUpdateable()) { + Object scalarValue = anImported.foreignProperty.getValue(embedded); update.setParameter(pos++, scalarValue); } } @@ -101,18 +101,18 @@ public class ImportedIdEmbedded implements ImportedId { } if (embeddedId == null) { - for (int i = 0; i < imported.length; i++) { - if (imported[i].owner.isUpdateable()) { - request.bind(null, imported[i].foreignProperty); + for (ImportedIdSimple anImported : imported) { + if (anImported.owner.isUpdateable()) { + request.bind(null, anImported.foreignProperty); } } } else { EntityBean embedded = (EntityBean) embeddedId; - for (int i = 0; i < imported.length; i++) { - if (imported[i].owner.isUpdateable()) { - Object scalarValue = imported[i].foreignProperty.getValue(embedded); - request.bind(scalarValue, imported[i].foreignProperty); + for (ImportedIdSimple anImported : imported) { + if (anImported.owner.isUpdateable()) { + Object scalarValue = anImported.foreignProperty.getValue(embedded); + request.bind(scalarValue, anImported.foreignProperty); } } } @@ -128,9 +128,9 @@ public class ImportedIdEmbedded implements ImportedId { throw new PersistenceException(msg); } - for (int i = 0; i < imported.length; i++) { - Object scalarValue = imported[i].foreignProperty.getValue(embeddedId); - row.put(imported[i].localDbColumn, scalarValue); + for (ImportedIdSimple anImported : imported) { + Object scalarValue = anImported.foreignProperty.getValue(embeddedId); + row.put(anImported.localDbColumn, scalarValue); } } @@ -140,8 +140,8 @@ public class ImportedIdEmbedded implements ImportedId { */ public BeanProperty findMatchImport(String matchDbColumn) { - for (int i = 0; i < imported.length; i++) { - BeanProperty p = imported[i].findMatchImport(matchDbColumn); + for (ImportedIdSimple anImported : imported) { + BeanProperty p = anImported.findMatchImport(matchDbColumn); if (p != null) { return p; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java index 37041ab4b..8d254e445 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java @@ -302,8 +302,8 @@ public class DeployBeanDescriptor { public boolean isScalaObject() { Class[] interfaces = beanType.getInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - String iname = interfaces[i].getName(); + for (Class anInterface : interfaces) { + String iname = anInterface.getName(); if (I_SCALAOBJECT.equals(iname)) { return true; } @@ -546,7 +546,7 @@ public class DeployBeanDescriptor { return new ChainedBeanPostConstructListener(postConstructListeners); } } - + public void addPersistController(BeanPersistController controller) { persistControllers.add(controller); } @@ -566,7 +566,7 @@ public class DeployBeanDescriptor { public void addPostConstructListener(BeanPostConstructListener postConstructListener) { postConstructListeners.add(postConstructListener); } - + public String getDraftTable() { return draftTable; } @@ -635,8 +635,8 @@ public class DeployBeanDescriptor { Collections.sort(list, PROP_ORDER); propMap = new LinkedHashMap<>(list.size()); - for (int i = 0; i < list.size(); i++) { - addBeanProperty(list.get(i)); + for (DeployBeanProperty aList : list) { + addBeanProperty(aList); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java index 57fef0ec5..3c055d507 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java @@ -42,7 +42,7 @@ public class DeployBeanPropertyLists { private final List mutable = new ArrayList<>(); private final List> manys = new ArrayList<>(); - + private final List nonManys = new ArrayList<>(); private final List> ones = new ArrayList<>(); @@ -179,7 +179,7 @@ public class DeployBeanPropertyLists { if (prop.isMutableScalarType()) { mutable.add(prop); } - + if (desc.getInheritInfo() != null && prop.isLocal()) { local.add(prop); } @@ -349,22 +349,21 @@ public class DeployBeanPropertyLists { private BeanPropertyAssocOne[] getOne(boolean imported, Mode mode) { ArrayList> list = new ArrayList<>(); - for (int i = 0; i < ones.size(); i++) { - BeanPropertyAssocOne prop = ones.get(i); + for (BeanPropertyAssocOne prop : ones) { if (imported != prop.isOneToOneExported()) { switch (mode) { - case Save: - if (prop.getCascadeInfo().isSave()) { - list.add(prop); - } - break; - case Delete: - if (prop.getCascadeInfo().isDelete()) { - list.add(prop); - } - break; - default: - break; + case Save: + if (prop.getCascadeInfo().isSave()) { + list.add(prop); + } + break; + case Delete: + if (prop.getCascadeInfo().isDelete()) { + list.add(prop); + } + break; + default: + break; } } } @@ -374,8 +373,7 @@ public class DeployBeanPropertyLists { private BeanPropertyAssocMany[] getMany2Many() { ArrayList> list = new ArrayList<>(); - for (int i = 0; i < manys.size(); i++) { - BeanPropertyAssocMany prop = manys.get(i); + for (BeanPropertyAssocMany prop : manys) { if (prop.isManyToMany()) { list.add(prop); } @@ -386,27 +384,25 @@ public class DeployBeanPropertyLists { private BeanPropertyAssocMany[] getMany(Mode mode) { ArrayList> list = new ArrayList<>(); - for (int i = 0; i < manys.size(); i++) { - BeanPropertyAssocMany prop = manys.get(i); - + for (BeanPropertyAssocMany prop : manys) { switch (mode) { - case Save: - if (prop.getCascadeInfo().isSave() || prop.isManyToMany() + case Save: + if (prop.getCascadeInfo().isSave() || prop.isManyToMany() || ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) { - // Note ManyToMany always included as we always 'save' - // the relationship via insert/delete of intersection table - // REMOVALS means including PrivateOwned relationships - list.add(prop); - } - break; - case Delete: - if (prop.getCascadeInfo().isDelete() || ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) { - // REMOVALS means including PrivateOwned relationships - list.add(prop); - } - break; - default: - break; + // Note ManyToMany always included as we always 'save' + // the relationship via insert/delete of intersection table + // REMOVALS means including PrivateOwned relationships + list.add(prop); + } + break; + case Delete: + if (prop.getCascadeInfo().isDelete() || ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) { + // REMOVALS means including PrivateOwned relationships + list.add(prop); + } + break; + default: + break; } } @@ -419,15 +415,15 @@ public class DeployBeanPropertyLists { if (deployProp instanceof DeployBeanPropertyAssocOne) { return new BeanPropertyAssocOne(owner, desc, (DeployBeanPropertyAssocOne) deployProp); } - + if (deployProp instanceof DeployBeanPropertySimpleCollection) { return new BeanPropertySimpleCollection(desc, (DeployBeanPropertySimpleCollection) deployProp); } - + if (deployProp instanceof DeployBeanPropertyAssocMany) { return new BeanPropertyAssocMany(desc, (DeployBeanPropertyAssocMany) deployProp); } - + if (deployProp instanceof DeployBeanPropertyCompound) { return new BeanPropertyCompound(desc, (DeployBeanPropertyCompound) deployProp); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java index 5296fff32..d810f58ce 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java @@ -54,8 +54,8 @@ public class DeployTableJoin { */ public void setColumns(DeployTableJoinColumn[] cols, boolean reverse) { columns = new ArrayList<>(); - for (int i = 0; i < cols.length; i++) { - addJoinColumn(cols[i].copy(reverse)); + for (DeployTableJoinColumn col : cols) { + addJoinColumn(col.copy(reverse)); } } @@ -86,8 +86,8 @@ public class DeployTableJoin { * Add a JoinColumn array. */ public void addJoinColumn(boolean order, JoinColumn[] jcArray, BeanTable beanTable) { - for (int i = 0; i < jcArray.length; i++) { - addJoinColumn(order, jcArray[i], beanTable); + for (JoinColumn aJcArray : jcArray) { + addJoinColumn(order, aJcArray, beanTable); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java index 2bda44973..f5385890f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java @@ -228,20 +228,20 @@ public class AnnotationAssocManys extends AnnotationParser { if (!intJoin.hasJoinColumns()) { // define foreign key columns BeanProperty[] localIds = localTable.getIdProperties(); - for (int i = 0; i < localIds.length; i++) { + for (BeanProperty localId : localIds) { // add the source to intersection join columns - String fkCol = localTableName + "_" + localIds[i].getDbColumn(); - intJoin.addJoinColumn(new DeployTableJoinColumn(localIds[i].getDbColumn(), namingConvention.getColumnFromProperty(null, fkCol))); + String fkCol = localTableName + "_" + localId.getDbColumn(); + intJoin.addJoinColumn(new DeployTableJoinColumn(localId.getDbColumn(), namingConvention.getColumnFromProperty(null, fkCol))); } } if (!destJoin.hasJoinColumns()) { // define inverse foreign key columns BeanProperty[] otherIds = otherTable.getIdProperties(); - for (int i = 0; i < otherIds.length; i++) { + for (BeanProperty otherId : otherIds) { // set the intersection to dest table join columns - final String fkCol = otherTableName + "_" + otherIds[i].getDbColumn(); - destJoin.addJoinColumn(new DeployTableJoinColumn(namingConvention.getColumnFromProperty(null, fkCol), otherIds[i].getDbColumn())); + final String fkCol = otherTableName + "_" + otherId.getDbColumn(); + destJoin.addJoinColumn(new DeployTableJoinColumn(namingConvention.getColumnFromProperty(null, fkCol), otherId.getDbColumn())); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java index e2457ba77..8ddb2422c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java @@ -24,7 +24,7 @@ public abstract class AnnotationParser extends AnnotationBase { protected final Class beanType; protected final boolean validationAnnotations; - + public AnnotationParser(DeployBeanInfo info, boolean validationAnnotations) { super(info.getUtil()); this.validationAnnotations = validationAnnotations; @@ -56,9 +56,9 @@ public abstract class AnnotationParser extends AnnotationBase { if (attrOverrides != null) { HashMap propMap = new HashMap<>(); AttributeOverride[] aoArray = attrOverrides.value(); - for (int i = 0; i < aoArray.length; i++) { - String propName = aoArray[i].name(); - String columnName = aoArray[i].column().name(); + for (AttributeOverride anAoArray : aoArray) { + String propName = anAoArray.name(); + String columnName = anAoArray.column().name(); propMap.put(propName, columnName); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java index f1a4224e8..272c81b86 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java @@ -38,7 +38,7 @@ import java.lang.reflect.Type; public class DeployCreateProperties { private static final Logger logger = LoggerFactory.getLogger(DeployCreateProperties.class); - + private final DetermineManyType determineManyType; private final TypeManager typeManager; @@ -183,10 +183,9 @@ public class DeployCreateProperties { String methIsName = "is" + initFieldName; String scalaGet = field.getName(); - for (int i = 0; i < declaredMethods.length; i++) { - Method m = declaredMethods[i]; + for (Method m : declaredMethods) { if ((scalaObject && m.getName().equals(scalaGet)) || m.getName().equals(methGetName) - || m.getName().equals(methIsName)) { + || m.getName().equals(methIsName)) { Class[] params = m.getParameterTypes(); if (params.length == 0) { @@ -222,7 +221,7 @@ public class DeployCreateProperties { private DeployBeanProperty createProp(DeployBeanDescriptor desc, Field field) { Class propertyType = field.getType(); - + ManyToOne manyToOne = AnnotationBase.findAnnotation(field,ManyToOne.class); if (manyToOne != null){ Class tt = manyToOne.targetEntity(); @@ -233,7 +232,7 @@ public class DeployCreateProperties { if (isSpecialScalarType(field)) { return new DeployBeanProperty(desc, propertyType, field.getGenericType()); } - + // check for Collection type (list, set or map) ManyType manyType = determineManyType.getManyType(propertyType); if (manyType != null) { @@ -303,7 +302,7 @@ public class DeployCreateProperties { || (AnnotationBase.findAnnotation(field,DbArray.class) != null) || (AnnotationBase.findAnnotation(field,DbHstore.class) != null); } - + private boolean isTransientField(Field field) { Transient t = AnnotationBase.findAnnotation(field,Transient.class); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java index 329307b5b..24afe1ed3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java @@ -10,7 +10,7 @@ import java.util.HashSet; */ public class SqlReservedWords { - private static final String baseKeyWords = + private static final String baseKeyWords = "ALIAS,ALTER,ADD,ALL,ARE,AND,ANY,ARRAY" +",AS,ASC,AT" +",AVG,BEGIN,BETWEEN,BIGINT,BINARY,BIT,BIT_LENGTH,BLOB,BOOLEAN" @@ -44,15 +44,15 @@ public class SqlReservedWords { +",UPDATE,USER,VARCHAR,VIEW,WHEN" +",WHERE,WITH"; - + private static final HashSet keywords = new HashSet<>(); static { - + String[] initialKeywords = baseKeyWords.split(","); - for (int i = 0; i < initialKeywords.length; i++) { - keywords.add(initialKeywords[i].trim()); - } - + for (String initialKeyword : initialKeywords) { + keywords.add(initialKeyword.trim()); + } + } @@ -63,7 +63,7 @@ public class SqlReservedWords { String s = keyword.trim().toUpperCase(); return keywords.contains(s); } - + /** * Add a sql keyword to the known set. */ @@ -71,7 +71,7 @@ public class SqlReservedWords { if (keyword != null){ keyword = keyword.trim().toUpperCase(); if (!keyword.isEmpty()){ - keywords.add(keyword); + keywords.add(keyword); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/TransientProperties.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/TransientProperties.java index 0d119f0d4..2f8b52d9f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/TransientProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/TransientProperties.java @@ -11,41 +11,38 @@ import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne; * Mark transient properties. */ public class TransientProperties { - + public TransientProperties() { } - + /** * Mark any additional properties as transient. */ public void process(DeployBeanDescriptor desc) { - + List props = desc.propertiesBase(); - for (int i = 0; i < props.size(); i++) { - DeployBeanProperty prop = props.get(i); - if (!prop.isDbRead() && !prop.isDbInsertable() && !prop.isDbUpdateable()) { - // non-transient... - prop.setTransient(); - } - } + for (DeployBeanProperty prop : props) { + if (!prop.isDbRead() && !prop.isDbInsertable() && !prop.isDbUpdateable()) { + // non-transient... + prop.setTransient(); + } + } List> ones = desc.propertiesAssocOne(); - for (int i = 0; i < ones.size(); i++) { - DeployBeanPropertyAssocOne prop = ones.get(i); - if (prop.getBeanTable() == null) { - if (!prop.isEmbedded()) { - prop.setTransient(); - } - } + for (DeployBeanPropertyAssocOne prop : ones) { + if (prop.getBeanTable() == null) { + if (!prop.isEmbedded()) { + prop.setTransient(); + } } + } List> manys = desc.propertiesAssocMany(); - for (int i = 0; i < manys.size(); i++) { - DeployBeanPropertyAssocMany prop = manys.get(i); - if (prop.getBeanTable() == null) { - prop.setTransient(); - } + for (DeployBeanPropertyAssocMany prop : manys) { + if (prop.getBeanTable() == null) { + prop.setTransient(); } - + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElComparatorCompound.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElComparatorCompound.java index 663a92043..9f77d986f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElComparatorCompound.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElComparatorCompound.java @@ -18,8 +18,8 @@ public final class ElComparatorCompound implements Comparator, ElComparato public int compare(T o1, T o2) { - for (int i = 0; i < array.length; i++) { - int ret = array[i].compare(o1, o2); + for (ElComparator anArray : array) { + int ret = anArray.compare(o1, o2); if (ret != 0) { return ret; } @@ -30,8 +30,8 @@ public final class ElComparatorCompound implements Comparator, ElComparato public int compareValue(Object value, T o2) { - for (int i = 0; i < array.length; i++) { - int ret = array[i].compareValue(value, o2); + for (ElComparator anArray : array) { + int ret = anArray.compareValue(value, o2); if (ret != 0) { return ret; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java index c8650d0d7..a37b4dcec 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java @@ -47,8 +47,7 @@ public final class ElFilter implements Filter { } protected boolean isMatch(T bean) { - for (int i = 0; i < matches.size(); i++) { - ElMatcher matcher = matches.get(i); + for (ElMatcher matcher : matches) { if (!matcher.isMatch(bean)) { return false; } @@ -235,8 +234,7 @@ public final class ElFilter implements Filter { ArrayList filterList = new ArrayList<>(); - for (int i = 0; i < list.size(); i++) { - T t = list.get(i); + for (T t : list) { if (isMatch(t)) { filterList.add(t); if (maxRows > 0 && filterList.size() >= maxRows) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChain.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChain.java index dcb9a0c19..4d298ca4f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChain.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChain.java @@ -193,8 +193,8 @@ public class ElPropertyChain implements ElPropertyValue { } public boolean isAssocProperty() { - for (int i = 0; i < chain.length; i++) { - if (chain[i].isAssocProperty()) { + for (ElPropertyValue aChain : chain) { + if (aChain.isAssocProperty()) { return true; } } @@ -233,8 +233,8 @@ public class ElPropertyChain implements ElPropertyValue { @Override public Object pathGet(Object bean) { - for (int i = 0; i < chain.length; i++) { - bean = chain[i].pathGet(bean); + for (ElPropertyValue aChain : chain) { + bean = aChain.pathGet(bean); if (bean == null) { return null; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java index a9b419c2c..e82fbd3c7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java @@ -35,8 +35,8 @@ public class ArrayContainsExpression extends AbstractExpression { } else { context.startBoolMustNot(); } - for (int i = 0; i < values.length; i++) { - context.writeEqualTo(propName, values[i]); + for (Object value : values) { + context.writeEqualTo(propName, value); } context.endBool(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java index f6060a649..9bb9041e9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java @@ -124,8 +124,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio public void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins) { list = buildExpressions(desc); if (list != null) { - for (int i = 0; i < list.size(); i++) { - list.get(i).containsMany(desc, whereManyJoins); + for (SpiExpression aList : list) { + aList.containsMany(desc, whereManyJoins); } } } @@ -173,8 +173,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio @Override public void validate(SpiExpressionValidation validation) { - for (int i = 0; i < list.size(); i++) { - list.get(i).validate(validation); + for (SpiExpression aList : list) { + aList.validate(validation); } } @@ -184,8 +184,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio @Override public void addBindValues(SpiExpressionRequest request) { - for (int i = 0; i < list.size(); i++) { - SpiExpression item = list.get(i); + for (SpiExpression item : list) { item.addBindValues(request); } } @@ -218,8 +217,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio public void queryPlanHash(HashQueryPlanBuilder builder) { builder.add(DefaultExampleExpression.class); - for (int i = 0; i < list.size(); i++) { - list.get(i).queryPlanHash(builder); + for (SpiExpression aList : list) { + aList.queryPlanHash(builder); } } @@ -229,8 +228,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio @Override public int queryBindHash() { int hc = DefaultExampleExpression.class.getName().hashCode(); - for (int i = 0; i < list.size(); i++) { - hc = hc * 92821 + list.get(i).queryBindHash(); + for (SpiExpression aList : list) { + hc = hc * 92821 + aList.queryBindHash(); } return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java index 8b28e2706..2da0b3c90 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java @@ -139,11 +139,10 @@ public class DefaultExpressionList implements SpiExpressionList { if (implicitBool) { context.startBoolGroupList(Junction.Type.SHOULD); } - for (int i = 0; i < size; i++) { - SpiExpression expr = list.get(i); + for (SpiExpression expr : list) { if (explicitBool) { try { - ((SpiJunction)expr).writeDocQueryJunction(context); + ((SpiJunction) expr).writeDocQueryJunction(context); } catch (ClassCastException e) { throw new IllegalStateException("The top level text() expressions should be all be 'Must', 'Should' or 'Must Not' or none of them should be.", e); } @@ -177,8 +176,8 @@ public class DefaultExpressionList implements SpiExpressionList { if (idEquals != null) { idEquals.writeDocQuery(context); } - for (int i = 0; i < size; i++) { - list.get(i).writeDocQuery(context); + for (SpiExpression aList : list) { + aList.writeDocQuery(context); } context.endBool(); } @@ -226,15 +225,15 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins) { - for (int i = 0; i < list.size(); i++) { - list.get(i).containsMany(desc, whereManyJoins); + for (SpiExpression aList : list) { + aList.containsMany(desc, whereManyJoins); } } @Override public void validate(SpiExpressionValidation validation) { - for (int i = 0; i < list.size(); i++) { - list.get(i).validate(validation); + for (SpiExpression aList : list) { + aList.validate(validation); } } @@ -480,15 +479,15 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public void addBindValues(SpiExpressionRequest request) { - for (int i = 0, size = list.size(); i < size; i++) { - list.get(i).addBindValues(request); + for (SpiExpression aList : list) { + aList.addBindValues(request); } } @Override public void prepareExpression(BeanQueryRequest request) { - for (int i = 0, size = list.size(); i < size; i++) { - list.get(i).prepareExpression(request); + for (SpiExpression aList : list) { + aList.prepareExpression(request); } } @@ -499,8 +498,8 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public void queryPlanHash(HashQueryPlanBuilder builder) { builder.add(DefaultExpressionList.class); - for (int i = 0, size = list.size(); i < size; i++) { - list.get(i).queryPlanHash(builder); + for (SpiExpression aList : list) { + aList.queryPlanHash(builder); } } @@ -510,8 +509,8 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public int queryBindHash() { int hash = DefaultExpressionList.class.getName().hashCode(); - for (int i = 0, size = list.size(); i < size; i++) { - hash = hash * 92821 + list.get(i).queryBindHash(); + for (SpiExpression aList : list) { + hash = hash * 92821 + aList.queryBindHash(); } return hash; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java index 3c983bc6d..027718b4b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java @@ -63,8 +63,7 @@ public class DefaultExpressionRequest implements SpiExpressionRequest { * Bind the values from the underlying expression list. */ public void bind(DataBind dataBind) throws SQLException { - for (int i = 0; i < bindValues.size(); i++) { - Object bindValue = bindValues.get(i); + for (Object bindValue : bindValues) { binder.bindObject(dataBind, bindValue); } if (bindLog != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java index aa1abcfe7..9f43cbb77 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java @@ -98,8 +98,8 @@ class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpress @Override public void addBindValues(SpiExpressionRequest request) { - for (int i = 0; i < bindParams.size(); i++) { - request.addBindValue(bindParams.get(i)); + for (Object bindParam : bindParams) { + request.addBindValue(bindParam); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/IdExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/IdExpression.java index c74767df2..d39931aea 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/IdExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/IdExpression.java @@ -50,8 +50,8 @@ class IdExpression extends NonPrepareExpression implements SpiExpression { // into an array of the underlying scalar field values DefaultExpressionRequest r = (DefaultExpressionRequest) request; Object[] bindIdValues = r.getBeanDescriptor().getBindIdValues(value); - for (int i = 0; i < bindIdValues.length; i++) { - request.addBindValue(bindIdValues[i]); + for (Object bindIdValue : bindIdValues) { + request.addBindValue(bindIdValue); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/IdInExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/IdInExpression.java index 3c153b9ad..2b329000a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/IdInExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/IdInExpression.java @@ -50,8 +50,8 @@ public class IdInExpression extends NonPrepareExpression { BeanDescriptor descriptor = r.getBeanDescriptor(); IdBinder idBinder = descriptor.getIdBinder(); - for (int i = 0; i < idList.size(); i++) { - idBinder.addIdInBindValue(request, idList.get(i)); + for (Object anIdList : idList) { + idBinder.addIdInBindValue(request, anIdList); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java index 682fdfcc6..7222d3372 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java @@ -59,16 +59,16 @@ class InExpression extends AbstractExpression { prop = null; } - for (int i = 0; i < bindValues.length; i++) { + for (Object bindValue : bindValues) { if (prop == null) { - request.addBindValue(bindValues[i]); + request.addBindValue(bindValue); } else { // extract the id values from the bean - Object[] ids = prop.getAssocIdValues((EntityBean) bindValues[i]); + Object[] ids = prop.getAssocIdValues((EntityBean) bindValue); if (ids != null) { - for (int j = 0; j < ids.length; j++) { - request.addBindValue(ids[j]); + for (Object id : ids) { + request.addBindValue(id); } } } @@ -120,8 +120,8 @@ class InExpression extends AbstractExpression { @Override public int queryBindHash() { int hc = 92821; - for (int i = 0; i < bindValues.length; i++) { - hc = 92821 * hc + bindValues[i].hashCode(); + for (Object bindValue : bindValues) { + hc = 92821 * hc + bindValue.hashCode(); } return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java index ba1bd8857..47abc862f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java @@ -91,8 +91,8 @@ class InQueryExpression extends AbstractExpression implements UnsupportedDocStor @Override public void addBindValues(SpiExpressionRequest request) { - for (int i = 0; i < bindParams.size(); i++) { - request.addBindValue(bindParams.get(i)); + for (Object bindParam : bindParams) { + request.addBindValue(bindParam); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java index b7556fd96..657ea35c0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java @@ -91,8 +91,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public void writeDocQuery(DocQueryContext context) throws IOException { context.startBool(type); List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).writeDocQuery(context); + for (SpiExpression aList : list) { + aList.writeDocQuery(context); } context.endBool(); } @@ -101,8 +101,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public void writeDocQueryJunction(DocQueryContext context) throws IOException { context.startBoolGroupList(type); List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).writeDocQuery(context); + for (SpiExpression aList : list) { + aList.writeDocQuery(context); } context.endBoolGroupList(); } @@ -125,8 +125,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression manyWhereJoin.setRequireOuterJoins(true); } - for (int i = 0; i < list.size(); i++) { - list.get(i).containsMany(desc, manyWhereJoin); + for (SpiExpression aList : list) { + aList.containsMany(desc, manyWhereJoin); } if (type == Type.OR && !parentOuterJoins) { // restore state to not forcing outer joins @@ -155,8 +155,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public void addBindValues(SpiExpressionRequest request) { List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).addBindValues(request); + for (SpiExpression aList : list) { + aList.addBindValues(request); } } @@ -182,8 +182,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression @Override public void prepareExpression(BeanQueryRequest request) { List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).prepareExpression(request); + for (SpiExpression aList : list) { + aList.prepareExpression(request); } } @@ -194,8 +194,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public void queryPlanHash(HashQueryPlanBuilder builder) { builder.add(JunctionExpression.class).add(type); List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).queryPlanHash(builder); + for (SpiExpression aList : list) { + aList.queryPlanHash(builder); } } @@ -203,8 +203,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public int queryBindHash() { int hc = JunctionExpression.class.getName().hashCode(); List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - hc = hc * 92821 + list.get(i).queryBindHash(); + for (SpiExpression aList : list) { + hc = hc * 92821 + aList.queryBindHash(); } return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/RawExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/RawExpression.java index 3632086cf..d0f065596 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/RawExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/RawExpression.java @@ -43,8 +43,8 @@ class RawExpression extends NonPrepareExpression { @Override public void addBindValues(SpiExpressionRequest request) { if (values != null) { - for (int i = 0; i < values.length; i++) { - request.addBindValue(values[i]); + for (Object value : values) { + request.addBindValue(value); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java index c50681faa..fbe082f99 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java @@ -64,8 +64,8 @@ public class SimpleExpression extends AbstractValueExpression { if (prop.isAssocId()) { Object[] ids = prop.getAssocIdValues((EntityBean) value()); if (ids != null) { - for (int i = 0; i < ids.length; i++) { - request.addBindValue(ids[i]); + for (Object id : ids) { + request.addBindValue(id); } } return; diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java b/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java index e6521da23..78496bc23 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java @@ -11,22 +11,22 @@ public class Str { * Append strings together. */ public static String add(String s0, String s1, String ... args) { - + // determine a decent buffer size int len = 16 + s0.length() + s1.length(); - for (int i = 0; i < args.length; i++) { - len += args[i].length(); + for (String arg1 : args) { + len += arg1.length(); } - - // append all the strings into the buffer + + // append all the strings into the buffer StringBuilder sb = new StringBuilder(len); sb.append(s0).append(s1); - for (int i = 0; i < args.length; i++) { - sb.append(args[i]); + for (String arg : args) { + sb.append(arg); } return sb.toString(); } - + /** * Append two strings together. */ @@ -35,5 +35,5 @@ public class Str { StringBuilder sb = new StringBuilder(s0.length() + s1.length() + 5); return sb.append(s0).append(s1).toString(); } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java index eb5e6707b..31159abad 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java @@ -169,8 +169,8 @@ public class DLoadContext implements LoadContext { } int maxBatch = 0; - for (int i = 0; i < secQuery.size(); i++) { - int batchSize = secQuery.get(i).getQueryFetchBatch(); + for (OrmQueryProperties aSecQuery : secQuery) { + int batchSize = aSecQuery.getQueryFetchBatch(); if (batchSize == 0) { batchSize = defaultQueryBatch; } @@ -185,8 +185,8 @@ public class DLoadContext implements LoadContext { public void executeSecondaryQueries(OrmQueryRequest parentRequest, boolean forEach) { if (secQuery != null) { - for (int i = 0; i < secQuery.size(); i++) { - LoadSecondaryQuery load = getLoadSecondaryQuery(secQuery.get(i).getPath()); + for (OrmQueryProperties aSecQuery : secQuery) { + LoadSecondaryQuery load = getLoadSecondaryQuery(aSecQuery.getPath()); load.loadSecondaryQuery(parentRequest, forEach); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java index e4efe2cb7..07927bfef 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java @@ -248,8 +248,8 @@ public final class BatchControl { if (transaction.isLogSummary()) { transaction.logSummary("BatchControl flush " + Arrays.toString(bsArray)); } - for (int i = 0; i < bsArray.length; i++) { - bsArray[i].executeNow(); + for (BatchedBeanHolder aBsArray : bsArray) { + aBsArray.executeNow(); } if (resetTop) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java index ed5be8019..999bf4ef8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java @@ -93,8 +93,8 @@ public class BatchedPstmt { } private void postExecute() { - for (int i = 0; i < list.size(); i++) { - list.get(i).postExecute(); + for (BatchPostExecute aList : list) { + aList.postExecute(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java b/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java index f9e329562..3e46b87fe 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java @@ -74,9 +74,7 @@ public class Binder { String logPrefix = ""; ArrayList list = bindValues.values(); - for (int i = 0; i < list.size(); i++) { - BindValues.Value bindValue = list.get(i); - + for (BindValues.Value bindValue : list) { Object val = bindValue.getValue(); int dt = bindValue.getDbType(); bindObject(dataBind, val, dt); @@ -136,9 +134,7 @@ public class Binder { // the iterator is assumed to be in the correct order Object value = null; try { - for (int i = 0; i < list.size(); i++) { - - BindParams.Param param = list.get(i); + for (BindParams.Param param : list) { if (param.isOutParam() && cstmt != null) { cstmt.registerOutParameter(dataBind.nextPos(), param.getType()); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java b/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java index 4c035aa9c..402fdd50a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java @@ -197,7 +197,7 @@ public final class DefaultPersister implements Persister { for (T draftBean: draftBeans) { T liveBean = draftHandler.publishToDestinationBean(draftBean); livePublish.add(liveBean); - + // reset @DraftDirty and @DraftReset properties draftHandler.resetDraft(draftBean); @@ -557,8 +557,8 @@ public final class DefaultPersister implements Persister { } private void deleteList(List beanList, Transaction t, boolean softDelete) { - for (int i = 0; i < beanList.size(); i++) { - deleteRecurse((EntityBean) beanList.get(i), t, softDelete); + for (Object aBeanList : beanList) { + deleteRecurse((EntityBean) aBeanList, t, softDelete); } } @@ -634,15 +634,15 @@ public final class DefaultPersister implements Persister { if (t.isPersistCascade()) { // OneToOne exported side with delete cascade BeanPropertyAssocOne[] expOnes = descriptor.propertiesOneExportedDelete(); - for (int i = 0; i < expOnes.length; i++) { - BeanDescriptor targetDesc = expOnes[i].getTargetDescriptor(); + for (BeanPropertyAssocOne expOne : expOnes) { + BeanDescriptor targetDesc = expOne.getTargetDescriptor(); // only cascade soft deletes when supported by target if (!softDelete || targetDesc.isSoftDelete()) { if (!softDelete && targetDesc.isDeleteByStatement()) { - SqlUpdate sqlDelete = expOnes[i].deleteByParentId(id, idList); + SqlUpdate sqlDelete = expOne.deleteByParentId(id, idList); executeSqlUpdate(sqlDelete, t); } else { - List childIds = expOnes[i].findIdsByParentId(id, idList, t); + List childIds = expOne.findIdsByParentId(id, idList, t); deleteChildrenById(t, targetDesc, childIds, softDelete); } } @@ -650,17 +650,17 @@ public final class DefaultPersister implements Persister { // OneToMany's with delete cascade BeanPropertyAssocMany[] manys = descriptor.propertiesManyDelete(); - for (int i = 0; i < manys.length; i++) { - BeanDescriptor targetDesc = manys[i].getTargetDescriptor(); + for (BeanPropertyAssocMany many : manys) { + BeanDescriptor targetDesc = many.getTargetDescriptor(); // only cascade soft deletes when supported by target if (!softDelete || targetDesc.isSoftDelete()) { if (!softDelete && targetDesc.isDeleteByStatement()) { // we can just delete children with a single statement - SqlUpdate sqlDelete = manys[i].deleteByParentId(id, idList); + SqlUpdate sqlDelete = many.deleteByParentId(id, idList); executeSqlUpdate(sqlDelete, t); } else { // we need to fetch the Id's to delete (recurse or notify L2 cache) - List childIds = manys[i].findIdsByParentId(id, idList, t, null); + List childIds = many.findIdsByParentId(id, idList, t, null); if (!childIds.isEmpty()) { delete(targetDesc, null, childIds, t, softDelete); } @@ -672,10 +672,10 @@ public final class DefaultPersister implements Persister { if (!softDelete) { // ManyToMany's ... delete from intersection table BeanPropertyAssocMany[] manys = descriptor.propertiesManyToMany(); - for (int i = 0; i < manys.length; i++) { - SqlUpdate sqlDelete = manys[i].deleteByParentId(id, idList); + for (BeanPropertyAssocMany many : manys) { + SqlUpdate sqlDelete = many.deleteByParentId(id, idList); if (t.isLogSummary()) { - t.logSummary("-- Deleting intersection table entries: " + manys[i].getFullBeanName()); + t.logSummary("-- Deleting intersection table entries: " + many.getFullBeanName()); } executeSqlUpdate(sqlDelete, t); } @@ -720,8 +720,8 @@ public final class DefaultPersister implements Persister { Query q = server.createQuery(desc.getBeanType()); StringBuilder sb = new StringBuilder(30); - for (int i = 0; i < propImportDelete.length; i++) { - sb.append(propImportDelete[i].getName()).append(","); + for (BeanPropertyAssocOne aPropImportDelete : propImportDelete) { + sb.append(aPropImportDelete.getName()).append(","); } q.setAutoTune(false); q.select(sb.toString()); @@ -786,9 +786,7 @@ public final class DefaultPersister implements Persister { // exported ones with cascade save BeanPropertyAssocOne[] expOnes = desc.propertiesOneExportedSave(); - for (int i = 0; i < expOnes.length; i++) { - BeanPropertyAssocOne prop = expOnes[i]; - + for (BeanPropertyAssocOne prop : expOnes) { // check for partial beans if (request.isLoadedProperty(prop)) { EntityBean detailBean = prop.getValueAsEntityBean(parentBean); @@ -805,12 +803,12 @@ public final class DefaultPersister implements Persister { // many's with cascade save BeanPropertyAssocMany[] manys = desc.propertiesManySave(); - for (int i = 0; i < manys.length; i++) { + for (BeanPropertyAssocMany many : manys) { // check that property is loaded and collection should be cascaded to - if (request.isLoadedProperty(manys[i]) && !manys[i].isSkipSaveBeanCollection(parentBean, insertedParent)) { - saveMany(new SaveManyPropRequest(insertedParent, manys[i], parentBean, request), insertMode); + if (request.isLoadedProperty(many) && !many.isSkipSaveBeanCollection(parentBean, insertedParent)) { + saveMany(new SaveManyPropRequest(insertedParent, many, parentBean, request), insertMode); if (!insertedParent) { - request.addUpdatedManyProperty(manys[i]); + request.addUpdatedManyProperty(many); } } } @@ -916,7 +914,7 @@ public final class DefaultPersister implements Persister { } } else { if (saveMany.isModifyListenMode()) { - // delete any removed beans via private owned. Needs to occur before + // delete any removed beans via private owned. Needs to occur before // a 'deleteMissingChildren' statement occurs removeAssocManyPrivateOwned(saveMany); } @@ -1188,14 +1186,13 @@ public final class DefaultPersister implements Persister { if (expOnes.length > 0) { DeleteUnloadedForeignKeys unloaded = null; - for (int i = 0; i < expOnes.length; i++) { - BeanPropertyAssocOne prop = expOnes[i]; + for (BeanPropertyAssocOne prop : expOnes) { // for soft delete check cascade type also supports soft delete if (!softDelete || prop.getTargetDescriptor().isSoftDelete()) { if (request.isLoadedProperty(prop)) { Object detailBean = prop.getValue(parentBean); if (detailBean != null) { - deleteRecurse((EntityBean)detailBean, t, softDelete); + deleteRecurse((EntityBean) detailBean, t, softDelete); } } else { if (unloaded == null) { @@ -1213,19 +1210,19 @@ public final class DefaultPersister implements Persister { // Many's with delete cascade BeanPropertyAssocMany[] manys = desc.propertiesManyDelete(); - for (int i = 0; i < manys.length; i++) { - if (manys[i].isManyToMany()) { + for (BeanPropertyAssocMany many : manys) { + if (many.isManyToMany()) { if (!softDelete) { // delete associated rows from intersection table (but not during soft delete) - deleteAssocManyIntersection(parentBean, manys[i], t, request.isPublish()); + deleteAssocManyIntersection(parentBean, many, t, request.isPublish()); } } else { - if (ModifyListenMode.REMOVALS.equals(manys[i].getModifyListenMode())) { + if (ModifyListenMode.REMOVALS.equals(many.getModifyListenMode())) { // PrivateOwned ... // if soft delete then check target also supports soft delete - if (!softDelete || manys[i].getTargetDescriptor().isSoftDelete()) { - Object details = manys[i].getValue(parentBean); + if (!softDelete || many.getTargetDescriptor().isSoftDelete()) { + Object details = many.getValue(parentBean); if (details instanceof BeanCollection) { Set modifyRemovals = ((BeanCollection) details).getModifyRemovals(); if (modifyRemovals != null && !modifyRemovals.isEmpty()) { @@ -1233,7 +1230,7 @@ public final class DefaultPersister implements Persister { // delete the orphans that have been removed from the collection for (Object detail : modifyRemovals) { EntityBean detailBean = (EntityBean) detail; - if (manys[i].hasId(detailBean)) { + if (many.hasId(detailBean)) { deleteRecurse(detailBean, t, softDelete); } } @@ -1242,7 +1239,7 @@ public final class DefaultPersister implements Persister { } } - deleteManyDetails(t, desc, parentBean, manys[i], null, softDelete); + deleteManyDetails(t, desc, parentBean, many, null, softDelete); } } @@ -1314,16 +1311,14 @@ public final class DefaultPersister implements Persister { // imported ones with save cascade BeanPropertyAssocOne[] ones = desc.propertiesOneImportedSave(); - for (int i = 0; i < ones.length; i++) { - BeanPropertyAssocOne prop = ones[i]; - + for (BeanPropertyAssocOne prop : ones) { // check for partial objects if (request.isLoadedProperty(prop)) { EntityBean detailBean = prop.getValueAsEntityBean(request.getEntityBean()); if (detailBean != null - && !prop.isSaveRecurseSkippable(detailBean) - && !prop.isReference(detailBean) - && !request.isParent(detailBean)) { + && !prop.isSaveRecurseSkippable(detailBean) + && !prop.isReference(detailBean) + && !request.isParent(detailBean)) { SpiTransaction t = request.getTransaction(); t.depth(-1); saveRecurse(detailBean, t, null, insertMode, request.isPublish()); @@ -1342,14 +1337,14 @@ public final class DefaultPersister implements Persister { DeleteUnloadedForeignKeys fkeys = null; BeanPropertyAssocOne[] ones = request.getBeanDescriptor().propertiesOneImportedDelete(); - for (int i = 0; i < ones.length; i++) { - if (!request.isLoadedProperty(ones[i])) { + for (BeanPropertyAssocOne one : ones) { + if (!request.isLoadedProperty(one)) { // we have cascade Delete on a partially populated bean and // this property was not loaded (so we are going to have to fetch it) if (fkeys == null) { fkeys = new DeleteUnloadedForeignKeys(server, request); } - fkeys.add(ones[i]); + fkeys.add(one); } } @@ -1362,8 +1357,7 @@ public final class DefaultPersister implements Persister { private void deleteAssocOne(PersistRequestBean request) { BeanPropertyAssocOne[] ones = request.getBeanDescriptor().propertiesOneImportedDelete(); - for (int i = 0; i < ones.length; i++) { - BeanPropertyAssocOne prop = ones[i]; + for (BeanPropertyAssocOne prop : ones) { if (request.isLoadedProperty(prop)) { Object detailBean = prop.getValue(request.getEntityBean()); if (detailBean != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java b/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java index 175695a21..4d2b97b50 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java @@ -59,8 +59,8 @@ class DeleteUnloadedForeignKeys { Object id = request.getBeanId(); StringBuilder sb = new StringBuilder(30); - for (int i = 0; i < propList.size(); i++) { - sb.append(propList.get(i).getName()).append(","); + for (BeanPropertyAssocOne aPropList : propList) { + sb.append(aPropList.getName()).append(","); } // run query in a separate persistence context @@ -84,8 +84,7 @@ class DeleteUnloadedForeignKeys { */ void deleteCascade() { - for (int i = 0; i < propList.size(); i++) { - BeanPropertyAssocOne prop = propList.get(i); + for (BeanPropertyAssocOne prop : propList) { Object detailBean = prop.getValue(beanWithForeignKeys); // if bean exists with a unique id then delete it diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java index ebfb52d5c..39f00c1a0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java @@ -34,8 +34,8 @@ public class BindableCompound implements Bindable { public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < items.length; i++) { - items[i].dmlAppend(request); + for (BindableProperty item : items) { + item.dmlAppend(request); } } @@ -51,8 +51,8 @@ public class BindableCompound implements Bindable { Object valueObject = compound.getValue(bean); // bind each of the underlying scalar values for this compound type - for (int i = 0; i < items.length; i++) { - items[i].dmlBindObject(bindRequest, valueObject); + for (BindableProperty item : items) { + item.dmlBindObject(bindRequest, valueObject); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java index 29d5b9e70..b1b707f8b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java @@ -34,8 +34,8 @@ public class BindableEmbedded implements Bindable { public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < items.length; i++) { - items[i].dmlAppend(request); + for (Bindable item : items) { + item.dmlAppend(request); } } @@ -50,14 +50,14 @@ public class BindableEmbedded implements Bindable { // get the embedded bean EntityBean embBean = (EntityBean) embProp.getValue(bean); if (embBean == null) { - for (int i = 0; i < items.length; i++) { - items[i].dmlBind(bindRequest, null); + for (Bindable item : items) { + item.dmlBind(bindRequest, null); } } else { //EntityBeanIntercept ebi = embBean._ebean_getIntercept(); - for (int i = 0; i < items.length; i++) { + for (Bindable item : items) { //if (ebi.isLoadedProperty(props[i].getPropertyIndex())) { - items[i].dmlBind(bindRequest, embBean); + item.dmlBind(bindRequest, embBean); //} } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java index b07be39d2..5466754bf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java @@ -64,18 +64,18 @@ public final class BindableIdEmbedded implements BindableId { EntityBean idValue = (EntityBean) embId.getValue(bean); - for (int i = 0; i < props.length; i++) { + for (BeanProperty prop : props) { - Object value = props[i].getValue(idValue); - request.bind(value, props[i]); + Object value = prop.getValue(idValue); + request.bind(value, prop); } request.setIdValue(idValue); } public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < props.length; i++) { - request.appendColumn(props[i].getDbColumn()); + for (BeanProperty prop : props) { + request.appendColumn(prop.getDbColumn()); } } @@ -94,8 +94,8 @@ public final class BindableIdEmbedded implements BindableId { EntityBean newId = (EntityBean) embId.createEmbeddedId(); // populate it from the assoc one id values... - for (int i = 0; i < matches.length; i++) { - matches[i].populate(bean, newId); + for (MatchedImportedProperty matche : matches) { + matche.populate(bean, newId); } // support PropertyChangeSupport diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java index dc7c743e2..79f8fbc03 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java @@ -43,23 +43,23 @@ public class BindableList implements Bindable { } public void addToUpdate(PersistRequestBean request, List list) { - for (int i = 0; i < items.length; i++) { - items[i].addToUpdate(request, list); + for (Bindable item : items) { + item.addToUpdate(request, list); } } public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < items.length; i++) { - items[i].dmlAppend(request); + for (Bindable item : items) { + item.dmlAppend(request); } } public void dmlBind(BindableRequest bindRequest, EntityBean bean) throws SQLException { - for (int i = 0; i < items.length; i++) { - items[i].dmlBind(bindRequest, bean); + for (Bindable item : items) { + item.dmlBind(bindRequest, bean); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java index 20e21c1e1..e3dc4ad01 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java @@ -21,21 +21,21 @@ public class FactoryAssocOnes { BeanPropertyAssocOne[] ones = desc.propertiesOneImported(); - for (int i = 0; i < ones.length; i++) { - if (!ones[i].isImportedPrimaryKey()) { + for (BeanPropertyAssocOne one : ones) { + if (!one.isImportedPrimaryKey()) { switch (mode) { case INSERT: - if (!ones[i].isInsertable()) { + if (!one.isInsertable()) { continue; } break; case UPDATE: - if (!ones[i].isUpdateable()) { + if (!one.isUpdateable()) { continue; } break; } - list.add(new BindableAssocOne(ones[i])); + list.add(new BindableAssocOne(one)); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java index e1378423b..57ea2f4c7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java @@ -31,13 +31,13 @@ public class FactoryBaseProperties { add(desc.propertiesBaseScalar(), list, mode, withLobs); BeanPropertyCompound[] compoundProps = desc.propertiesBaseCompound(); - for (int i = 0; i < compoundProps.length; i++) { - BeanProperty[] props = compoundProps[i].getScalarProperties(); + for (BeanPropertyCompound compoundProp : compoundProps) { + BeanProperty[] props = compoundProp.getScalarProperties(); List newList = new ArrayList<>(props.length); addCompound(props, newList, mode, withLobs); - BindableCompound compoundBindable = new BindableCompound(compoundProps[i], newList); + BindableCompound compoundBindable = new BindableCompound(compoundProp, newList); list.add(compoundBindable); } @@ -45,8 +45,8 @@ public class FactoryBaseProperties { private void add(BeanProperty[] props, List list, DmlMode mode, boolean withLobs) { - for (int i = 0; i < props.length; i++) { - Bindable item = factoryProperty.create(props[i], mode, withLobs); + for (BeanProperty prop : props) { + Bindable item = factoryProperty.create(prop, mode, withLobs); if (item != null) { list.add(item); } @@ -55,8 +55,8 @@ public class FactoryBaseProperties { private void addCompound(BeanProperty[] props, List list, DmlMode mode, boolean withLobs) { - for (int i = 0; i < props.length; i++) { - BindableProperty item = (BindableProperty) factoryProperty.create(props[i], mode, withLobs); + for (BeanProperty prop : props) { + BindableProperty item = (BindableProperty) factoryProperty.create(prop, mode, withLobs); if (item != null) { list.add(item); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java index 45d1e165e..52beeccc4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java @@ -26,20 +26,20 @@ public class FactoryEmbedded { BeanPropertyAssocOne[] embedded = desc.propertiesEmbedded(); - for (int j = 0; j < embedded.length; j++) { + for (BeanPropertyAssocOne anEmbedded : embedded) { - BeanProperty[] props = embedded[j].getProperties(); + BeanProperty[] props = anEmbedded.getProperties(); List bindList = new ArrayList<>(props.length); - for (int i = 0; i < props.length; i++) { - Bindable item = factoryProperty.create(props[i], mode, withLobs); + for (BeanProperty prop : props) { + Bindable item = factoryProperty.create(prop, mode, withLobs); if (item != null) { bindList.add(item); } } - list.add(new BindableEmbedded(embedded[j], bindList)); + list.add(new BindableEmbedded(anEmbedded, bindList)); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java index 9e4da8a12..a95505f2c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java @@ -66,14 +66,14 @@ class MatchedImportedProperty { String dbColumn = prop.getDbColumn(); BeanPropertyAssocOne[] assocOnes = desc.propertiesOne(); - for (int i = 0; i < assocOnes.length; i++) { - if (assocOnes[i].isImportedPrimaryKey()) { + for (BeanPropertyAssocOne assocOne1 : assocOnes) { + if (assocOne1.isImportedPrimaryKey()) { // search using the ImportedId from the assoc one - BeanProperty foreignMatch = assocOnes[i].getImportedId().findMatchImport(dbColumn); + BeanProperty foreignMatch = assocOne1.getImportedId().findMatchImport(dbColumn); if (foreignMatch != null) { - return new MatchedImportedProperty(assocOnes[i], foreignMatch, prop); + return new MatchedImportedProperty(assocOne1, foreignMatch, prop); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java index 93cf4d102..7c1c86c41 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java @@ -142,8 +142,8 @@ public class CQueryPlan { DataBind bindEncryptedProperties(PreparedStatement stmt, Connection conn) throws SQLException { DataBind dataBind = new DataBind(dataTimeZone, stmt, conn); if (encryptedProps != null) { - for (int i = 0; i < encryptedProps.length; i++) { - String key = encryptedProps[i].getEncryptKey().getStringValue(); + for (BeanProperty encryptedProp : encryptedProps) { + String key = encryptedProp.getEncryptKey().getStringValue(); dataBind.setString(key); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java index e53bfc904..f727c2987 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java @@ -219,20 +219,20 @@ public class SqlTreeBuilder { List myJoinList = new ArrayList<>(); BeanPropertyAssocOne[] ones = desc.propertiesOne(); - for (int i = 0; i < ones.length; i++) { - String propPrefix = SplitName.add(prefix, ones[i].getName()); + for (BeanPropertyAssocOne one : ones) { + String propPrefix = SplitName.add(prefix, one.getName()); if (isIncludeBean(propPrefix)) { selectIncludes.add(propPrefix); - buildSelectChain(propPrefix, ones[i], ones[i].getTargetDescriptor(), myJoinList); + buildSelectChain(propPrefix, one, one.getTargetDescriptor(), myJoinList); } } BeanPropertyAssocMany[] manys = desc.propertiesMany(); - for (int i = 0; i < manys.length; i++) { - String propPrefix = SplitName.add(prefix, manys[i].getName()); - if (isIncludeMany(propPrefix, manys[i])) { + for (BeanPropertyAssocMany many : manys) { + String propPrefix = SplitName.add(prefix, many.getName()); + if (isIncludeMany(propPrefix, many)) { selectIncludes.add(propPrefix); - buildSelectChain(propPrefix, manys[i], manys[i].getTargetDescriptor(), myJoinList); + buildSelectChain(propPrefix, many, many.getTargetDescriptor(), myJoinList); } } @@ -458,13 +458,13 @@ public class SqlTreeBuilder { selectProps.add(desc.propertiesEmbedded()); BeanPropertyAssocOne[] propertiesOne = desc.propertiesOne(); - for (int i = 0; i < propertiesOne.length; i++) { + for (BeanPropertyAssocOne aPropertiesOne : propertiesOne) { //noinspection StatementWithEmptyBody - if (queryProps != null && queryProps.isIncludedBeanJoin(propertiesOne[i].getName())) { + if (queryProps != null && queryProps.isIncludedBeanJoin(aPropertiesOne.getName())) { // if it is a joined bean... then don't add the property // as it will have its own entire Node in the SqlTree } else { - selectProps.add(propertiesOne[i]); + selectProps.add(aPropertiesOne); } } @@ -576,8 +576,8 @@ public class SqlTreeBuilder { Arrays.sort(extras); // reverse order so get the leaves first... - for (int i = 0; i < extras.length; i++) { - createExtraJoin(extras[i]); + for (String extra : extras) { + createExtraJoin(extra); } return rootRegister.values(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java index c739fa3f6..b5c2b1332 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java @@ -143,8 +143,8 @@ class SqlTreeNodeBean implements SqlTreeNode { BeanPropertyAssocMany[] manys = desc.propertiesMany(); HashMap m = new HashMap<>(); - for (int i = 0; i < manys.length; i++) { - String name = manys[i].getName(); + for (BeanPropertyAssocMany many : manys) { + String name = many.getName(); m.put(name, getPath(prefix, name)); } @@ -167,14 +167,14 @@ class SqlTreeNodeBean implements SqlTreeNode { } idBinder.buildRawSqlSelectChain(prefix, selectChain); } - for (int i = 0, x = properties.length; i < x; i++) { - properties[i].buildRawSqlSelectChain(prefix, selectChain); + for (BeanProperty property : properties) { + property.buildRawSqlSelectChain(prefix, selectChain); } // recursively continue reading... - for (int i = 0; i < children.length; i++) { + for (SqlTreeNode aChildren : children) { // read each child... and let them set their // values back to this localBean - children[i].buildRawSqlSelectChain(selectChain); + aChildren.buildRawSqlSelectChain(selectChain); } } @@ -269,20 +269,20 @@ class SqlTreeNodeBean implements SqlTreeNode { if (inheritInfo == null) { // normal behavior with no inheritance - for (int i = 0, x = properties.length; i < x; i++) { - properties[i].load(sqlBeanLoad); + for (BeanProperty property : properties) { + property.load(sqlBeanLoad); } } else { // take account of inheritance and due to subclassing approach // need to get a 'local' version of the property - for (int i = 0, x = properties.length; i < x; i++) { + for (BeanProperty property : properties) { // get a local version of the BeanProperty - BeanProperty p = localDesc.getBeanProperty(properties[i].getName()); + BeanProperty p = localDesc.getBeanProperty(property.getName()); if (p != null) { p.load(sqlBeanLoad); } else { - properties[i].loadIgnore(ctx); + property.loadIgnore(ctx); } } } @@ -295,10 +295,10 @@ class SqlTreeNodeBean implements SqlTreeNode { } // recursively continue reading... - for (int i = 0; i < children.length; i++) { + for (SqlTreeNode aChildren : children) { // read each child... and let them set their // values back to this localBean - children[i].load(ctx, localBean, contextBean); + aChildren.load(ctx, localBean, contextBean); } if (!lazyLoadMany && localBean != null) { @@ -367,17 +367,17 @@ class SqlTreeNodeBean implements SqlTreeNode { // load the List/Set/Map proxy objects (deferred fetching of lists) BeanPropertyAssocMany[] manys = localDesc.propertiesMany(); - for (int i = 0; i < manys.length; i++) { + for (BeanPropertyAssocMany many : manys) { - if (fetchedMany == null || !fetchedMany.equals(manys[i])) { + if (fetchedMany == null || !fetchedMany.equals(many)) { // create a proxy for the many (deferred fetching) - BeanCollection ref = manys[i].createReferenceIfNull(localBean); + BeanCollection ref = many.createReferenceIfNull(localBean); if (ref != null) { if (disableLazyLoad) { ref.setDisableLazyLoad(true); } if (!ref.isRegisteredWithLoadContext()) { - ctx.register(manys[i].getName(), ref); + ctx.register(many.getName(), ref); } } } @@ -392,9 +392,9 @@ class SqlTreeNodeBean implements SqlTreeNode { if (readId) { appendSelectId(ctx, idBinder.getBeanProperty()); } - for (int i = 0; i < properties.length; i++) { - if (!properties[i].isAggregation()) { - properties[i].appendSelect(ctx, subQuery); + for (BeanProperty property : properties) { + if (!property.isAggregation()) { + property.appendSelect(ctx, subQuery); } } ctx.popTableAlias(); @@ -427,10 +427,10 @@ class SqlTreeNodeBean implements SqlTreeNode { } appendSelect(ctx, subQuery, properties); - for (int i = 0; i < children.length; i++) { + for (SqlTreeNode aChildren : children) { // read each child... and let them set their // values back to this localBean - children[i].appendSelect(ctx, subQuery); + aChildren.appendSelect(ctx, subQuery); } ctx.popTableAlias(); @@ -446,8 +446,8 @@ class SqlTreeNodeBean implements SqlTreeNode { */ private void appendSelect(DbSqlContext ctx, boolean subQuery, BeanProperty[] props) { - for (int i = 0; i < props.length; i++) { - props[i].appendSelect(ctx, subQuery); + for (BeanProperty prop : props) { + prop.appendSelect(ctx, subQuery); } } @@ -480,10 +480,10 @@ class SqlTreeNodeBean implements SqlTreeNode { ctx.append(" ").append(ew).append(" "); } - for (int i = 0; i < children.length; i++) { + for (SqlTreeNode aChildren : children) { // recursively add to the where clause any // fixed predicates (extraWhere etc) - children[i].appendWhere(ctx); + aChildren.appendWhere(ctx); } } @@ -500,13 +500,13 @@ class SqlTreeNodeBean implements SqlTreeNode { // join and return SqlJoinType to use for child joins joinType = appendFromBaseTable(ctx, joinType); - for (int i = 0; i < properties.length; i++) { + for (BeanProperty property : properties) { // usually nothing... except for 1-1 Exported - properties[i].appendFrom(ctx, joinType); + property.appendFrom(ctx, joinType); } - for (int i = 0; i < children.length; i++) { - children[i].appendFrom(ctx, joinType); + for (SqlTreeNode aChildren : children) { + aChildren.appendFrom(ctx, joinType); } ctx.popTableAlias(); @@ -532,8 +532,8 @@ class SqlTreeNodeBean implements SqlTreeNode { if (intersectionAsOfTableAlias) { query.incrementAsOfTableCount(); } - for (int i = 0; i < children.length; i++) { - children[i].addAsOfTableAlias(query); + for (SqlTreeNode aChildren : children) { + aChildren.addAsOfTableAlias(query); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java index e5977e4a5..b605d51f2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java @@ -129,8 +129,7 @@ class SqlTreeNodeExtraJoin implements SqlTreeNode { joinType = joinType.autoToOuter(); } - for (int i = 0; i < children.size(); i++) { - SqlTreeNodeExtraJoin child = children.get(i); + for (SqlTreeNodeExtraJoin child : children) { child.appendFrom(ctx, joinType); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java index 9d03aae91..560709d35 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java @@ -36,8 +36,8 @@ final class SqlTreeNodeRoot extends SqlTreeNodeBean { if (lazyLoadParent != null && lazyLoadParent.isManyToManyWithHistory()) { query.incrementAsOfTableCount(); } - for (int i = 0; i < children.length; i++) { - children[i].addAsOfTableAlias(query); + for (SqlTreeNode aChildren : children) { + aChildren.addAsOfTableAlias(query); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java index df298ab4a..c6c407541 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java @@ -40,8 +40,8 @@ public class SqlTreeProperties { public void add(BeanProperty[] props) { //noinspection ManualArrayToCollectionCopy - for (int i = 0; i < props.length; i++) { - propsList.add(props[i]); + for (BeanProperty prop : props) { + propsList.add(prop); } } @@ -107,4 +107,4 @@ public class SqlTreeProperties { } return null; } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 48f39d412..95516ee4a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -413,15 +413,13 @@ public class DefaultOrmQuery implements SpiQuery { if (orderBy != null) { // remove any orderBy properties that relate to // paths of the secondary queries - for (int i = 0; i < queryJoins.size(); i++) { - OrmQueryProperties joinPath = queryJoins.get(i); - + for (OrmQueryProperties joinPath : queryJoins) { // loop through the orderBy properties and // move any ones related to the query join List properties = orderBy.getProperties(); Iterator it = properties.iterator(); while (it.hasNext()) { - OrderBy.Property property = it.next(); + Property property = it.next(); if (property.getProperty().startsWith(joinPath.getPath())) { // remove this orderBy segment and // add it to the secondary join diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java index a1c388355..234bfe5ef 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java @@ -208,8 +208,7 @@ public class OrmQueryDetail implements Serializable { // the list of secondary queries ArrayList props = new ArrayList<>(); - for (int i = 0; i < matchingPaths.size(); i++) { - String path = matchingPaths.get(i); + for (String path : matchingPaths) { OrmQueryProperties secQuery = fetchPaths.remove(path); if (secQuery != null) { props.add(secQuery); @@ -231,8 +230,8 @@ public class OrmQueryDetail implements Serializable { // Add the secondary queries as select properties // to the parent chunk to ensure the foreign keys // are included in the query - for (int i = 0; i < props.size(); i++) { - String path = props.get(i).getPath(); + for (OrmQueryProperties prop : props) { + String path = prop.getPath(); // split into parent and property String[] split = SplitName.split(path); // add property to parent chunk diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java index e41534c31..c7cac78b5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java @@ -250,8 +250,7 @@ public class OrmQueryProperties implements Serializable { if (secondaryChildren != null) { int trimPath = path.length() + 1; - for (int i = 0; i < secondaryChildren.size(); i++) { - OrmQueryProperties p = secondaryChildren.get(i); + for (OrmQueryProperties p : secondaryChildren) { String path = p.getPath(); path = path.substring(trimPath); query.fetch(path, p.getProperties(), p.getFetchConfig()); diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java index b6d475c53..6be8be81d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java @@ -120,8 +120,8 @@ class OrmQueryPropertiesParser { int count = 0; String temp; - for (int i = 0; i < res.length; i++) { - temp = res[i].trim(); + for (String re : res) { + temp = re.trim(); if (!temp.isEmpty()) { if (count > 0) { sb.append(","); diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java b/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java index 3fe34fe90..a99acfec4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java @@ -218,26 +218,26 @@ public class TCsvReader implements CsvReader { } private void addPropertiesFromHeader(String[] line) { - for (int i = 0; i < line.length; i++) { - ElPropertyValue elProp = descriptor.getElGetValue(line[i]); - if (elProp == null) { - throw new TextException("Property [" + line[i] + "] not found"); - } + for (String aLine : line) { + ElPropertyValue elProp = descriptor.getElGetValue(aLine); + if (elProp == null) { + throw new TextException("Property [" + aLine + "] not found"); + } - if (Types.TIME == elProp.getJdbcType()) { - addProperty(line[i], TIME_PARSER); + if (Types.TIME == elProp.getJdbcType()) { + addProperty(aLine, TIME_PARSER); - } else if (isDateTimeType(elProp.getJdbcType())) { - addDateTime(line[i], null, null); + } else if (isDateTimeType(elProp.getJdbcType())) { + addDateTime(aLine, null, null); - } else if (elProp.isAssocProperty()) { - BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne) elProp.getBeanProperty(); - String idProp = assocOne.getBeanDescriptor().getIdBinder().getIdProperty(); - addProperty(line[i] + "." + idProp); - } else { - addProperty(line[i]); - } - } + } else if (elProp.isAssocProperty()) { + BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne) elProp.getBeanProperty(); + String idProp = assocOne.getBeanDescriptor().getIdBinder().getIdProperty(); + addProperty(aLine + "." + idProp); + } else { + addProperty(aLine); + } + } } private boolean isDateTimeType(int t) { @@ -257,7 +257,7 @@ public class TCsvReader implements CsvReader { } return bean; - + } catch (RuntimeException e) { String msg = "Error at line: " + row + " line[" + Arrays.toString(line) + "]"; throw new RuntimeException(msg, e); diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java index aa01245af..f7713cd4c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java @@ -488,15 +488,15 @@ public class WriteJson implements JsonWriter { if (!isReferenceOnly()) { // render all the properties and invoke lazy loading if required BeanProperty[] props = desc.propertiesNonTransient(); - for (int j = 0; j < props.length; j++) { - if (isIncludeProperty(props[j])) { - props[j].jsonWrite(writeJson, currentBean); + for (BeanProperty prop1 : props) { + if (isIncludeProperty(prop1)) { + prop1.jsonWrite(writeJson, currentBean); } } props = desc.propertiesTransient(); - for (int j = 0; j < props.length; j++) { - if (isIncludeTransientProperty(props[j])) { - props[j].jsonWrite(writeJson, currentBean); + for (BeanProperty prop : props) { + if (isIncludeTransientProperty(prop)) { + prop.jsonWrite(writeJson, currentBean); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java index 03c6c344b..4bc583d9b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java @@ -222,14 +222,12 @@ public class BeanPersistIds { beanDescriptor.queryCacheClear(); if (updateIds != null) { - for (int i = 0; i < updateIds.size(); i++) { - Object id = updateIds.get(i); + for (Object id : updateIds) { beanDescriptor.cacheHandleDeleteById(id); } } if (deleteIds != null) { - for (int i = 0; i < deleteIds.size(); i++) { - Object id = deleteIds.get(i); + for (Object id : deleteIds) { beanDescriptor.cacheHandleDeleteById(id); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java index ed56e9946..ca634cf73 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java @@ -55,8 +55,8 @@ public class BulkEventListenerMap { } private void process(BulkTableEvent event) { - for (int i = 0; i < listeners.size(); i++) { - listeners.get(i).process(event); + for (BulkTableEventListener listener : listeners) { + listener.process(event); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java index 3f00a02f0..20ed290a9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java @@ -31,8 +31,8 @@ public final class DeleteByIdMap { List idValues = deleteIds.getDeleteIds(); if (idValues != null) { d.queryCacheClear(changeSet); - for (int i = 0; i < idValues.size(); i++) { - d.cacheHandleDeleteById(idValues.get(i), changeSet); + for (Object idValue : idValues) { + d.cacheHandleDeleteById(idValue, changeSet); } } } @@ -61,8 +61,8 @@ public final class DeleteByIdMap { public void addList(BeanDescriptor desc, List idList) { BeanPersistIds r = getPersistIds(desc); - for (int i = 0; i < idList.size(); i++) { - r.addId(PersistRequest.Type.DELETE, (Serializable) idList.get(i)); + for (Object anIdList : idList) { + r.addId(PersistRequest.Type.DELETE, (Serializable) anIdList); } } @@ -89,11 +89,11 @@ public final class DeleteByIdMap { String queueId = desc.getDocStoreQueueId(); List idValues = deleteIds.getDeleteIds(); if (idValues != null) { - for (int i = 0; i < idValues.size(); i++) { + for (Object idValue : idValues) { if (queue) { - docStoreUpdates.queueDelete(queueId, idValues.get(i)); + docStoreUpdates.queueDelete(queueId, idValue); } else { - docStoreUpdates.addDelete(new DocStoreDeleteEvent(desc, idValues.get(i))); + docStoreUpdates.addDelete(new DocStoreDeleteEvent(desc, idValue)); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java index cc4b2c0e6..8c52986c2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java @@ -171,8 +171,8 @@ public final class PostCommitProcessing { private void localPersistListenersNotify() { if (persistBeanRequests != null) { - for (int i = 0; i < persistBeanRequests.size(); i++) { - persistBeanRequests.get(i).notifyLocalPersistListener(); + for (PersistRequestBean persistBeanRequest : persistBeanRequests) { + persistBeanRequest.notifyLocalPersistListener(); } } TransactionEventTable eventTables = event.getEventTables(); @@ -191,8 +191,8 @@ public final class PostCommitProcessing { } BeanPersistIdMap m = new BeanPersistIdMap(); - for (int i = 0; i < persistBeanRequests.size(); i++) { - persistBeanRequests.get(i).addToPersistMap(m); + for (PersistRequestBean persistBeanRequest : persistBeanRequests) { + persistBeanRequest.addToPersistMap(m); } return m; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java index 77e72c59b..1983c3cd5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java @@ -49,8 +49,8 @@ public class RemoteTransactionEvent implements Runnable { public void writeBinaryMessage(BinaryMessageList msgList) throws IOException { if (tableList != null) { - for (int i = 0; i < tableList.size(); i++) { - tableList.get(i).writeBinaryMessage(msgList); + for (TableIUD aTableList : tableList) { + aTableList.writeBinaryMessage(msgList); } } @@ -60,8 +60,8 @@ public class RemoteTransactionEvent implements Runnable { } } - for (int i = 0; i < beanPersistList.size(); i++) { - beanPersistList.get(i).writeBinaryMessage(msgList); + for (BeanPersistIds aBeanPersistList : beanPersistList) { + aBeanPersistList.writeBinaryMessage(msgList); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java index 68e477df7..9afe59a23 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java @@ -390,8 +390,7 @@ public class TransactionManager { List tableIUDList = remoteEvent.getTableIUDList(); if (tableIUDList != null) { - for (int i = 0; i < tableIUDList.size(); i++) { - TableIUD tableIUD = tableIUDList.get(i); + for (TableIUD tableIUD : tableIUDList) { beanDescriptorManager.cacheNotify(tableIUD); } } @@ -400,8 +399,8 @@ public class TransactionManager { // processes both Bean IUD and DeleteById List beanPersistList = remoteEvent.getBeanPersistList(); if (beanPersistList != null) { - for (int i = 0; i < beanPersistList.size(); i++) { - beanPersistList.get(i).notifyCacheAndListener(); + for (BeanPersistIds aBeanPersistList : beanPersistList) { + aBeanPersistList.notifyCacheAndListener(); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java index 7def927ec..24d23a5fa 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java @@ -87,8 +87,8 @@ public final class CtCompoundType implements ScalarDataReader { } public void loadIgnore(DataReader dataReader) { - for (int i = 0; i < propReaders.length; i++) { - propReaders[i].loadIgnore(dataReader); + for (ScalarDataReader propReader : propReaders) { + propReader.loadIgnore(dataReader); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java index 67fb843e3..ef5753f74 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java @@ -391,9 +391,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { return recursiveCreateScalarDataReader(propertyType); } - for (int i = 0; i < customScalarTypes.size(); i++) { - ScalarType customScalarType = customScalarTypes.get(i); - + for (ScalarType customScalarType : customScalarTypes) { if (sqlType == customScalarType.getJdbcType() && (propertyType.equals(customScalarType.getType()))) { return customScalarType; @@ -623,10 +621,10 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { Map nameValueMap = new HashMap<>(); Field[] fields = enumType.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - EnumValue enumValue = fields[i].getAnnotation(EnumValue.class); + for (Field field : fields) { + EnumValue enumValue = field.getAnnotation(EnumValue.class); if (enumValue != null) { - nameValueMap.put(fields[i].getName(), enumValue.value()); + nameValueMap.put(field.getName(), enumValue.value()); if (integerType && !isIntegerType(enumValue.value())) { // will treat the values as strings integerType = false; @@ -653,11 +651,11 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { public ScalarType createEnumScalarType(Class> enumType) { Method[] methods = enumType.getMethods(); - for (int i = 0; i < methods.length; i++) { - DbEnumValue dbValue = methods[i].getAnnotation(DbEnumValue.class); + for (Method method : methods) { + DbEnumValue dbValue = method.getAnnotation(DbEnumValue.class); if (dbValue != null) { boolean integerValues = DbEnumType.INTEGER == dbValue.storage(); - return createEnumScalarTypeDbValue(enumType, methods[i], integerValues); + return createEnumScalarTypeDbValue(enumType, method, integerValues); } } @@ -677,12 +675,12 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { Map nameValueMap = new HashMap<>(); Enum[] enumConstants = enumType.getEnumConstants(); - for (int i = 0; i < enumConstants.length; i++) { + for (Enum enumConstant : enumConstants) { try { - Object value = method.invoke(enumConstants[i]); - nameValueMap.put(enumConstants[i].name(), value.toString()); + Object value = method.invoke(enumConstant); + nameValueMap.put(enumConstant.name(), value.toString()); } catch (Exception e) { - throw new IllegalArgumentException("Error trying to invoke DbEnumValue method on " + enumConstants[i], e); + throw new IllegalArgumentException("Error trying to invoke DbEnumValue method on " + enumConstant, e); } } if (nameValueMap.isEmpty()) { @@ -737,8 +735,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { List>> foundTypes = bootupClasses.getScalarTypes(); - for (int i = 0; i < foundTypes.size(); i++) { - Class> cls = foundTypes.get(i); + for (Class> cls : foundTypes) { try { ScalarType scalarType; @@ -783,8 +780,8 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { List>> foundTypes = bootupClasses.getScalarConverters(); - for (int i = 0; i < foundTypes.size(); i++) { - Class cls = foundTypes.get(i); + for (Class> foundType : foundTypes) { + Class cls = foundType; try { Class[] paramTypes = TypeReflectHelper.getParams(cls, ScalarTypeConverter.class); @@ -818,9 +815,9 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { private void initialiseCompoundTypes(BootupClasses bootupClasses) { List>> compoundTypes = bootupClasses.getCompoundTypes(); - for (int j = 0; j < compoundTypes.size(); j++) { + for (Class> compoundType1 : compoundTypes) { - Class type = compoundTypes.get(j); + Class type = compoundType1; try { Class[] paramTypes = TypeReflectHelper.getParams(type, CompoundType.class); diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java index 1712c6dfe..dbf2276fd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java @@ -49,8 +49,8 @@ public class ScalarTypeEnumStandard { LinkedHashSet values = new LinkedHashSet<>(); Object[] ea = enumType.getEnumConstants(); - for (int i = 0; i < ea.length; i++) { - Enum e = (Enum) ea[i]; + for (Object anEa : ea) { + Enum e = (Enum) anEa; values.add("'" + e.name() + "'"); } return values; @@ -61,8 +61,8 @@ public class ScalarTypeEnumStandard { int maxLen = 0; Object[] ea = enumType.getEnumConstants(); - for (int i = 0; i < ea.length; i++) { - Enum e = (Enum) ea[i]; + for (Object anEa : ea) { + Enum e = (Enum) anEa; maxLen = Math.max(maxLen, e.name().length()); } @@ -130,8 +130,8 @@ public class ScalarTypeEnumStandard { public Set getDbCheckConstraintValues() { LinkedHashSet values = new LinkedHashSet<>(); - for (int i = 0; i < enumArray.length; i++) { - Enum e = (Enum) enumArray[i]; + for (Object anEnumArray : enumArray) { + Enum e = (Enum) anEnumArray; values.add(Integer.toString(e.ordinal())); } return values; diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/TypeReflectHelper.java b/src/main/java/com/avaje/ebeaninternal/server/type/TypeReflectHelper.java index 90bdab8c6..0504961d2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/TypeReflectHelper.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/TypeReflectHelper.java @@ -27,8 +27,7 @@ public class TypeReflectHelper { private static Type[] getParamType(Class cls, Class matchRawType) { Type[] gis = cls.getGenericInterfaces(); - for (int i = 0; i < gis.length; i++) { - Type type = gis[i]; + for (Type type : gis) { if (type instanceof ParameterizedType) { ParameterizedType paramType = (ParameterizedType) type; Type rawType = paramType.getRawType(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/CheckImmutable.java b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/CheckImmutable.java index 24b5a3cd8..b491511ae 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/CheckImmutable.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/CheckImmutable.java @@ -39,11 +39,11 @@ public class CheckImmutable { // find the constructor with the most number of parameters Constructor[] constructors = cls.getConstructors(); - for (int i = 0; i < constructors.length; i++) { - Class[] parameterTypes = constructors[i].getParameterTypes(); + for (Constructor constructor : constructors) { + Class[] parameterTypes = constructor.getParameterTypes(); if (parameterTypes.length > maxLength) { maxLength = parameterTypes.length; - chosen = constructors[i]; + chosen = constructor; } } @@ -90,14 +90,14 @@ public class CheckImmutable { // Check all fields defined in the class for type and if they are final Field[] objFields = cls.getDeclaredFields(); - for (int i = 0; i < objFields.length; i++) { - if (!Modifier.isStatic(objFields[i].getModifiers())) { - if (!Modifier.isFinal(objFields[i].getModifiers())) { - res.setReasonNotImmutable("Non final field " + cls + "." + objFields[i].getName()); + for (Field objField : objFields) { + if (!Modifier.isStatic(objField.getModifiers())) { + if (!Modifier.isFinal(objField.getModifiers())) { + res.setReasonNotImmutable("Non final field " + cls + "." + objField.getName()); return false; } - if (!isImmutable(objFields[i].getType(), res)) { - res.setReasonNotImmutable("Non Immutable field type " + objFields[i].getType()); + if (!isImmutable(objField.getType(), res)) { + res.setReasonNotImmutable("Non Immutable field type " + objField.getType()); return false; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java index 738a8dd19..0be11f55f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java @@ -25,8 +25,8 @@ public class ImmutableMetaFactory { // search the constructors in score order ... // ... we need to find a set of readers for each // ... type in the constructor - for (int i = 0; i < scoreConstructors.length; i++) { - Constructor constructor = scoreConstructors[i].constructor; + for (ScoreConstructor scoreConstructor : scoreConstructors) { + Constructor constructor = scoreConstructor.constructor; try { Method[] getters = findGetters(cls, constructor); @@ -58,31 +58,31 @@ public class ImmutableMetaFactory { Class[] parameterTypes = c.getParameterTypes(); int score = -1000 * parameterTypes.length; - for (int i = 0; i < parameterTypes.length; i++) { - if (parameterTypes[i].equals(String.class)) { + for (Class parameterType : parameterTypes) { + if (parameterType.equals(String.class)) { // string is very generic and we would prefer // a more specific type if that was available score = score + 1; - } else if (parameterTypes[i].equals(BigDecimal.class)) { + } else if (parameterType.equals(BigDecimal.class)) { score = score - 10; - } else if (parameterTypes[i].equals(Timestamp.class)) { + } else if (parameterType.equals(Timestamp.class)) { score = score - 10; - } else if (parameterTypes[i].equals(double.class)) { + } else if (parameterType.equals(double.class)) { score = score - 9; - } else if (parameterTypes[i].equals(Double.class)) { + } else if (parameterType.equals(Double.class)) { score = score - 8; - } else if (parameterTypes[i].equals(float.class)) { + } else if (parameterType.equals(float.class)) { score = score - 7; - } else if (parameterTypes[i].equals(Float.class)) { + } else if (parameterType.equals(Float.class)) { score = score - 6; - } else if (parameterTypes[i].equals(long.class)) { + } else if (parameterType.equals(long.class)) { score = score - 5; - } else if (parameterTypes[i].equals(Long.class)) { + } else if (parameterType.equals(Long.class)) { score = score - 4; - } else if (parameterTypes[i].equals(int.class)) { + } else if (parameterType.equals(int.class)) { score = score - 3; - } else if (parameterTypes[i].equals(Integer.class)) { + } else if (parameterType.equals(Integer.class)) { score = score - 2; } } @@ -112,9 +112,9 @@ public class ImmutableMetaFactory { // filter out any constructors with less parameters than the max ArrayList list = new ArrayList<>(); - for (int i = 0; i < score.length; i++) { - if (score[i].getParamCount() == maxParamCount) { - list.add(score[i]); + for (ScoreConstructor aScore : score) { + if (aScore.getParamCount() == maxParamCount) { + list.add(aScore); } } @@ -160,15 +160,15 @@ public class ImmutableMetaFactory { private Method findGetter(Class paramType, Method[] methods) { - for (int i = 0; i < methods.length; i++) { - if (!Modifier.isStatic(methods[i].getModifiers())) { - if (methods[i].getParameterTypes().length == 0) { + for (Method method : methods) { + if (!Modifier.isStatic(method.getModifiers())) { + if (method.getParameterTypes().length == 0) { // could be a getter - String methName = methods[i].getName(); + String methName = method.getName(); if (!methName.equals("hashCode") && !methName.equals("toString")) { - Class returnType = methods[i].getReturnType(); + Class returnType = method.getReturnType(); if (paramType.equals(returnType)) { - return methods[i]; + return method; } } } @@ -208,8 +208,8 @@ public class ImmutableMetaFactory { return false; } HashSet> set = new HashSet<>(); - for (int i = 0; i < parameterTypes.length; i++) { - if (!set.add(parameterTypes[i])) { + for (Class parameterType : parameterTypes) { + if (!set.add(parameterType)) { return true; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/util/Md5.java b/src/main/java/com/avaje/ebeaninternal/server/util/Md5.java index 448c4b239..e51b16cbb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/util/Md5.java +++ b/src/main/java/com/avaje/ebeaninternal/server/util/Md5.java @@ -24,8 +24,8 @@ public class Md5 { private static String digestToHex(byte[] digest) { StringBuilder sb = new StringBuilder(); - for (int i = 0; i < digest.length; i++) { - sb.append(Integer.toString((digest[i] & 0xff) + 0x100, 16).substring(1)); + for (byte aDigest : digest) { + sb.append(Integer.toString((aDigest & 0xff) + 0x100, 16).substring(1)); } return sb.toString(); } diff --git a/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java b/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java index b40a596a1..bf2020e5a 100644 --- a/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java +++ b/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java @@ -19,8 +19,8 @@ public final class SortByClauseParser { SortByClause sortBy = new SortByClause(); String[] sections = rawSortBy.split(","); - for (int i = 0; i < sections.length; i++) { - Property p = parseSection(sections[i].trim()); + for (String section : sections) { + Property p = parseSection(section.trim()); if (p == null) { break; } else { diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java index 942094df6..bf5ca3249 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java @@ -232,8 +232,8 @@ public abstract class DocStoreBeanBaseAdapter implements DocStoreBeanAdapter< @Override public void updateEmbedded(PersistRequestBean request, DocStoreUpdates docStoreUpdates) { - for (int i = 0; i < embeddedInvalidation.size(); i++) { - embeddedInvalidation.get(i).embeddedInvalidate(request, docStoreUpdates); + for (DocStoreEmbeddedInvalidation anEmbeddedInvalidation : embeddedInvalidation) { + anEmbeddedInvalidation.embeddedInvalidate(request, docStoreUpdates); } } @@ -256,8 +256,8 @@ public abstract class DocStoreBeanBaseAdapter implements DocStoreBeanAdapter< final DocStructure docStructure = new DocStructure(pathProps); BeanProperty[] properties = desc.propertiesNonTransient(); - for (int i = 0; i < properties.length; i++) { - properties[i].docStoreInclude(includeByDefault, docStructure); + for (BeanProperty property : properties) { + property.docStoreInclude(includeByDefault, docStructure); } InheritInfo inheritInfo = desc.getInheritInfo(); diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/InExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/InExpressionTest.java index e52824f92..a4b0df3cb 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/InExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/InExpressionTest.java @@ -98,8 +98,8 @@ public class InExpressionTest { List values(int... vals) { ArrayList list = new ArrayList(); - for (int i = 0; i < vals.length; i++) { - list.add(vals[i]); + for (int val : vals) { + list.add(val); } return list; } @@ -171,4 +171,4 @@ public class InExpressionTest { assertThat(exp("a", false, 10, "ABC").isSameByBind(exp("a", false, 10, "ABC", 30))).isFalse(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java b/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java index 5ccb67a97..71a6768d5 100644 --- a/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java +++ b/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java @@ -30,8 +30,8 @@ public class TestBatchLazyWithCacheHits extends BaseTestCase { ArrayList inserted = new ArrayList<>(); String[] names = "A,B,C,D,E,F,G,H,I,J".split(","); - for (int i = 0; i < names.length; i++) { - inserted.add(insert(names[i])); + for (String name : names) { + inserted.add(insert(name)); } ServerCacheManager serverCacheManager = Ebean.getDefaultServer().getServerCacheManager(); diff --git a/src/test/java/com/avaje/tests/query/TestAutofetchTuneWithJoin.java b/src/test/java/com/avaje/tests/query/TestAutofetchTuneWithJoin.java index cc0fd4be7..fa86f7b4d 100644 --- a/src/test/java/com/avaje/tests/query/TestAutofetchTuneWithJoin.java +++ b/src/test/java/com/avaje/tests/query/TestAutofetchTuneWithJoin.java @@ -34,8 +34,7 @@ public class TestAutofetchTuneWithJoin extends BaseTestCase { List list = q.findList(); - for (int i = 0; i < list.size(); i++) { - Order order = list.get(i); + for (Order order : list) { order.getOrderDate(); order.getShipDate(); // order.setShipDate(new Date(System.currentTimeMillis()));