Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
net.sf.mmm.util.value.base.AbstractGenericValueConverter Maven / Gradle / Ivy
package net.sf.mmm.util.value.base;
import java.lang.reflect.Type;
import net.sf.mmm.util.component.base.AbstractLoggableComponent;
import net.sf.mmm.util.value.api.GenericValueConverter;
import net.sf.mmm.util.value.api.ValueNotSetException;
import net.sf.mmm.util.value.api.ValueOutOfRangeException;
import net.sf.mmm.util.value.api.WrongValueTypeException;
public abstract class AbstractGenericValueConverter extends AbstractLoggableComponent
implements GenericValueConverter {
public AbstractGenericValueConverter () {
super ();
}
@Override
public TARGET convertValue (SOURCE value, Object valueSource, Class targetClass)
throws ValueNotSetException, WrongValueTypeException {
return convertValue(value, valueSource, targetClass, targetClass);
}
@Override
public final TARGET convertValue (SOURCE value, Object valueSource, Class type, Type targetType,
TARGET defaultValue) throws WrongValueTypeException {
if (value == null ) {
return defaultValue;
} else {
return convertValue(value, valueSource, type, type);
}
}
@Override
public TARGET convertValue (SOURCE value, Object valueSource, Class targetClass,
TARGET defaultValue) throws WrongValueTypeException {
return convertValue(value, valueSource, targetClass, targetClass, defaultValue);
}
@Override
public TARGET convertValue (SOURCE value, Object valueSource, TARGET minimum,
TARGET maximum, TARGET defaultValue) throws WrongValueTypeException, ValueOutOfRangeException {
if (defaultValue != null ) {
ValueOutOfRangeException.checkRange((Object) defaultValue, minimum, maximum, valueSource);
}
if (value == null ) {
return defaultValue;
} else {
return convertValue(value, valueSource, minimum, maximum);
}
}
@Override
public TARGET convertValue (SOURCE value, Object valueSource, TARGET minimum,
TARGET maximum) throws ValueNotSetException, WrongValueTypeException, ValueOutOfRangeException {
Class targetClass = minimum.getClass();
@SuppressWarnings ("unchecked" )
TARGET result = (TARGET) convertValue(value, valueSource, targetClass, targetClass);
ValueOutOfRangeException.checkRange((Object) result, minimum, maximum, valueSource);
return result;
}
}