Skip to content

Commit

Permalink
docs: create and enhance documentation to attribute converter
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed Feb 19, 2024
1 parent 7053b57 commit 8781a6d
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions api/nosql-core/src/main/java/jakarta/nosql/AttributeConverter.java
Expand Up @@ -16,32 +16,21 @@
package jakarta.nosql;

/**
* A class that implements this interface can be used to convert entity attribute state into database column
* representation and back again. Note that the X and Y types may be the same Java type.
* @param <X> the type of the entity attribute
* @param <Y> the type of the database column
*/
/**
* Interface implemented by custom attribute <em>converters</em>. A
* converter is a class whose methods convert between:
* <ul>
* <li>the <em>target type</em> of the converter, an arbitrary Java
* type which may be used as the type of a persistent field or
* property, and
* <li>a basic type or aa type that can be persisted by a persistence provider used as an intermediate step
* in mapping to the database representation.
* </ul>
* A class that implements this interface can be used to convert entity attribute state into a database column
* representation and vice versa. Note that the types X and Y may be the same Java type.
*
* <p>A converted field or property is considered basic, since,
* with the aid of the converter, its values can be represented as
* instances of a basic type.
* <p>This interface is implemented by custom attribute converters. A converter is a class whose methods convert
* between the target type of the converter (an arbitrary Java type which may be used as the type of a persistent
* field or property) and a basic type or a type that can be persisted by a persistence provider, used as an
* intermediate step in mapping to the database representation.
*
* <p>A converted field or property is considered basic, since, with the aid of the converter, its values can be
* represented as instances of a basic type.
*
* <p>Note that the target type {@code X} and the converted basic type
* {@code Y} may be the same Java type.
* <p>Note that the target type {@code X} and the converted basic type {@code Y} may be the same Java type.
*
* @param <X> the target type, that is, the type of the entity attribute
* @param <Y> a basic type or a supported type to the NoSQL database representing the type of the database column
* @param <Y> a basic type or a supported type in the NoSQL database representing the type of the database column
*
* @see Convert
*/
Expand All @@ -50,14 +39,14 @@ public interface AttributeConverter<X, Y> {
/**
* Converts the value stored in the entity attribute into the data representation to be stored in the database.
*
* @param attribute attribute the entity attribute value to be converted
* @param attribute the entity attribute value to be converted
* @return the converted data to be stored in the database column
*/
Y convertToDatabaseColumn(X attribute);

/**
* Converts the data stored in the database column into the value to be stored in the entity attribute.
* Note that it is the responsibility of the converter writer to specify the correct dbData type for the
* Note that it is the responsibility of the converter writer to specify the correct database data type for the
* corresponding column for use by the JDBC driver: i.e., persistence providers are not expected to do
* such type conversion.
*
Expand Down

0 comments on commit 8781a6d

Please sign in to comment.