// Path: binder/src/main/java/com/artfulbits/binding/Formatting.java
// @SuppressWarnings("unused")
// public interface Formatting<TLeft, TRight>
//     extends ToView<TLeft, TRight>, ToModel<TRight, TLeft> {
// }
// 
// Path: binder/src/main/java/com/artfulbits/binding/exceptions/OneWayBindingError.java
// public class OneWayBindingError extends Error {
//   /** Serialization id. */
//   private static final long serialVersionUID = -3510027916462788278L;
// }


import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.artfulbits.binding.Formatting;
import com.artfulbits.binding.exceptions.OneWayBindingError;
package com.artfulbits.binding.toolbox;



/**
 * Methods for construction of typical data type converter's.
 * <p/>
 * Why MOLD? I like short names. Synonyms are: mold, makeup, cast, formatting, formatter, converter.
 */
@SuppressWarnings({"unused", "unchecked"})
public final class Molds {
  /* [ CONSTRUCTORS ] ============================================================================================== */

  /** hidden constructor. */
  private Molds() {
    throw new AssertionError();
  }

	/* [ STATIC METHODS - GENERIC ] ================================================================================== */

  /** No formatting. Input and Output is the same value. */
  @NonNull
  public static <T, V> Formatting<T, V> direct() {
    return new Formatting<T, V>() {
      @Override
      public T toView(V value) {
        return (T) value;
      }

      @Override
      public V toModel(T value) {
        return (V) value;
      }
    };
  }

  /** Reverse formatting instance. */
  @NonNull
  public static <T, V> Formatting<T, V> reverse(@NonNull final Formatting<V, T> f) {
    return new Formatting<T, V>() {
      @Override
      public T toView(final V value) {
        return f.toModel(value);
      }

      @Override
      public V toModel(final T value) {
        return f.toView(value);
      }
    };
  }

  /**
   * Create one way binding - allowed only POP operation, from MODEL to VIEW. VIEW to MODEL - not allowed.
   */
  @NonNull
  public static <T, V> Formatting<T, V> onlyPop(@NonNull final Formatting<T, V> f) {
    return new Formatting<T, V>() {
      @Override
      public T toView(final V value) {
        return f.toView(value);
      }

      @Override
      public V toModel(final T value) {
// Path: binder/src/main/java/com/artfulbits/binding/Formatting.java
// @SuppressWarnings("unused")
// public interface Formatting<TLeft, TRight>
//     extends ToView<TLeft, TRight>, ToModel<TRight, TLeft> {
// }
// 
// Path: binder/src/main/java/com/artfulbits/binding/exceptions/OneWayBindingError.java
// public class OneWayBindingError extends Error {
//   /** Serialization id. */
//   private static final long serialVersionUID = -3510027916462788278L;
// }


// Path: binder/src/main/java/com/artfulbits/binding/toolbox/Molds.java
import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.artfulbits.binding.Formatting;
import com.artfulbits.binding.exceptions.OneWayBindingError;

package com.artfulbits.binding.toolbox;



/**
 * Methods for construction of typical data type converter's.
 * <p/>
 * Why MOLD? I like short names. Synonyms are: mold, makeup, cast, formatting, formatter, converter.
 */
@SuppressWarnings({"unused", "unchecked"})
public final class Molds {
  /* [ CONSTRUCTORS ] ============================================================================================== */

  /** hidden constructor. */
  private Molds() {
    throw new AssertionError();
  }

	/* [ STATIC METHODS - GENERIC ] ================================================================================== */

  /** No formatting. Input and Output is the same value. */
  @NonNull
  public static <T, V> Formatting<T, V> direct() {
    return new Formatting<T, V>() {
      @Override
      public T toView(V value) {
        return (T) value;
      }

      @Override
      public V toModel(T value) {
        return (V) value;
      }
    };
  }

  /** Reverse formatting instance. */
  @NonNull
  public static <T, V> Formatting<T, V> reverse(@NonNull final Formatting<V, T> f) {
    return new Formatting<T, V>() {
      @Override
      public T toView(final V value) {
        return f.toModel(value);
      }

      @Override
      public V toModel(final T value) {
        return f.toView(value);
      }
    };
  }

  /**
   * Create one way binding - allowed only POP operation, from MODEL to VIEW. VIEW to MODEL - not allowed.
   */
  @NonNull
  public static <T, V> Formatting<T, V> onlyPop(@NonNull final Formatting<T, V> f) {
    return new Formatting<T, V>() {
      @Override
      public T toView(final V value) {
        return f.toView(value);
      }

      @Override
      public V toModel(final T value) {
        throw new OneWayBindingError();