com.google.sitebricks.conversion.NumberConverters Maven / Gradle / Ivy
The newest version!
package com.google.sitebricks.conversion;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
/**
* @author John Patterson ([email protected])
*/
public class NumberConverters {
public static List> converters() {
List> converters = new ArrayList>();
converters.add(new ConverterAdaptor() {
public Integer to(Number source) {
return Integer.valueOf(source.intValue());
}
});
converters.add(new ConverterAdaptor() {
public Long to(Number source) {
return Long.valueOf(source.longValue());
}
});
converters.add(new ConverterAdaptor() {
public Float to(Number source) {
return Float.valueOf(source.floatValue());
}
});
converters.add(new ConverterAdaptor() {
public Double to(Number source) {
return Double.valueOf(source.doubleValue());
}
});
converters.add(new ConverterAdaptor() {
public Short to(Number source) {
return Short.valueOf(source.shortValue());
}
});
converters.add(new ConverterAdaptor() {
public BigInteger to(Number source) {
return BigInteger.valueOf(source.longValue());
}
});
converters.add(new ConverterAdaptor() {
public BigDecimal to(Number source) {
return BigDecimal.valueOf(source.doubleValue());
}
});
return converters;
}
}