com.google.sitebricks.conversion.StringToPrimitiveConverters Maven / Gradle / Ivy
The newest version!
package com.google.sitebricks.conversion;
import java.util.ArrayList;
import java.util.List;
/**
* @author John Patterson ([email protected])
*/
public class StringToPrimitiveConverters {
public static List> converters() {
List> converters = new ArrayList>();
converters.add(new ConverterAdaptor() {
public Integer to(String source) {
return Integer.valueOf(source);
}
});
converters.add(new ConverterAdaptor() {
public Long to(String source) {
return Long.valueOf(source);
}
});
converters.add(new ConverterAdaptor() {
public Float to(String source) {
return Float.valueOf(source);
}
});
converters.add(new ConverterAdaptor() {
public Double to(String source) {
return Double.valueOf(source);
}
});
converters.add(new ConverterAdaptor() {
public Byte to(String source) {
return Byte.valueOf(source);
}
});
converters.add(new ConverterAdaptor() {
public Boolean to(String source) {
return Boolean.valueOf(source);
}
});
converters.add(new ConverterAdaptor() {
public Character to(String source) {
return source.charAt(0);
}
});
return converters;
}
}