Package tech.ydb.yoj.databind.converter
Class StringValueConverter<J>
java.lang.Object
tech.ydb.yoj.databind.converter.StringValueConverter<J>
- Type Parameters:
J- Java type
- All Implemented Interfaces:
ValueConverter<J,String>
Generic YDB text column ↔ Java value converter. Uses
Object.toString() to convert Java values
to YDB column values, and one of (static fromString(String), static valueOf(String) or the
1-arg String constructor) to convert YDB column values back to Java.
- Apply it locally to your entity's field, by using the
@StringColumnannotation. Explicitly specify@Column(customValueType=@CustomValueType(columnClass=String.class, converter=StringValueConverter.class), ...)if you need to add more column customizations. - Apply it globally to a user-defined field type, by using the
@StringValueTypeannotation. Explicitly specify@CustomValueType(columnClass=String.class, converter=StringValueConverter.class), ...)if you prefer not to use meta-annotations.
-
Nested Class Summary
Nested classes/interfaces inherited from interface tech.ydb.yoj.databind.converter.ValueConverter
ValueConverter.NoConverter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull StringtoColumn(@NonNull Schema.JavaField field, J value) Converts a field value to adatabase column valuesupported by YOJ.toJava(@NonNull Schema.JavaField field, @NonNull String column) Converts a database column value to a Java field value.
-
Constructor Details
-
StringValueConverter
public StringValueConverter()
-
-
Method Details
-
toColumn
@NonNull public @NonNull String toColumn(@NonNull @NonNull Schema.JavaField field, @NonNull J value) Description copied from interface:ValueConverterConverts a field value to adatabase column valuesupported by YOJ.- Specified by:
toColumnin interfaceValueConverter<J,String> - Parameters:
field- schema fieldvalue- field value, guaranteed to not benull- Returns:
- database column value corresponding to the Java field value, must not be
null - See Also:
-
toJava
Description copied from interface:ValueConverterConverts a database column value to a Java field value.- Specified by:
toJavain interfaceValueConverter<J,String> - Parameters:
field- schema fieldcolumn- database column value, guaranteed to not benull- Returns:
- Java field value corresponding to the database column value, must not be
null - See Also:
-