[#1999] Add Record.changed(boolean) changed(boolean, Field<?>)

changed(boolean, int) changed(boolean, String) as setters for the
changed flag
This commit is contained in:
Lukas Eder 2012-12-12 19:35:00 +01:00
parent e4ed930fd7
commit 2f63650bb7
3 changed files with 97 additions and 0 deletions

View File

@ -122,5 +122,27 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
assertTrue(book.changed());
assertTrue(book.changed(TBook_TITLE()));
assertTrue(book.changed(TBook_TITLE().getName()));
book.changed(false);
assertFalse(book.changed());
assertFalse(book.changed(TBook_TITLE()));
assertFalse(book.changed(TBook_TITLE().getName()));
assertEquals("abc", book.original().getValue(TBook_TITLE()));
assertEquals("abc", book.original(TBook_TITLE()));
book.changed(true);
assertTrue(book.changed());
assertTrue(book.changed(TBook_TITLE()));
assertTrue(book.changed(TBook_TITLE().getName()));
assertEquals("abc", book.original().getValue(TBook_TITLE()));
assertEquals("abc", book.original(TBook_TITLE()));
book.changed(false);
book.changed(true, TBook_TITLE());
assertTrue(book.changed());
assertTrue(book.changed(TBook_TITLE()));
assertTrue(book.changed(TBook_TITLE().getName()));
assertEquals("abc", book.original().getValue(TBook_TITLE()));
assertEquals("abc", book.original(TBook_TITLE()));
}
}

View File

@ -446,6 +446,59 @@ public interface Record extends FieldProvider, Attachable {
*/
boolean changed(String fieldName);
/**
* Set all of this record's internal changed flags to the supplied value
* <p>
* If the <code>changed</code> argument is <code>false</code>, the
* {@link #original()} values will be reset to the corresponding "current"
* values as well
*
* @see #changed()
* @see #changed(boolean, Field)
* @see #changed(boolean, int)
* @see #changed(boolean, String)
*/
void changed(boolean changed);
/**
* Set this record's internal changed flag to the supplied value for a given
* field.
* <p>
* If the <code>changed</code> argument is <code>false</code>, the
* {@link #original(Field)} value will be reset to the corresponding
* "current" value as well
*
* @see #changed()
* @see #changed(Field)
*/
void changed(boolean changed, Field<?> field);
/**
* Set this record's internal changed flag to the supplied value for a given
* field.
* <p>
* If the <code>changed</code> argument is <code>false</code>, the
* {@link #original(int)} value will be reset to the corresponding "current"
* value as well
*
* @see #changed()
* @see #changed(int)
*/
void changed(boolean changed, int fieldIndex);
/**
* Set this record's internal changed flag to the supplied value for a given
* field.
* <p>
* If the <code>changed</code> argument is <code>false</code>, the
* {@link #original(String)} value will be reset to the corresponding
* "current" value as well
*
* @see #changed()
* @see #changed(String)
*/
void changed(boolean changed, String fieldName);
/**
* Convert this record into an array.
* <p>

View File

@ -400,6 +400,28 @@ abstract class AbstractRecord extends AbstractStore implements Record {
return changed(getIndex(fieldName));
}
@Override
public final void changed(boolean changed) {
for (Value<?> value : getValues()) {
value.setChanged(changed);
}
}
@Override
public final void changed(boolean changed, Field<?> field) {
changed(changed, getIndex(field));
}
@Override
public final void changed(boolean changed, int fieldIndex) {
getValue0(fieldIndex).setChanged(changed);
}
@Override
public final void changed(boolean changed, String fieldName) {
changed(changed, getIndex(fieldName));
}
@Override
public final Object[] intoArray() {
return into(Object[].class);