Overrides, from David Hoover (belatedly): 'Also nukes trailing whitespace, foreaches a couple loops and varags one thing that leapt out at me while i was skimming it.'
This commit is contained in:
@@ -174,6 +174,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
|
|||||||
}
|
}
|
||||||
|
|
||||||
// from WhereClause
|
// from WhereClause
|
||||||
|
@Override
|
||||||
public SQLExpression getWhereExpression ()
|
public SQLExpression getWhereExpression ()
|
||||||
{
|
{
|
||||||
return new Expression<T>(_pClass, _values);
|
return new Expression<T>(_pClass, _values);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import java.util.Iterator;
|
|||||||
import com.google.common.collect.Iterators;
|
import com.google.common.collect.Iterators;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
import com.samskivert.util.Logger;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import com.samskivert.depot.clause.WhereClause;
|
import com.samskivert.depot.clause.WhereClause;
|
||||||
@@ -127,8 +128,7 @@ public abstract class KeySet<T extends PersistentRecord> extends WhereClause
|
|||||||
super(pClass);
|
super(pClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// from WhereClause
|
@Override public SQLExpression getWhereExpression () {
|
||||||
public SQLExpression getWhereExpression () {
|
|
||||||
return new LiteralExp("(1 = 0)");
|
return new LiteralExp("(1 = 0)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,8 +169,7 @@ public abstract class KeySet<T extends PersistentRecord> extends WhereClause
|
|||||||
_keys = keys;
|
_keys = keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
// from WhereClause
|
@Override public SQLExpression getWhereExpression () {
|
||||||
public SQLExpression getWhereExpression () {
|
|
||||||
// Single-column keys result in the compact IN(keyVal1, keyVal2, ...)
|
// Single-column keys result in the compact IN(keyVal1, keyVal2, ...)
|
||||||
ColumnExp column = new ColumnExp(_pClass, DepotUtil.getKeyFields(_pClass)[0]);
|
ColumnExp column = new ColumnExp(_pClass, DepotUtil.getKeyFields(_pClass)[0]);
|
||||||
return new Conditionals.In(column, _keys);
|
return new Conditionals.In(column, _keys);
|
||||||
@@ -220,8 +219,7 @@ public abstract class KeySet<T extends PersistentRecord> extends WhereClause
|
|||||||
_keys = keys;
|
_keys = keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
// from WhereClause
|
@Override public SQLExpression getWhereExpression () {
|
||||||
public SQLExpression getWhereExpression () {
|
|
||||||
// Multi-column keys result in OR'd AND's, of unknown efficiency (TODO check).
|
// Multi-column keys result in OR'd AND's, of unknown efficiency (TODO check).
|
||||||
SQLExpression[] keyexps = new SQLExpression[_keys.length];
|
SQLExpression[] keyexps = new SQLExpression[_keys.length];
|
||||||
int ii = 0;
|
int ii = 0;
|
||||||
@@ -273,10 +271,10 @@ public abstract class KeySet<T extends PersistentRecord> extends WhereClause
|
|||||||
public Collection<Key<T>> toCollection ()
|
public Collection<Key<T>> toCollection ()
|
||||||
{
|
{
|
||||||
return new AbstractCollection<Key<T>>() {
|
return new AbstractCollection<Key<T>>() {
|
||||||
public Iterator<Key<T>> iterator () {
|
@Override public Iterator<Key<T>> iterator () {
|
||||||
return KeySet.this.iterator();
|
return KeySet.this.iterator();
|
||||||
}
|
}
|
||||||
public int size () {
|
@Override public int size () {
|
||||||
return KeySet.this.size();
|
return KeySet.this.size();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -310,9 +308,9 @@ public abstract class KeySet<T extends PersistentRecord> extends WhereClause
|
|||||||
public void validateFlushType (Class<?> pClass)
|
public void validateFlushType (Class<?> pClass)
|
||||||
{
|
{
|
||||||
if (!pClass.equals(_pClass)) {
|
if (!pClass.equals(_pClass)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(Logger.format(
|
||||||
"Class mismatch between persistent record and cache invalidator " +
|
"Class mismatch between persistent record and cache invalidator",
|
||||||
"[record=" + pClass.getSimpleName() + ", invtype=" + _pClass.getSimpleName() + "].");
|
"record", pClass.getSimpleName(), "invtype", _pClass.getSimpleName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class Where extends WhereClause
|
|||||||
_condition = condition;
|
_condition = condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
// from WhereClause
|
@Override // from WhereClause
|
||||||
public SQLExpression getWhereExpression ()
|
public SQLExpression getWhereExpression ()
|
||||||
{
|
{
|
||||||
return _condition;
|
return _condition;
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ public class FunctionExp implements SQLExpression
|
|||||||
// from SQLExpression
|
// from SQLExpression
|
||||||
public void addClasses (Collection<Class<? extends PersistentRecord>> classSet)
|
public void addClasses (Collection<Class<? extends PersistentRecord>> classSet)
|
||||||
{
|
{
|
||||||
for (int ii = 0; ii < _arguments.length; ii ++) {
|
for (SQLExpression _argument : _arguments) {
|
||||||
_arguments[ii].addClasses(classSet);
|
_argument.addClasses(classSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +65,7 @@ public class FunctionExp implements SQLExpression
|
|||||||
return _arguments;
|
return _arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
return _function + "(" + StringUtil.join(_arguments, ", ") + ")";
|
return _function + "(" + StringUtil.join(_arguments, ", ") + ")";
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public class LiteralExp
|
|||||||
return _text;
|
return _text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
return _text;
|
return _text;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public interface SQLExpression
|
|||||||
_reason = reason;
|
_reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString () {
|
@Override public String toString () {
|
||||||
return "[unknown value, reason=" + _reason + "]";
|
return "[unknown value, reason=" + _reason + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -504,12 +504,12 @@ public class DepotMarshaller<T extends PersistentRecord>
|
|||||||
_columnFields = new String[_allFields.length];
|
_columnFields = new String[_allFields.length];
|
||||||
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 (String field : _allFields) {
|
||||||
FieldMarshaller<?> fm = _fields.get(_allFields[ii]);
|
FieldMarshaller<?> fm = _fields.get(field);
|
||||||
// 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) {
|
||||||
_columnFields[jj] = _allFields[ii];
|
_columnFields[jj] = field;
|
||||||
declarations[jj] = colDef;
|
declarations[jj] = colDef;
|
||||||
jj ++;
|
jj ++;
|
||||||
}
|
}
|
||||||
@@ -547,6 +547,7 @@ public class DepotMarshaller<T extends PersistentRecord>
|
|||||||
log.info("Creating initial version record for " + _pClass.getName() + ".");
|
log.info("Creating initial version record for " + _pClass.getName() + ".");
|
||||||
// if not, create a version entry with version zero
|
// if not, create a version entry with version zero
|
||||||
ctx.invoke(new SimpleModifier() {
|
ctx.invoke(new SimpleModifier() {
|
||||||
|
@Override
|
||||||
protected int invoke (DatabaseLiaison liaison, Statement stmt) throws SQLException {
|
protected int invoke (DatabaseLiaison liaison, Statement stmt) throws SQLException {
|
||||||
try {
|
try {
|
||||||
return stmt.executeUpdate(
|
return stmt.executeUpdate(
|
||||||
@@ -605,6 +606,7 @@ public class DepotMarshaller<T extends PersistentRecord>
|
|||||||
|
|
||||||
// and update our version in the schema version table
|
// and update our version in the schema version table
|
||||||
ctx.invoke(new SimpleModifier() {
|
ctx.invoke(new SimpleModifier() {
|
||||||
|
@Override
|
||||||
protected int invoke (DatabaseLiaison liaison, Statement stmt) throws SQLException {
|
protected int invoke (DatabaseLiaison liaison, Statement stmt) throws SQLException {
|
||||||
return stmt.executeUpdate(
|
return stmt.executeUpdate(
|
||||||
"update " + liaison.tableSQL(SCHEMA_VERSION_TABLE) +
|
"update " + liaison.tableSQL(SCHEMA_VERSION_TABLE) +
|
||||||
@@ -1035,6 +1037,7 @@ public class DepotMarshaller<T extends PersistentRecord>
|
|||||||
// server to whom we would talk if we were doing a modification (ie. the master, not a
|
// server to whom we would talk if we were doing a modification (ie. the master, not a
|
||||||
// read-only slave)
|
// read-only slave)
|
||||||
protected class ReadVersion extends SimpleModifier {
|
protected class ReadVersion extends SimpleModifier {
|
||||||
|
@Override
|
||||||
protected int invoke (DatabaseLiaison liaison, Statement stmt) throws SQLException {
|
protected int invoke (DatabaseLiaison liaison, Statement stmt) throws SQLException {
|
||||||
ResultSet rs = stmt.executeQuery(
|
ResultSet rs = stmt.executeQuery(
|
||||||
" select " + liaison.columnSQL(V_COLUMN) +
|
" select " + liaison.columnSQL(V_COLUMN) +
|
||||||
@@ -1049,6 +1052,7 @@ public class DepotMarshaller<T extends PersistentRecord>
|
|||||||
_newMigratingVersion = newMigratingVersion;
|
_newMigratingVersion = newMigratingVersion;
|
||||||
_guardVersion = guardVersion;
|
_guardVersion = guardVersion;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
protected int invoke (DatabaseLiaison liaison, Statement stmt) throws SQLException {
|
protected int invoke (DatabaseLiaison liaison, Statement stmt) throws SQLException {
|
||||||
return stmt.executeUpdate(
|
return stmt.executeUpdate(
|
||||||
"update " + liaison.tableSQL(SCHEMA_VERSION_TABLE) +
|
"update " + liaison.tableSQL(SCHEMA_VERSION_TABLE) +
|
||||||
@@ -1121,6 +1125,7 @@ public class DepotMarshaller<T extends PersistentRecord>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
return StringUtil.fieldsToString(this);
|
return StringUtil.fieldsToString(this);
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ public class HSQLBuilder
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Void visit (MultiOperator operator)
|
public Void visit (MultiOperator operator)
|
||||||
{
|
{
|
||||||
String op;
|
String op;
|
||||||
@@ -129,6 +130,7 @@ public class HSQLBuilder
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Void visit (EpochSeconds epochSeconds)
|
public Void visit (EpochSeconds epochSeconds)
|
||||||
{
|
{
|
||||||
_builder.append("datediff('ss', ");
|
_builder.append("datediff('ss', ");
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ public class MySQLBuilder
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Void visit (EpochSeconds epochSeconds)
|
public Void visit (EpochSeconds epochSeconds)
|
||||||
{
|
{
|
||||||
_builder.append("unix_timestamp(");
|
_builder.append("unix_timestamp(");
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ public class TestRepository extends DepotRepository
|
|||||||
{
|
{
|
||||||
public int recordId;
|
public int recordId;
|
||||||
public String name;
|
public String name;
|
||||||
public String toString () {
|
|
||||||
|
@Override public String toString () {
|
||||||
return recordId + ":" + name;
|
return recordId + ":" + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user