use of io.datarouter.model.field.imp.StringFieldKey in project datarouter by hotpads.
the class StringEnumField method toStringField.
public static StringField toStringField(StringEnumField<?> stringEnumField) {
if (stringEnumField == null) {
return null;
}
String value = null;
if (stringEnumField.getValue() != null) {
value = stringEnumField.getValue().getPersistentString();
}
String defaultValue = null;
if (stringEnumField.getKey().getDefaultValue() != null) {
defaultValue = stringEnumField.getKey().getDefaultValue().getPersistentString();
}
StringFieldKey key = new StringFieldKey(stringEnumField.key.getName(), stringEnumField.key.getColumnName(), stringEnumField.key.isNullable(), FieldGeneratorType.NONE, defaultValue, stringEnumField.key.getSize(), stringEnumField.key.getAttributes());
return new StringField(stringEnumField.getPrefix(), key, value);
}
use of io.datarouter.model.field.imp.StringFieldKey in project datarouter by hotpads.
the class FieldSetToolTests method testGetConcatenatedValueBytes.
@Test
public void testGetConcatenatedValueBytes() {
List<Field<?>> fields = List.of(new IntegerField(new IntegerFieldKey("a"), 55), new StringField(new StringFieldKey("b"), "abc"), new StringField(new StringFieldKey("c"), "xyz"));
int lengthWithout = 4 + 3 + 1 + 3;
int lengthWith = lengthWithout + 1;
Bytes withoutTrailingByte = new Bytes(FieldTool.getConcatenatedValueBytesUnterminated(fields));
Bytes withTrailingByte = new Bytes(FieldTool.getConcatenatedValueBytes(fields));
Assert.assertEquals(withoutTrailingByte.getLength(), lengthWithout);
Assert.assertEquals(withTrailingByte.getLength(), lengthWith);
}
Aggregations