All Downloads are FREE. Search and download functionalities are using the official Maven repository.

arez.persist.runtime.IdentityConverter Maven / Gradle / Ivy

The newest version!
package arez.persist.runtime;

import javax.annotation.Nonnull;

final class IdentityConverter
  implements Converter
{
  /**
   * Return the converter that performs no conversions.
   *
   * @param  the type of the value.
   * @return the converter.
   */
  @SuppressWarnings( "unchecked" )
  static  Converter instance()
  {
    return (Converter) Holder.CONVERTER;
  }

  // Holder class to avoid  on instance calls
  static final class Holder
  {
    @Nonnull
    static final IdentityConverter CONVERTER = new IdentityConverter<>();
  }

  @Override
  public A decode( @Nonnull final A encoded )
  {
    return encoded;
  }

  @Override
  public A encode( @Nonnull final A value )
  {
    return value;
  }
}