001package arez.persist.runtime;
002
003import javax.annotation.Nonnull;
004
005/**
006 * Converter that encodes a persistent property from application form to encoded form and back again.
007 *
008 * @param <A> the application form of the value.
009 * @param <E> the encoded form of the value.
010 */
011public interface Converter<A, E>
012{
013  /**
014   * Decode encoded value into form used by the application.
015   *
016   * @param encoded the encoded form of the value.
017   * @return the value.
018   */
019  A decode( @Nonnull E encoded );
020
021  /**
022   * Encode value into form used by the storage system.
023   *
024   * @param value the decoded value.
025   * @return the encoded form of the value.
026   */
027  E encode( @Nonnull A value );
028}