use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.
the class Record method compareValue.
default int compareValue(final CharSequence fieldName, final Object value) {
final FieldDefinition fieldDefinition = getFieldDefinition(fieldName);
if (fieldDefinition == null) {
return -1;
} else {
final int fieldIndex = fieldDefinition.getIndex();
final Object fieldValue = getValue(fieldIndex);
return CompareUtil.compare(fieldValue, value);
}
}
use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.
the class Record method validateField.
default void validateField(final int fieldIndex) {
final FieldDefinition field = getFieldDefinition(fieldIndex);
if (field != null) {
final Object value = getValue(fieldIndex);
field.validate(this, value);
}
}
use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.
the class Record method setValues.
default void setValues(final Record record) {
if (record != null) {
final List<FieldDefinition> idFields = getRecordDefinition().getIdFields();
final List<FieldDefinition> fields = getFieldDefinitions();
for (final FieldDefinition fieldDefintion : fields) {
if (!idFields.contains(fieldDefintion)) {
final String name = fieldDefintion.getName();
final Object value = record.getValue(name);
fieldDefintion.setValue(this, value);
}
}
}
}
use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.
the class Record method setValues.
default void setValues(final Map<? extends CharSequence, ? extends Object> values, final Collection<? extends CharSequence> fieldNames) {
for (final CharSequence fieldName : fieldNames) {
final Object newValue = values.get(fieldName);
final FieldDefinition fieldDefinition = getFieldDefinition(fieldName);
if (fieldDefinition != null) {
fieldDefinition.setValue(this, newValue);
}
}
}
use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.
the class AbstractRecord method setValues.
@Override
public void setValues(final Object... values) {
if (values != null) {
int i = 0;
final RecordDefinition recordDefinition = getRecordDefinition();
for (final FieldDefinition fieldDefinition : recordDefinition.getFields()) {
if (i < values.length) {
final Object value = values[i];
setValue(fieldDefinition, value);
i++;
} else {
return;
}
}
}
}
Aggregations