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

net.sf.mmm.util.value.base.ValueConverterIdentity Maven / Gradle / Ivy

The newest version!
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0
 * http://www.apache.org/licenses/LICENSE-2.0 */
package net.sf.mmm.util.value.base;

/**
 * This is an implementation of {@link net.sf.mmm.util.value.api.ValueConverter} that returns the unmodified
 * value (identity conversion).
 *
 * @param  is the generic type of the value.
 *
 * @author Joerg Hohwiller (hohwille at users.sourceforge.net)
 * @since 3.0.0
 */
public class ValueConverterIdentity extends AbstractSimpleValueConverter {

  private final Class valueClass;

  /**
   * The constructor.
   *
   * @param valueClass is the {@link Class} reflecting the value type.
   */
  public ValueConverterIdentity(Class valueClass) {

    super();
    this.valueClass = valueClass;
  }

  @Override
  public Class getSourceType() {

    return this.valueClass;
  }

  @Override
  public Class getTargetType() {

    return this.valueClass;
  }

  @Override
  @SuppressWarnings("unchecked")
  public  T convert(V value, Object valueSource, Class targetClass) {

    // GWT does not yet support cast...
    // return targetClass.cast(value);
    return (T) value;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy