org.bbottema.javareflection.valueconverter.converters.StringConverters Maven / Gradle / Ivy
package org.bbottema.javareflection.valueconverter.converters;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.experimental.UtilityClass;
import org.bbottema.javareflection.util.commonslang25.NumberUtils;
import org.bbottema.javareflection.util.Function;
import org.bbottema.javareflection.util.Function.Functions;
import org.bbottema.javareflection.valueconverter.IncompatibleTypeException;
import org.bbottema.javareflection.valueconverter.ValueFunction;
import org.bbottema.javareflection.valueconverter.ValueFunction.ValueFunctionImpl;
import org.jetbrains.annotations.Nullable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
/**
* Conversions are as follows:
* FIXME add non-Number conversions
*
* - Integer (or primitive int):
Integer.parseInt(value)
* - Character:
value.getCharAt(0)
*
new BigDecimal(value)
(simply attempt the widest number type)Byte.parseByte(value)
Short.parseShort(value)
Long.parseLong(value)
Float.parseFloat(value)
Double.parseDouble(value)
BigInteger.valueOf(Long.parseLong(value))
new BigDecimal(value)
String
to an Enum instance, by mapping to the enum's name using
* {@link Enum#valueOf(Class, String)}.
*/
public static