Le metric crapload of generics cleanup.

This commit is contained in:
Michael Bayne
2008-07-30 13:53:24 +00:00
parent 4e002054e4
commit 8f2cf98c17
24 changed files with 152 additions and 145 deletions
@@ -73,14 +73,14 @@ public class BindVisitor implements ExpressionVisitor
public void visit (WhereCondition<? extends PersistentRecord> whereCondition) public void visit (WhereCondition<? extends PersistentRecord> whereCondition)
throws Exception throws Exception
{ {
for (Comparable value : whereCondition.getValues()) { for (Comparable<?> value : whereCondition.getValues()) {
if (value != null) { if (value != null) {
_stmt.setObject(_argIdx ++, value); _stmt.setObject(_argIdx ++, value);
} }
} }
} }
public void visit (Key key) public void visit (Key<? extends PersistentRecord> key)
throws Exception throws Exception
{ {
key.condition.accept(this); key.condition.accept(this);
@@ -89,12 +89,13 @@ public class BindVisitor implements ExpressionVisitor
public void visit (MultiKey<? extends PersistentRecord> key) public void visit (MultiKey<? extends PersistentRecord> key)
throws Exception throws Exception
{ {
for (Map.Entry entry : key.getSingleFieldsMap().entrySet()) {
for (Map.Entry<String, Comparable<?>> entry : key.getSingleFieldsMap().entrySet()) {
if (entry.getValue() != null) { if (entry.getValue() != null) {
_stmt.setObject(_argIdx ++, entry.getValue()); _stmt.setObject(_argIdx ++, entry.getValue());
} }
} }
Comparable[] values = key.getMultiValues(); Comparable<?>[] values = key.getMultiValues();
for (int ii = 0; ii < values.length; ii++) { for (int ii = 0; ii < values.length; ii++) {
_stmt.setObject(_argIdx ++, values[ii]); _stmt.setObject(_argIdx ++, values[ii]);
} }
@@ -130,7 +131,7 @@ public class BindVisitor implements ExpressionVisitor
public void visit (In in) throws Exception public void visit (In in) throws Exception
{ {
Comparable[] values = in.getValues(); Comparable<?>[] values = in.getValues();
for (int ii = 0; ii < values.length; ii++) { for (int ii = 0; ii < values.length; ii++) {
_stmt.setObject(_argIdx ++, values[ii]); _stmt.setObject(_argIdx ++, values[ii]);
} }
@@ -229,7 +230,7 @@ public class BindVisitor implements ExpressionVisitor
public void visit (UpdateClause<? extends PersistentRecord> updateClause) throws Exception public void visit (UpdateClause<? extends PersistentRecord> updateClause) throws Exception
{ {
DepotMarshaller marsh = _types.getMarshaller(updateClause.getPersistentClass()); DepotMarshaller<?> marsh = _types.getMarshaller(updateClause.getPersistentClass());
// bind the update arguments // bind the update arguments
String[] fields = updateClause.getFields(); String[] fields = updateClause.getFields();
@@ -251,7 +252,7 @@ public class BindVisitor implements ExpressionVisitor
public void visit (InsertClause<? extends PersistentRecord> insertClause) throws Exception public void visit (InsertClause<? extends PersistentRecord> insertClause) throws Exception
{ {
DepotMarshaller marsh = _types.getMarshaller(insertClause.getPersistentClass()); DepotMarshaller<?> marsh = _types.getMarshaller(insertClause.getPersistentClass());
Object pojo = insertClause.getPojo(); Object pojo = insertClause.getPojo();
Set<String> idFields = insertClause.getIdentityFields(); Set<String> idFields = insertClause.getIdentityFields();
@@ -98,7 +98,7 @@ public abstract class BuildVisitor implements ExpressionVisitor
{ {
Class<? extends PersistentRecord> pClass = whereCondition.getPersistentClass(); Class<? extends PersistentRecord> pClass = whereCondition.getPersistentClass();
String[] keyFields = Key.getKeyFields(pClass); String[] keyFields = Key.getKeyFields(pClass);
List<Comparable> values = whereCondition.getValues(); List<Comparable<?>> values = whereCondition.getValues();
for (int ii = 0; ii < keyFields.length; ii ++) { for (int ii = 0; ii < keyFields.length; ii ++) {
if (ii > 0) { if (ii > 0) {
_builder.append(" and "); _builder.append(" and ");
@@ -113,7 +113,7 @@ public abstract class BuildVisitor implements ExpressionVisitor
} }
} }
public void visit (Key key) public void visit (Key<? extends PersistentRecord> key)
throws Exception throws Exception
{ {
_builder.append(" where "); _builder.append(" where ");
@@ -125,7 +125,7 @@ public abstract class BuildVisitor implements ExpressionVisitor
{ {
_builder.append(" where "); _builder.append(" where ");
boolean first = true; boolean first = true;
for (Map.Entry<String, Comparable> entry : key.getSingleFieldsMap().entrySet()) { for (Map.Entry<String, Comparable<?>> entry : key.getSingleFieldsMap().entrySet()) {
if (first) { if (first) {
first = false; first = false;
} else { } else {
@@ -145,7 +145,7 @@ public abstract class BuildVisitor implements ExpressionVisitor
appendRhsColumn(key.getPersistentClass(), key.getMultiField()); appendRhsColumn(key.getPersistentClass(), key.getMultiField());
_builder.append(" in ("); _builder.append(" in (");
Comparable[] values = key.getMultiValues(); Comparable<?>[] values = key.getMultiValues();
for (int ii = 0; ii < values.length; ii ++) { for (int ii = 0; ii < values.length; ii ++) {
if (ii > 0) { if (ii > 0) {
_builder.append(", "); _builder.append(", ");
@@ -206,7 +206,7 @@ public abstract class BuildVisitor implements ExpressionVisitor
{ {
in.getColumn().accept(this); in.getColumn().accept(this);
_builder.append(" in ("); _builder.append(" in (");
Comparable[] values = in.getValues(); Comparable<?>[] values = in.getValues();
for (int ii = 0; ii < values.length; ii ++) { for (int ii = 0; ii < values.length; ii ++) {
if (ii > 0) { if (ii > 0) {
_builder.append(", "); _builder.append(", ");
@@ -465,7 +465,7 @@ public abstract class BuildVisitor implements ExpressionVisitor
throws Exception throws Exception
{ {
Class<? extends PersistentRecord> pClass = insertClause.getPersistentClass(); Class<? extends PersistentRecord> pClass = insertClause.getPersistentClass();
DepotMarshaller marsh = _types.getMarshaller(pClass); DepotMarshaller<?> marsh = _types.getMarshaller(pClass);
_innerClause = true; _innerClause = true;
String[] fields = marsh.getColumnFieldNames(); String[] fields = marsh.getColumnFieldNames();
@@ -514,8 +514,8 @@ public abstract class BuildVisitor implements ExpressionVisitor
protected void appendLhsColumn (Class<? extends PersistentRecord> type, String field) protected void appendLhsColumn (Class<? extends PersistentRecord> type, String field)
throws Exception throws Exception
{ {
DepotMarshaller dm = _types.getMarshaller(type); DepotMarshaller<?> dm = _types.getMarshaller(type);
FieldMarshaller fm = dm.getFieldMarshaller(field); FieldMarshaller<?> fm = dm.getFieldMarshaller(field);
if (dm == null) { if (dm == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Unknown field on persistent record [record=" + type + ", field=" + field + "]"); "Unknown field on persistent record [record=" + type + ", field=" + field + "]");
@@ -529,8 +529,8 @@ public abstract class BuildVisitor implements ExpressionVisitor
protected void appendRhsColumn (Class<? extends PersistentRecord> type, String field) protected void appendRhsColumn (Class<? extends PersistentRecord> type, String field)
throws Exception throws Exception
{ {
DepotMarshaller dm = _types.getMarshaller(type); DepotMarshaller<?> dm = _types.getMarshaller(type);
FieldMarshaller fm = dm.getFieldMarshaller(field); FieldMarshaller<?> fm = dm.getFieldMarshaller(field);
if (dm == null) { if (dm == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Unknown field on persistent record [record=" + type + ", field=" + field + "]"); "Unknown field on persistent record [record=" + type + ", field=" + field + "]");
@@ -120,14 +120,14 @@ public class DepotMarshaller<T extends PersistentRecord>
continue; continue;
} }
FieldMarshaller fm = FieldMarshaller.createMarshaller(field); FieldMarshaller<?> fm = FieldMarshaller.createMarshaller(field);
_fields.put(field.getName(), fm); _fields.put(field.getName(), fm);
fields.add(field.getName()); fields.add(field.getName());
// check to see if this is our primary key // check to see if this is our primary key
if (field.getAnnotation(Id.class) != null) { if (field.getAnnotation(Id.class) != null) {
if (_pkColumns == null) { if (_pkColumns == null) {
_pkColumns = new ArrayList<FieldMarshaller>(); _pkColumns = new ArrayList<FieldMarshaller<?>>();
} }
_pkColumns.add(fm); _pkColumns.add(fm);
} }
@@ -194,7 +194,7 @@ public class DepotMarshaller<T extends PersistentRecord>
String[] conFields = constraint.fieldNames(); String[] conFields = constraint.fieldNames();
Set<String> colSet = new HashSet<String>(); Set<String> colSet = new HashSet<String>();
for (int ii = 0; ii < conFields.length; ii ++) { for (int ii = 0; ii < conFields.length; ii ++) {
FieldMarshaller fm = _fields.get(conFields[ii]); FieldMarshaller<?> fm = _fields.get(conFields[ii]);
if (fm == null) { if (fm == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Unknown unique constraint field: " + conFields[ii]); "Unknown unique constraint field: " + conFields[ii]);
@@ -287,7 +287,7 @@ public class DepotMarshaller<T extends PersistentRecord>
/** /**
* Returns the {@link FieldMarshaller} for a named field on our persistent class. * Returns the {@link FieldMarshaller} for a named field on our persistent class.
*/ */
public FieldMarshaller getFieldMarshaller (String fieldName) public FieldMarshaller<?> getFieldMarshaller (String fieldName)
{ {
return _fields.get(fieldName); return _fields.get(fieldName);
} }
@@ -349,11 +349,11 @@ public class DepotMarshaller<T extends PersistentRecord>
} }
try { try {
Comparable[] values = new Comparable[_pkColumns.size()]; Comparable<?>[] values = new Comparable<?>[_pkColumns.size()];
int nulls = 0; int nulls = 0;
for (int ii = 0; ii < _pkColumns.size(); ii++) { for (int ii = 0; ii < _pkColumns.size(); ii++) {
FieldMarshaller field = _pkColumns.get(ii); FieldMarshaller<?> field = _pkColumns.get(ii);
if ((values[ii] = (Comparable)field.getField().get(object)) == null) { if ((values[ii] = (Comparable<?>)field.getField().get(object)) == null) {
nulls++; nulls++;
} }
} }
@@ -383,7 +383,7 @@ public class DepotMarshaller<T extends PersistentRecord>
* Creates a primary key record for the type of object handled by this marshaller, using the * Creates a primary key record for the type of object handled by this marshaller, using the
* supplied primary key value. * supplied primary key value.
*/ */
public Key<T> makePrimaryKey (Comparable... values) public Key<T> makePrimaryKey (Comparable<?>... values)
{ {
if (!hasPrimaryKey()) { if (!hasPrimaryKey()) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
@@ -407,14 +407,14 @@ public class DepotMarshaller<T extends PersistentRecord>
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
getClass().getName() + " does not define a primary key"); getClass().getName() + " does not define a primary key");
} }
Comparable[] values = new Comparable[_pkColumns.size()]; Comparable<?>[] values = new Comparable<?>[_pkColumns.size()];
for (int ii = 0; ii < _pkColumns.size(); ii++) { for (int ii = 0; ii < _pkColumns.size(); ii++) {
Object keyValue = _pkColumns.get(ii).getFromSet(rs); Object keyValue = _pkColumns.get(ii).getFromSet(rs);
if (!(keyValue instanceof Comparable)) { if (!(keyValue instanceof Comparable<?>)) {
throw new IllegalArgumentException("Key field must be Comparable [field=" + throw new IllegalArgumentException("Key field must be Comparable<?> [field=" +
_pkColumns.get(ii).getColumnName() + "]"); _pkColumns.get(ii).getColumnName() + "]");
} }
values[ii] = (Comparable) keyValue; values[ii] = (Comparable<?>) keyValue;
} }
return makePrimaryKey(values); return makePrimaryKey(values);
} }
@@ -445,7 +445,7 @@ public class DepotMarshaller<T extends PersistentRecord>
// then create and populate the persistent object // then create and populate the persistent object
T po = _pClass.newInstance(); T po = _pClass.newInstance();
for (FieldMarshaller fm : _fields.values()) { for (FieldMarshaller<?> fm : _fields.values()) {
if (!fields.contains(fm.getColumnName())) { if (!fields.contains(fm.getColumnName())) {
// this field was not in the result set, make sure that's OK // this field was not in the result set, make sure that's OK
if (fm.getComputed() != null && !fm.getComputed().required()) { if (fm.getComputed() != null && !fm.getComputed().required()) {
@@ -530,7 +530,7 @@ public class DepotMarshaller<T extends PersistentRecord>
final SQLBuilder builder = ctx.getSQLBuilder(new DepotTypes(ctx, _pClass)); final SQLBuilder builder = ctx.getSQLBuilder(new DepotTypes(ctx, _pClass));
// perform the context-sensitive initialization of the field marshallers // perform the context-sensitive initialization of the field marshallers
for (FieldMarshaller fm : _fields.values()) { for (FieldMarshaller<?> fm : _fields.values()) {
fm.init(builder); fm.init(builder);
} }
@@ -545,7 +545,7 @@ public class DepotMarshaller<T extends PersistentRecord>
ColumnDefinition[] declarations = new ColumnDefinition[_allFields.length]; ColumnDefinition[] declarations = new ColumnDefinition[_allFields.length];
int jj = 0; int jj = 0;
for (int ii = 0; ii < _allFields.length; ii++) { for (int ii = 0; ii < _allFields.length; ii++) {
FieldMarshaller fm = _fields.get(_allFields[ii]); FieldMarshaller<?> fm = _fields.get(_allFields[ii]);
// include all persistent non-computed fields // include all persistent non-computed fields
ColumnDefinition colDef = fm.getColumnDefinition(); ColumnDefinition colDef = fm.getColumnDefinition();
if (colDef != null) { if (colDef != null) {
@@ -684,7 +684,7 @@ public class DepotMarshaller<T extends PersistentRecord>
// add any missing columns // add any missing columns
for (String fname : _columnFields) { for (String fname : _columnFields) {
final FieldMarshaller fmarsh = _fields.get(fname); final FieldMarshaller<?> fmarsh = _fields.get(fname);
if (metaData.tableColumns.remove(fmarsh.getColumnName())) { if (metaData.tableColumns.remove(fmarsh.getColumnName())) {
continue; continue;
} }
@@ -873,7 +873,7 @@ public class DepotMarshaller<T extends PersistentRecord>
throws PersistenceException throws PersistenceException
{ {
for (String fname : _columnFields) { for (String fname : _columnFields) {
FieldMarshaller fmarsh = _fields.get(fname); FieldMarshaller<?> fmarsh = _fields.get(fname);
meta.tableColumns.remove(fmarsh.getColumnName()); meta.tableColumns.remove(fmarsh.getColumnName());
} }
for (String column : meta.tableColumns) { for (String column : meta.tableColumns) {
@@ -977,11 +977,11 @@ public class DepotMarshaller<T extends PersistentRecord>
protected Map<String, ValueGenerator> _valueGenerators = new HashMap<String, ValueGenerator>(); protected Map<String, ValueGenerator> _valueGenerators = new HashMap<String, ValueGenerator>();
/** A field marshaller for each persistent field in our object. */ /** A field marshaller for each persistent field in our object. */
protected Map<String, FieldMarshaller> _fields = new HashMap<String, FieldMarshaller>(); protected Map<String, FieldMarshaller<?>> _fields = new HashMap<String, FieldMarshaller<?>>();
/** The field marshallers for our persistent object's primary key columns or null if it did not /** The field marshallers for our persistent object's primary key columns or null if it did not
* define a primary key. */ * define a primary key. */
protected ArrayList<FieldMarshaller> _pkColumns; protected ArrayList<FieldMarshaller<?>> _pkColumns;
/** The persisent fields of our object, in definition order. */ /** The persisent fields of our object, in definition order. */
protected String[] _allFields; protected String[] _allFields;
@@ -78,7 +78,7 @@ public abstract class DepotRepository
/** /**
* Loads the persistent object that matches the specified primary key. * Loads the persistent object that matches the specified primary key.
*/ */
protected <T extends PersistentRecord> T load (Class<T> type, Comparable primaryKey, protected <T extends PersistentRecord> T load (Class<T> type, Comparable<?> primaryKey,
QueryClause... clauses) QueryClause... clauses)
throws PersistenceException throws PersistenceException
{ {
@@ -89,7 +89,7 @@ public abstract class DepotRepository
/** /**
* Loads the persistent object that matches the specified primary key. * Loads the persistent object that matches the specified primary key.
*/ */
protected <T extends PersistentRecord> T load (Class<T> type, String ix, Comparable val, protected <T extends PersistentRecord> T load (Class<T> type, String ix, Comparable<?> val,
QueryClause... clauses) QueryClause... clauses)
throws PersistenceException throws PersistenceException
{ {
@@ -100,8 +100,8 @@ public abstract class DepotRepository
/** /**
* Loads the persistent object that matches the specified two-column primary key. * Loads the persistent object that matches the specified two-column primary key.
*/ */
protected <T extends PersistentRecord> T load (Class<T> type, String ix1, Comparable val1, protected <T extends PersistentRecord> T load (Class<T> type, String ix1, Comparable<?> val1,
String ix2, Comparable val2, String ix2, Comparable<?> val2,
QueryClause... clauses) QueryClause... clauses)
throws PersistenceException throws PersistenceException
{ {
@@ -112,9 +112,9 @@ public abstract class DepotRepository
/** /**
* Loads the persistent object that matches the specified three-column primary key. * Loads the persistent object that matches the specified three-column primary key.
*/ */
protected <T extends PersistentRecord> T load (Class<T> type, String ix1, Comparable val1, protected <T extends PersistentRecord> T load (Class<T> type, String ix1, Comparable<?> val1,
String ix2, Comparable val2, String ix3, String ix2, Comparable<?> val2, String ix3,
Comparable val3, QueryClause... clauses) Comparable<?> val3, QueryClause... clauses)
throws PersistenceException throws PersistenceException
{ {
clauses = ArrayUtil.append(clauses, new Key<T>(type, ix1, val1, ix2, val2, ix3, val3)); clauses = ArrayUtil.append(clauses, new Key<T>(type, ix1, val1, ix2, val2, ix3, val3));
@@ -231,7 +231,7 @@ public abstract class DepotRepository
requireNotComputed(pClass, "update"); requireNotComputed(pClass, "update");
DepotMarshaller<T> marsh = _ctx.getMarshaller(pClass); DepotMarshaller<T> marsh = _ctx.getMarshaller(pClass);
Key key = marsh.getPrimaryKey(record); Key<T> key = marsh.getPrimaryKey(record);
if (key == null) { if (key == null) {
throw new IllegalArgumentException("Can't update record with null primary key."); throw new IllegalArgumentException("Can't update record with null primary key.");
} }
@@ -269,7 +269,8 @@ public abstract class DepotRepository
requireNotComputed(pClass, "updatePartial"); requireNotComputed(pClass, "updatePartial");
DepotMarshaller<T> marsh = _ctx.getMarshaller(pClass); DepotMarshaller<T> marsh = _ctx.getMarshaller(pClass);
Key key = marsh.getPrimaryKey(record);
Key<T> key = marsh.getPrimaryKey(record);
if (key == null) { if (key == null) {
throw new IllegalArgumentException("Can't update record with null primary key."); throw new IllegalArgumentException("Can't update record with null primary key.");
@@ -305,7 +306,7 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updatePartial ( protected <T extends PersistentRecord> int updatePartial (
Class<T> type, Comparable primaryKey, Map<String,Object> updates) Class<T> type, Comparable<?> primaryKey, Map<String,Object> updates)
throws PersistenceException throws PersistenceException
{ {
Object[] fieldsValues = new Object[updates.size()*2]; Object[] fieldsValues = new Object[updates.size()*2];
@@ -328,7 +329,7 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updatePartial ( protected <T extends PersistentRecord> int updatePartial (
Class<T> type, Comparable primaryKey, Object... fieldsValues) Class<T> type, Comparable<?> primaryKey, Object... fieldsValues)
throws PersistenceException throws PersistenceException
{ {
return updatePartial(_ctx.getMarshaller(type).makePrimaryKey(primaryKey), fieldsValues); return updatePartial(_ctx.getMarshaller(type).makePrimaryKey(primaryKey), fieldsValues);
@@ -346,7 +347,7 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updatePartial ( protected <T extends PersistentRecord> int updatePartial (
Class<T> type, String ix1, Comparable val1, String ix2, Comparable val2, Class<T> type, String ix1, Comparable<?> val1, String ix2, Comparable<?> val2,
Object... fieldsValues) Object... fieldsValues)
throws PersistenceException throws PersistenceException
{ {
@@ -365,8 +366,8 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updatePartial ( protected <T extends PersistentRecord> int updatePartial (
Class<T> type, String ix1, Comparable val1, String ix2, Comparable val2, Class<T> type, String ix1, Comparable<?> val1, String ix2, Comparable<?> val2,
String ix3, Comparable val3, Object... fieldsValues) String ix3, Comparable<?> val3, Object... fieldsValues)
throws PersistenceException throws PersistenceException
{ {
return updatePartial(new Key<T>(type, ix1, val1, ix2, val2, ix3, val3), fieldsValues); return updatePartial(new Key<T>(type, ix1, val1, ix2, val2, ix3, val3), fieldsValues);
@@ -452,7 +453,7 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updateLiteral ( protected <T extends PersistentRecord> int updateLiteral (
Class<T> type, Comparable primaryKey, Map<String, SQLExpression> fieldsToValues) Class<T> type, Comparable<?> primaryKey, Map<String, SQLExpression> fieldsToValues)
throws PersistenceException throws PersistenceException
{ {
Key<T> key = _ctx.getMarshaller(type).makePrimaryKey(primaryKey); Key<T> key = _ctx.getMarshaller(type).makePrimaryKey(primaryKey);
@@ -477,7 +478,7 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updateLiteral ( protected <T extends PersistentRecord> int updateLiteral (
Class<T> type, String ix1, Comparable val1, String ix2, Comparable val2, Class<T> type, String ix1, Comparable<?> val1, String ix2, Comparable<?> val2,
Map<String, SQLExpression> fieldsToValues) Map<String, SQLExpression> fieldsToValues)
throws PersistenceException throws PersistenceException
{ {
@@ -503,8 +504,8 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updateLiteral ( protected <T extends PersistentRecord> int updateLiteral (
Class<T> type, String ix1, Comparable val1, String ix2, Comparable val2, Class<T> type, String ix1, Comparable<?> val1, String ix2, Comparable<?> val2,
String ix3, Comparable val3, Map<String, SQLExpression> fieldsToValues) String ix3, Comparable<?> val3, Map<String, SQLExpression> fieldsToValues)
throws PersistenceException throws PersistenceException
{ {
Key<T> key = new Key<T>(type, ix1, val1, ix2, val2, ix3, val3); Key<T> key = new Key<T>(type, ix1, val1, ix2, val2, ix3, val3);
@@ -662,7 +663,8 @@ public abstract class DepotRepository
* *
* @return the number of rows deleted by this action. * @return the number of rows deleted by this action.
*/ */
protected <T extends PersistentRecord> int delete (Class<T> type, Comparable primaryKeyValue) protected <T extends PersistentRecord> int delete (
Class<T> type, Comparable<?> primaryKeyValue)
throws PersistenceException throws PersistenceException
{ {
return delete(type, _ctx.getMarshaller(type).makePrimaryKey(primaryKeyValue)); return delete(type, _ctx.getMarshaller(type).makePrimaryKey(primaryKeyValue));
@@ -714,7 +716,7 @@ public abstract class DepotRepository
protected void requireNotComputed (Class<? extends PersistentRecord> type, String action) protected void requireNotComputed (Class<? extends PersistentRecord> type, String action)
throws PersistenceException throws PersistenceException
{ {
DepotMarshaller marsh = _ctx.getMarshaller(type); DepotMarshaller<?> marsh = _ctx.getMarshaller(type);
if (marsh == null) { if (marsh == null) {
throw new PersistenceException("Unknown persistent type [class=" + type + "]"); throw new PersistenceException("Unknown persistent type [class=" + type + "]");
} }
@@ -152,9 +152,9 @@ public class DepotTypes
* *
* @exception IllegalArgumentException thrown if the specified class is not known. * @exception IllegalArgumentException thrown if the specified class is not known.
*/ */
public DepotMarshaller getMarshaller (Class<? extends PersistentRecord> cl) public DepotMarshaller<?> getMarshaller (Class<? extends PersistentRecord> cl)
{ {
DepotMarshaller marsh = _classMap.get(cl); DepotMarshaller<?> marsh = _classMap.get(cl);
if (marsh == null) { if (marsh == null) {
throw new IllegalArgumentException("Persistent class not known: " + cl); throw new IllegalArgumentException("Persistent class not known: " + cl);
} }
@@ -202,10 +202,11 @@ public class DepotTypes
} }
/** Classes mapped to integers, used for table abbreviation indexing. */ /** Classes mapped to integers, used for table abbreviation indexing. */
protected Map<Class, Integer> _classIx = new HashMap<Class, Integer>(); protected Map<Class<?>, Integer> _classIx = new HashMap<Class<?>, Integer>();
/** Classes mapped to marshallers, used for table names and field lists. */ /** Classes mapped to marshallers, used for table names and field lists. */
protected Map<Class, DepotMarshaller> _classMap = new HashMap<Class, DepotMarshaller>(); protected Map<Class<?>, DepotMarshaller<?>> _classMap =
new HashMap<Class<?>, DepotMarshaller<?>>();
/** When false, override the normal table abbreviations and return full table names instead. */ /** When false, override the normal table abbreviations and return full table names instead. */
protected boolean _useTableAbbreviations = true; protected boolean _useTableAbbreviations = true;
@@ -101,7 +101,7 @@ public abstract class EntityMigration extends Modifier
return true; return true;
} }
protected void init (String tableName, Map<String,FieldMarshaller> marshallers) { protected void init (String tableName, Map<String,FieldMarshaller<?>> marshallers) {
super.init(tableName, marshallers); super.init(tableName, marshallers);
_newColumnDef = marshallers.get(_newColumnName).getColumnDefinition(); _newColumnDef = marshallers.get(_newColumnName).getColumnDefinition();
} }
@@ -133,7 +133,7 @@ public abstract class EntityMigration extends Modifier
return false; return false;
} }
protected void init (String tableName, Map<String,FieldMarshaller> marshallers) { protected void init (String tableName, Map<String,FieldMarshaller<?>> marshallers) {
super.init(tableName, marshallers); super.init(tableName, marshallers);
_columnName = marshallers.get(_fieldName).getColumnName(); _columnName = marshallers.get(_fieldName).getColumnName();
_newColumnDef = marshallers.get(_fieldName).getColumnDefinition(); _newColumnDef = marshallers.get(_fieldName).getColumnDefinition();
@@ -174,7 +174,7 @@ public abstract class EntityMigration extends Modifier
* migration has been determined to be runnable so one cannot rely on this method having been * migration has been determined to be runnable so one cannot rely on this method having been
* called in {@link #shouldRunMigration}. * called in {@link #shouldRunMigration}.
*/ */
protected void init (String tableName, Map<String,FieldMarshaller> marshallers) protected void init (String tableName, Map<String,FieldMarshaller<?>> marshallers)
{ {
_tableName = tableName; _tableName = tableName;
} }
@@ -52,10 +52,10 @@ public abstract class FieldMarshaller<T>
* Creates and returns a field marshaller for the specified field. Throws an exception if the * Creates and returns a field marshaller for the specified field. Throws an exception if the
* field in question cannot be marshalled. * field in question cannot be marshalled.
*/ */
public static FieldMarshaller createMarshaller (Field field) public static FieldMarshaller<?> createMarshaller (Field field)
{ {
Class<?> ftype = field.getType(); Class<?> ftype = field.getType();
FieldMarshaller marshaller; FieldMarshaller<?> marshaller;
// primitive types // primitive types
if (ftype.equals(Boolean.TYPE)) { if (ftype.equals(Boolean.TYPE)) {
@@ -117,7 +117,7 @@ public abstract class FindAllQuery<T extends PersistentRecord>
if (_marsh.getPrimaryKeyFields().length == 1) { if (_marsh.getPrimaryKeyFields().length == 1) {
// Single-column keys result in the compact IN(keyVal1, keyVal2, ...) // Single-column keys result in the compact IN(keyVal1, keyVal2, ...)
Comparable[] keyFieldValues = new Comparable[fetchKeys.size()]; Comparable<?>[] keyFieldValues = new Comparable<?>[fetchKeys.size()];
int ii = 0; int ii = 0;
for (Key<T> key : fetchKeys) { for (Key<T> key : fetchKeys) {
keyFieldValues[ii ++] = key.condition.getValues().get(0); keyFieldValues[ii ++] = key.condition.getValues().get(0);
@@ -31,7 +31,7 @@ import com.samskivert.jdbc.depot.annotation.GeneratedValue;
*/ */
public class IdentityValueGenerator extends ValueGenerator public class IdentityValueGenerator extends ValueGenerator
{ {
public IdentityValueGenerator (GeneratedValue gv, DepotMarshaller dm, FieldMarshaller fm) public IdentityValueGenerator (GeneratedValue gv, DepotMarshaller<?> dm, FieldMarshaller<?> fm)
{ {
super(gv, dm, fm); super(gv, dm, fm);
} }
+16 -15
View File
@@ -24,6 +24,7 @@ import java.io.Serializable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -46,7 +47,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
public static class WhereCondition<U extends PersistentRecord> public static class WhereCondition<U extends PersistentRecord>
implements SQLExpression, Serializable implements SQLExpression, Serializable
{ {
public WhereCondition (Class<U> pClass, ArrayList<Comparable> values) public WhereCondition (Class<U> pClass, ArrayList<Comparable<?>> values)
{ {
_pClass = pClass; _pClass = pClass;
_values = values; _values = values;
@@ -69,7 +70,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
return _pClass; return _pClass;
} }
public ArrayList<Comparable> getValues () public ArrayList<Comparable<?>> getValues ()
{ {
return _values; return _values;
} }
@@ -83,7 +84,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
if (obj == null || getClass() != obj.getClass()) { if (obj == null || getClass() != obj.getClass()) {
return false; return false;
} }
WhereCondition other = (WhereCondition) obj; WhereCondition<?> other = (WhereCondition<?>) obj;
return _pClass == other._pClass && _values.equals(other.getValues()); return _pClass == other._pClass && _values.equals(other.getValues());
} }
@@ -94,7 +95,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
} }
protected Class<U> _pClass; protected Class<U> _pClass;
protected ArrayList<Comparable> _values; protected ArrayList<Comparable<?>> _values; // List is not Serializable
} }
/** The expression that identifies our row. */ /** The expression that identifies our row. */
@@ -103,7 +104,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new single-column {@code Key} with the given value. * Constructs a new single-column {@code Key} with the given value.
*/ */
public Key (Class<T> pClass, String ix, Comparable val) public Key (Class<T> pClass, String ix, Comparable<?> val)
{ {
this(pClass, new String[] { ix }, new Comparable[] { val }); this(pClass, new String[] { ix }, new Comparable[] { val });
} }
@@ -111,8 +112,8 @@ public class Key<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new two-column {@code Key} with the given values. * Constructs a new two-column {@code Key} with the given values.
*/ */
public Key (Class<T> pClass, String ix1, Comparable val1, public Key (Class<T> pClass, String ix1, Comparable<?> val1,
String ix2, Comparable val2) String ix2, Comparable<?> val2)
{ {
this(pClass, new String[] { ix1, ix2 }, new Comparable[] { val1, val2 }); this(pClass, new String[] { ix1, ix2 }, new Comparable[] { val1, val2 });
} }
@@ -120,8 +121,8 @@ public class Key<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new three-column {@code Key} with the given values. * Constructs a new three-column {@code Key} with the given values.
*/ */
public Key (Class<T> pClass, String ix1, Comparable val1, public Key (Class<T> pClass, String ix1, Comparable<?> val1,
String ix2, Comparable val2, String ix3, Comparable val3) String ix2, Comparable<?> val2, String ix3, Comparable<?> val3)
{ {
this(pClass, new String[] { ix1, ix2, ix3 }, new Comparable[] { val1, val2, val3 }); this(pClass, new String[] { ix1, ix2, ix3 }, new Comparable[] { val1, val2, val3 });
} }
@@ -129,14 +130,14 @@ public class Key<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new multi-column {@code Key} with the given values. * Constructs a new multi-column {@code Key} with the given values.
*/ */
public Key (Class<T> pClass, String[] fields, Comparable[] values) public Key (Class<T> pClass, String[] fields, Comparable<?>[] values)
{ {
if (fields.length != values.length) { if (fields.length != values.length) {
throw new IllegalArgumentException("Field and Value arrays must be of equal length."); throw new IllegalArgumentException("Field and Value arrays must be of equal length.");
} }
// build a local map of field name -> field value // build a local map of field name -> field value
Map<String, Comparable> map = new HashMap<String, Comparable>(); Map<String, Comparable<?>> map = new HashMap<String, Comparable<?>>();
for (int i = 0; i < fields.length; i ++) { for (int i = 0; i < fields.length; i ++) {
map.put(fields[i], values[i]); map.put(fields[i], values[i]);
} }
@@ -145,9 +146,9 @@ public class Key<T extends PersistentRecord> extends WhereClause
String[] keyFields = getKeyFields(pClass); String[] keyFields = getKeyFields(pClass);
// now extract the values in field order and ensure none are extra or missing // now extract the values in field order and ensure none are extra or missing
ArrayList<Comparable> newValues = new ArrayList<Comparable>(); ArrayList<Comparable<?>> newValues = new ArrayList<Comparable<?>>();
for (int ii = 0; ii < keyFields.length; ii++) { for (int ii = 0; ii < keyFields.length; ii++) {
Comparable nugget = map.remove(keyFields[ii]); Comparable<?> nugget = map.remove(keyFields[ii]);
if (nugget == null) { if (nugget == null) {
// make sure we were provided with a value for this primary key field // make sure we were provided with a value for this primary key field
throw new IllegalArgumentException("Missing value for key field: " + keyFields[ii]); throw new IllegalArgumentException("Missing value for key field: " + keyFields[ii]);
@@ -227,7 +228,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
if (obj == null || getClass() != obj.getClass()) { if (obj == null || getClass() != obj.getClass()) {
return false; return false;
} }
return condition.equals(((Key) obj).condition); return condition.equals(((Key<?>) obj).condition);
} }
@Override @Override
@@ -260,7 +261,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
{ {
String[] fields = _keyFields.get(pClass); String[] fields = _keyFields.get(pClass);
if (fields == null) { if (fields == null) {
ArrayList<String> kflist = new ArrayList<String>(); List<String> kflist = new ArrayList<String>();
for (Field field : pClass.getFields()) { for (Field field : pClass.getFields()) {
// look for @Id fields // look for @Id fields
if (field.getAnnotation(Id.class) != null) { if (field.getAnnotation(Id.class) != null) {
@@ -38,7 +38,7 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new single-column {@code MultiKey} with the given value range. * Constructs a new single-column {@code MultiKey} with the given value range.
*/ */
public MultiKey (Class<T> pClass, String ix, Comparable... val) public MultiKey (Class<T> pClass, String ix, Comparable<?>... val)
{ {
this(pClass, new String[0], new Comparable[0], ix, val); this(pClass, new String[0], new Comparable[0], ix, val);
} }
@@ -46,7 +46,8 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new two-column {@code MultiKey} with the given value range. * Constructs a new two-column {@code MultiKey} with the given value range.
*/ */
public MultiKey (Class<T> pClass, String ix1, Comparable val1, String ix2, Comparable... val2) public MultiKey (Class<T> pClass, String ix1, Comparable<?> val1, String ix2,
Comparable<?>... val2)
{ {
this(pClass, new String[] { ix1 }, new Comparable[] { val1 }, ix2, val2); this(pClass, new String[] { ix1 }, new Comparable[] { val1 }, ix2, val2);
} }
@@ -54,8 +55,8 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new three-column {@code MultiKey} with the given value range. * Constructs a new three-column {@code MultiKey} with the given value range.
*/ */
public MultiKey (Class<T> pClass, String ix1, Comparable val1, String ix2, Comparable val2, public MultiKey (Class<T> pClass, String ix1, Comparable<?> val1,
String ix3, Comparable... val3) String ix2, Comparable<?> val2, String ix3, Comparable<?>... val3)
{ {
this(pClass, new String[] { ix1, ix2 }, new Comparable[] { val1, val2 }, ix3, val3); this(pClass, new String[] { ix1, ix2 }, new Comparable[] { val1, val2 }, ix3, val3);
} }
@@ -64,8 +65,8 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
* Constructs a new multi-column {@code MultiKey} with the given value range. * Constructs a new multi-column {@code MultiKey} with the given value range.
* @TODO: See {@link Key#Key(Class, String[], Comparable[]) for somewhat relevant comments. * @TODO: See {@link Key#Key(Class, String[], Comparable[]) for somewhat relevant comments.
*/ */
public MultiKey (Class<T> pClass, String[] sFields, Comparable[] sValues, public MultiKey (Class<T> pClass, String[] sFields, Comparable<?>[] sValues,
String mField, Comparable[] mValues) String mField, Comparable<?>[] mValues)
{ {
if (sFields.length != sValues.length) { if (sFields.length != sValues.length) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@@ -74,7 +75,7 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
_pClass = pClass; _pClass = pClass;
_mField = mField; _mField = mField;
_mValues = mValues; _mValues = mValues;
_map = new HashMap<String, Comparable>(); _map = new HashMap<String, Comparable<?>>();
for (int i = 0; i < sFields.length; i ++) { for (int i = 0; i < sFields.length; i ++) {
_map.put(sFields[i], sValues[i]); _map.put(sFields[i], sValues[i]);
} }
@@ -85,7 +86,7 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
return _pClass; return _pClass;
} }
public Map<String, Comparable> getSingleFieldsMap () public Map<String, Comparable<?>> getSingleFieldsMap ()
{ {
return _map; return _map;
} }
@@ -95,7 +96,7 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
return _mField; return _mField;
} }
public Comparable[] getMultiValues () public Comparable<?>[] getMultiValues ()
{ {
return _mValues; return _mValues;
} }
@@ -126,7 +127,7 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
// from CacheInvalidator // from CacheInvalidator
public void invalidate (PersistenceContext ctx) public void invalidate (PersistenceContext ctx)
{ {
HashMap<String, Comparable> newMap = new HashMap<String, Comparable>(_map); HashMap<String, Comparable<?>> newMap = new HashMap<String, Comparable<?>>(_map);
for (int i = 0; i < _mValues.length; i ++) { for (int i = 0; i < _mValues.length; i ++) {
newMap.put(_mField, _mValues[i]); newMap.put(_mField, _mValues[i]);
ctx.cacheInvalidate(new SimpleCacheKey(_pClass, newMap)); ctx.cacheInvalidate(new SimpleCacheKey(_pClass, newMap));
@@ -141,7 +142,7 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
} }
protected String _mField; protected String _mField;
protected Comparable[] _mValues; protected Comparable<?>[] _mValues;
protected Class<T> _pClass; protected Class<T> _pClass;
protected HashMap<String, Comparable> _map; protected HashMap<String, Comparable<?>> _map;
} }
@@ -205,7 +205,7 @@ public class MySQLBuilder
} }
@Override @Override
protected <T> String getColumnType (FieldMarshaller fm, int length) protected <T> String getColumnType (FieldMarshaller<?> fm, int length)
{ {
if (fm instanceof ByteMarshaller) { if (fm instanceof ByteMarshaller) {
return "TINYINT"; return "TINYINT";
@@ -316,9 +316,8 @@ public class PersistenceContext
log.debug("storing [key=" + key + ", value=" + entry + "]"); log.debug("storing [key=" + key + ", value=" + entry + "]");
CacheAdapter.CacheBin<T> bin = _cache.getCache(key.getCacheId()); CacheAdapter.CacheBin<T> bin = _cache.getCache(key.getCacheId());
CacheAdapter.CachedValue element = bin.lookup(key.getCacheKey()); CacheAdapter.CachedValue<T> element = bin.lookup(key.getCacheKey());
@SuppressWarnings("unchecked") T oldEntry = T oldEntry = (element != null ? element.getValue() : null);
(element != null ? (T) element.getValue() : null);
// update the cache // update the cache
bin.store(key.getCacheKey(), entry); bin.store(key.getCacheKey(), entry);
@@ -353,7 +352,7 @@ public class PersistenceContext
* Evicts the cache entry indexed under the given class and cache key, if there is one. The * Evicts the cache entry indexed under the given class and cache key, if there is one. The
* eviction may trigger further cache invalidations. * eviction may trigger further cache invalidations.
*/ */
public void cacheInvalidate (Class pClass, Serializable cacheKey) public void cacheInvalidate (Class<? extends PersistentRecord> pClass, Serializable cacheKey)
{ {
cacheInvalidate(pClass.getName(), cacheKey); cacheInvalidate(pClass.getName(), cacheKey);
} }
@@ -397,7 +396,8 @@ public class PersistenceContext
* Brutally iterates over the entire contents of the cache associated with the given class, * Brutally iterates over the entire contents of the cache associated with the given class,
* invoking the callback for each cache entry. * invoking the callback for each cache entry.
*/ */
public <T extends Serializable> void cacheTraverse (Class pClass, CacheTraverser<T> filter) public <T extends Serializable> void cacheTraverse (
Class<? extends PersistentRecord> pClass, CacheTraverser<T> filter)
{ {
cacheTraverse(pClass.getName(), filter); cacheTraverse(pClass.getName(), filter);
} }
@@ -212,7 +212,7 @@ public class PostgreSQLBuilder
} }
@Override @Override
protected <T> String getColumnType (FieldMarshaller fm, int length) protected <T> String getColumnType (FieldMarshaller<?> fm, int length)
{ {
if (fm instanceof ByteMarshaller) { if (fm instanceof ByteMarshaller) {
return "SMALLINT"; return "SMALLINT";
@@ -109,7 +109,7 @@ public abstract class SQLBuilder
* TODO: This method should be split into several parts that are more easily overridden on a * TODO: This method should be split into several parts that are more easily overridden on a
* case-by-case basis in the dialectal subclasses. * case-by-case basis in the dialectal subclasses.
*/ */
public ColumnDefinition buildColumnDefinition (FieldMarshaller fm) public ColumnDefinition buildColumnDefinition (FieldMarshaller<?> fm)
{ {
// if this field is @Computed, it has no SQL definition // if this field is @Computed, it has no SQL definition
if (fm.getComputed() != null) { if (fm.getComputed() != null) {
@@ -228,7 +228,7 @@ public abstract class SQLBuilder
* Overridden by subclasses to figure the dialect-specific SQL type of the given field. * Overridden by subclasses to figure the dialect-specific SQL type of the given field.
* @param length * @param length
*/ */
protected abstract <T> String getColumnType (FieldMarshaller fm, int length); protected abstract <T> String getColumnType (FieldMarshaller<?> fm, int length);
/** The class that maps persistent classes to marshallers. */ /** The class that maps persistent classes to marshallers. */
protected DepotTypes _types; protected DepotTypes _types;
@@ -42,7 +42,7 @@ public class SimpleCacheKey
* Construct a {@link SimpleCacheKey} associated with the given persistent class with * Construct a {@link SimpleCacheKey} associated with the given persistent class with
* the given cache key. * the given cache key.
*/ */
public SimpleCacheKey (Class cacheClass, Serializable cacheKey) public SimpleCacheKey (Class<?> cacheClass, Serializable cacheKey)
{ {
this(cacheClass.getName(), cacheKey); this(cacheClass.getName(), cacheKey);
} }
@@ -37,7 +37,8 @@ import com.samskivert.jdbc.JDBCUtil;
*/ */
public class TableValueGenerator extends ValueGenerator public class TableValueGenerator extends ValueGenerator
{ {
public TableValueGenerator (TableGenerator tg, GeneratedValue gv, DepotMarshaller dm, FieldMarshaller fm) public TableValueGenerator (
TableGenerator tg, GeneratedValue gv, DepotMarshaller<?> dm, FieldMarshaller<?> fm)
{ {
super(gv, dm, fm); super(gv, dm, fm);
_valueTable = defStr(tg.table(), "IdSequences"); _valueTable = defStr(tg.table(), "IdSequences");
@@ -36,7 +36,7 @@ import static com.samskivert.jdbc.depot.Log.log;
*/ */
public abstract class ValueGenerator public abstract class ValueGenerator
{ {
public ValueGenerator (GeneratedValue gv, DepotMarshaller dm, FieldMarshaller fm) public ValueGenerator (GeneratedValue gv, DepotMarshaller<?> dm, FieldMarshaller<?> fm)
{ {
_allocationSize = gv.allocationSize(); _allocationSize = gv.allocationSize();
_initialValue = gv.initialValue(); _initialValue = gv.initialValue();
@@ -101,12 +101,12 @@ public abstract class ValueGenerator
} }
} }
public DepotMarshaller getDepotMarshaller () public DepotMarshaller<?> getDepotMarshaller ()
{ {
return _dm; return _dm;
} }
public FieldMarshaller getFieldMarshaller () public FieldMarshaller<?> getFieldMarshaller ()
{ {
return _fm; return _fm;
} }
@@ -115,6 +115,6 @@ public abstract class ValueGenerator
protected int _allocationSize; protected int _allocationSize;
protected boolean _migrateIfExists; protected boolean _migrateIfExists;
protected DepotMarshaller _dm; protected DepotMarshaller<?> _dm;
protected FieldMarshaller _fm; protected FieldMarshaller<?> _fm;
} }
@@ -38,26 +38,26 @@ import com.samskivert.jdbc.depot.operator.Logic.And;
*/ */
public class Where extends WhereClause public class Where extends WhereClause
{ {
public Where (ColumnExp column, Comparable value) public Where (ColumnExp column, Comparable<?> value)
{ {
this(new ColumnExp[] { column }, new Comparable[] { value }); this(new ColumnExp[] { column }, new Comparable<?>[] { value });
} }
public Where (ColumnExp index1, Comparable value1, public Where (ColumnExp index1, Comparable<?> value1,
ColumnExp index2, Comparable value2) ColumnExp index2, Comparable<?> value2)
{ {
this(new ColumnExp[] { index1, index2 }, new Comparable[] { value1, value2 }); this(new ColumnExp[] { index1, index2 }, new Comparable<?>[] { value1, value2 });
} }
public Where (ColumnExp index1, Comparable value1, public Where (ColumnExp index1, Comparable<?> value1,
ColumnExp index2, Comparable value2, ColumnExp index2, Comparable<?> value2,
ColumnExp index3, Comparable value3) ColumnExp index3, Comparable<?> value3)
{ {
this(new ColumnExp[] { index1, index2, index3 }, this(new ColumnExp[] { index1, index2, index3 },
new Comparable[] { value1, value2, value3 }); new Comparable<?>[] { value1, value2, value3 });
} }
public Where (ColumnExp[] columns, Comparable[] values) public Where (ColumnExp[] columns, Comparable<?>[] values)
{ {
this(toCondition(columns, values)); this(toCondition(columns, values));
} }
@@ -84,7 +84,7 @@ public class Where extends WhereClause
_condition.addClasses(classSet); _condition.addClasses(classSet);
} }
protected static SQLExpression toCondition (ColumnExp[] columns, Comparable[] values) protected static SQLExpression toCondition (ColumnExp[] columns, Comparable<?>[] values)
{ {
SQLExpression[] comparisons = new SQLExpression[columns.length]; SQLExpression[] comparisons = new SQLExpression[columns.length];
for (int ii = 0; ii < columns.length; ii ++) { for (int ii = 0; ii < columns.length; ii ++) {
@@ -55,7 +55,7 @@ public interface ExpressionVisitor
throws Exception; throws Exception;
public void visit (WhereCondition<? extends PersistentRecord> whereCondition) public void visit (WhereCondition<? extends PersistentRecord> whereCondition)
throws Exception; throws Exception;
public void visit (Key key) public void visit (Key<? extends PersistentRecord> key)
throws Exception; throws Exception;
public void visit (MultiKey<? extends PersistentRecord> key) public void visit (MultiKey<? extends PersistentRecord> key)
throws Exception; throws Exception;
@@ -32,7 +32,7 @@ public abstract class Arithmetic
/** The SQL '+' operator. */ /** The SQL '+' operator. */
public static class Add extends BinaryOperator public static class Add extends BinaryOperator
{ {
public Add (SQLExpression column, Comparable value) public Add (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -52,7 +52,7 @@ public abstract class Arithmetic
/** The SQL '-' operator. */ /** The SQL '-' operator. */
public static class Sub extends BinaryOperator public static class Sub extends BinaryOperator
{ {
public Sub (SQLExpression column, Comparable value) public Sub (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -72,7 +72,7 @@ public abstract class Arithmetic
/** The SQL '*' operator. */ /** The SQL '*' operator. */
public static class Mul extends BinaryOperator public static class Mul extends BinaryOperator
{ {
public Mul (SQLExpression column, Comparable value) public Mul (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -92,7 +92,7 @@ public abstract class Arithmetic
/** The SQL '/' operator. */ /** The SQL '/' operator. */
public static class Div extends BinaryOperator public static class Div extends BinaryOperator
{ {
public Div (SQLExpression column, Comparable value) public Div (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -112,7 +112,7 @@ public abstract class Arithmetic
/** The SQL '&' operator. */ /** The SQL '&' operator. */
public static class BitAnd extends BinaryOperator public static class BitAnd extends BinaryOperator
{ {
public BitAnd (SQLExpression column, Comparable value) public BitAnd (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -132,7 +132,7 @@ public abstract class Arithmetic
/** The SQL '|' operator. */ /** The SQL '|' operator. */
public static class BitOr extends BinaryOperator public static class BitOr extends BinaryOperator
{ {
public BitOr (SQLExpression column, Comparable value) public BitOr (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -75,7 +75,7 @@ public abstract class Conditionals
/** The SQL '=' operator. */ /** The SQL '=' operator. */
public static class Equals extends SQLOperator.BinaryOperator public static class Equals extends SQLOperator.BinaryOperator
{ {
public Equals (SQLExpression column, Comparable value) public Equals (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -95,7 +95,7 @@ public abstract class Conditionals
/** The SQL '!=' operator. */ /** The SQL '!=' operator. */
public static class NotEquals extends SQLOperator.BinaryOperator public static class NotEquals extends SQLOperator.BinaryOperator
{ {
public NotEquals (SQLExpression column, Comparable value) public NotEquals (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -115,7 +115,7 @@ public abstract class Conditionals
/** The SQL '<' operator. */ /** The SQL '<' operator. */
public static class LessThan extends SQLOperator.BinaryOperator public static class LessThan extends SQLOperator.BinaryOperator
{ {
public LessThan (SQLExpression column, Comparable value) public LessThan (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -135,7 +135,7 @@ public abstract class Conditionals
/** The SQL '<=' operator. */ /** The SQL '<=' operator. */
public static class LessThanEquals extends SQLOperator.BinaryOperator public static class LessThanEquals extends SQLOperator.BinaryOperator
{ {
public LessThanEquals (SQLExpression column, Comparable value) public LessThanEquals (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -155,7 +155,7 @@ public abstract class Conditionals
/** The SQL '>' operator. */ /** The SQL '>' operator. */
public static class GreaterThan extends SQLOperator.BinaryOperator public static class GreaterThan extends SQLOperator.BinaryOperator
{ {
public GreaterThan (SQLExpression column, Comparable value) public GreaterThan (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -175,7 +175,7 @@ public abstract class Conditionals
/** The SQL '>=' operator. */ /** The SQL '>=' operator. */
public static class GreaterThanEquals extends SQLOperator.BinaryOperator public static class GreaterThanEquals extends SQLOperator.BinaryOperator
{ {
public GreaterThanEquals (SQLExpression column, Comparable value) public GreaterThanEquals (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -196,18 +196,18 @@ public abstract class Conditionals
public static class In public static class In
implements SQLOperator implements SQLOperator
{ {
public In (Class<? extends PersistentRecord> pClass, String pColumn, Comparable... values) public In (Class<? extends PersistentRecord> pClass, String pColumn, Comparable<?>... values)
{ {
this(new ColumnExp(pClass, pColumn), values); this(new ColumnExp(pClass, pColumn), values);
} }
public In (Class<? extends PersistentRecord> pClass, String pColumn, public In (Class<? extends PersistentRecord> pClass, String pColumn,
Collection<? extends Comparable> values) Collection<? extends Comparable<?>> values)
{ {
this(new ColumnExp(pClass, pColumn), values.toArray(new Comparable[values.size()])); this(new ColumnExp(pClass, pColumn), values.toArray(new Comparable<?>[values.size()]));
} }
public In (ColumnExp column, Comparable... values) public In (ColumnExp column, Comparable<?>... values)
{ {
if (values.length == 0) { if (values.length == 0) {
throw new IllegalArgumentException("In() condition needs at least one value."); throw new IllegalArgumentException("In() condition needs at least one value.");
@@ -216,9 +216,9 @@ public abstract class Conditionals
_values = values; _values = values;
} }
public In (ColumnExp pColumn, Collection<? extends Comparable> values) public In (ColumnExp pColumn, Collection<? extends Comparable<?>> values)
{ {
this(pColumn, values.toArray(new Comparable[values.size()])); this(pColumn, values.toArray(new Comparable<?>[values.size()]));
} }
public ColumnExp getColumn () public ColumnExp getColumn ()
@@ -226,7 +226,7 @@ public abstract class Conditionals
return _column; return _column;
} }
public Comparable[] getValues () public Comparable<?>[] getValues ()
{ {
return _values; return _values;
} }
@@ -244,13 +244,13 @@ public abstract class Conditionals
} }
protected ColumnExp _column; protected ColumnExp _column;
protected Comparable[] _values; protected Comparable<?>[] _values;
} }
/** The SQL ' like ' operator. */ /** The SQL ' like ' operator. */
public static class Like extends SQLOperator.BinaryOperator public static class Like extends SQLOperator.BinaryOperator
{ {
public Like (SQLExpression column, Comparable value) public Like (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -83,7 +83,7 @@ public interface SQLOperator extends SQLExpression
_rhs = rhs; _rhs = rhs;
} }
public BinaryOperator (SQLExpression lhs, Comparable rhs) public BinaryOperator (SQLExpression lhs, Comparable<?> rhs)
{ {
this(lhs, new ValueExp(rhs)); this(lhs, new ValueExp(rhs));
} }
@@ -140,7 +140,7 @@ public class GenRecordTask extends Task
} }
/** Processes a resolved persistent record class instance. */ /** Processes a resolved persistent record class instance. */
protected void processRecord (File source, Class rclass) protected void processRecord (File source, Class<?> rclass)
{ {
// make sure we extend persistent record // make sure we extend persistent record
if (!_prclass.isAssignableFrom(rclass)) { if (!_prclass.isAssignableFrom(rclass)) {