Package tech.ydb.yoj.databind
Annotation Interface CustomValueType
@Inherited
@Retention(RUNTIME)
@Target({TYPE,FIELD,RECORD_COMPONENT,ANNOTATION_TYPE})
public @interface CustomValueType
Annotates the class, or entity field/record component as having a custom
The specified converter will be used by YOJ instead of the default (Database column↔Java field) mapping.
Defining recursive custom value types is prohibited: that is, you cannot have a custom value type with a converter that returns value of
value converter.
The specified converter will be used by YOJ instead of the default (Database column↔Java field) mapping.
Defining recursive custom value types is prohibited: that is, you cannot have a custom value type with a converter that returns value of
another custom value type.
- This annotation is inherited, so make sure that your
convertereither supports all possible subclasses of your class, or restrict subclassing by making your classfinalorsealed. - This is a meta-annotation: it can be applied to other annotations; if you use these annotations, YOJ
will correctly apply the
@CustomValueTypeannotation. This allows to define custom value type configuration once and then re-use it in multiple classes. @Column(customValueType=...)annotation on an entity field/record component has priority over annotation on the field's/record component's class.@Columnis also a meta-annotation, so you can define custom value types for individual columns using@Column.customValueType.
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionClass<? extends Comparable>Class of the values that thetoColumn()method of theconverterreturns.Class<? extends ValueConverter>Converter class.
-
Element Details
-
columnClass
Class<? extends Comparable> columnClassClass of the values that thetoColumn()method of theconverterreturns.Column class itself cannot be a custom value type. It must be one of the
database column value types supported by YOJand it must implementComparable.It is allowed to return value of a subclass of
columnClass, e.g. in case ofcolumnClassbeing anenumclass. -
converter
Class<? extends ValueConverter> converterConverter class. Must have a no-args public constructor.
-