org.bbottema.javareflection.valueconverter.converters.StringConverters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-reflection Show documentation
Show all versions of java-reflection Show documentation
Java Reflection provides a small package with nifty reflection features that will help with finding constructors, methods and value conversions
package org.bbottema.javareflection.valueconverter.converters;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.experimental.UtilityClass;
import org.bbottema.javareflection.util.Function;
import org.bbottema.javareflection.util.Function.Functions;
import org.bbottema.javareflection.util.commonslang25.NumberUtils;
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 org.slf4j.Logger;
import java.io.File;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import static org.slf4j.LoggerFactory.getLogger;
/**
* 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