class StringConverter implements AtlasConverter<String> {

    @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.BYTE, concerns = {
            AtlasConversionConcern.RANGE, AtlasConversionConcern.FORMAT, AtlasConversionConcern.FRACTIONAL_PART})
    public Byte toByte(String value) throws AtlasConversionException {
        if (value == null) {
            return null;
        }
        try {
            return Byte.parseByte(value);
        } catch (NumberFormatException nfex) {
            try {
                BigDecimal bd = new BigDecimal(value);
                if (bd.compareTo(new BigDecimal(Byte.MIN_VALUE)) < 0
                        || bd.compareTo(new BigDecimal(Byte.MAX_VALUE)) > 0) {
                    throw new AtlasConversionException(String
                            .format("String %s is greater than Byte.MAX_VALUE  or less than Byte.MIN_VALUE", value));
                }
                return bd.byteValue();
            } catch (NumberFormatException nfe2) {
                throw new AtlasConversionException(String
                        .format("String %s cannont be converted to a Byte as it is not in a numerical format", value));
            }
        }
    }

}