net.sf.mmm.util.value.base.ValueConverterIdentity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mmm-util-value Show documentation
Show all versions of mmm-util-value Show documentation
This project provides common utitlities to for converting values.
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