public static byte[] getBytes(Object value, Class<?> clazz)
    {
        if (clazz.isAssignableFrom(String.class))
        {
            return Bytes.toBytes(value.toString());
        }
        else if (clazz.equals(int.class) || clazz.isAssignableFrom(Integer.class))
        {
            return Bytes.toBytes(value instanceof Integer ? (Integer) value : new Integer(value.toString()));
        }
        else if (clazz.equals(long.class) || clazz.isAssignableFrom(Long.class))
        {
            return Bytes.toBytes(value instanceof Long ? (Long) value : new Long(value.toString()));
        }
        else if (clazz.equals(boolean.class) || clazz.isAssignableFrom(Boolean.class))
        {
            return Bytes.toBytes(value instanceof Boolean ? (Boolean) value : new Boolean(value.toString()));
        }
        else if (clazz.equals(double.class) || clazz.isAssignableFrom(Double.class))
        {
            return Bytes.toBytes(value instanceof Double ? (Double) value : new Double(value.toString()));
        }
        else if (clazz.equals(float.class) || clazz.isAssignableFrom(Float.class))
        {
            return Bytes.toBytes(value instanceof Float ? (Float) value : new Float(value.toString()));
        }
        else if (clazz.equals(short.class) || clazz.isAssignableFrom(Short.class))
        {
            return Bytes.toBytes(value instanceof Short ? (Short) value : new Short(value.toString()));
        }
        else if (clazz.equals(BigDecimal.class))
        {
            return Bytes.toBytes(value instanceof BigDecimal ? (BigDecimal) value : new BigDecimal(value.toString()));
        }
        else
        {
            if (value.getClass().isAssignableFrom(String.class))
            {
                value = PropertyAccessorFactory.getPropertyAccessor(clazz).fromString(clazz, value.toString());
            }
            return PropertyAccessorFactory.getPropertyAccessor(clazz).toBytes(value);
        }
    }
public static byte [ ] getBytes ( Object value , Class < ? > clazz ) { if ( clazz . isAssignableFrom ( String . class ) ) { return Bytes . toBytes ( value . toString ( ) ) ; } else if ( clazz . equals ( int . class ) || clazz . isAssignableFrom ( Integer . class ) ) { return Bytes . toBytes ( value instanceof Integer ? ( Integer ) value : new Integer ( value . toString ( ) ) ) ; } else if ( clazz . equals ( long . class ) || clazz . isAssignableFrom ( Long . class ) ) { return Bytes . toBytes ( value instanceof Long ? ( Long ) value : new Long ( value . toString ( ) ) ) ; } else if ( clazz . equals ( boolean . class ) || clazz . isAssignableFrom ( Boolean . class ) ) { return Bytes . toBytes ( value instanceof Boolean ? ( Boolean ) value : new Boolean ( value . toString ( ) ) ) ; } else if ( clazz . equals ( double . class ) || clazz . isAssignableFrom ( Double . class ) ) { return Bytes . toBytes ( value instanceof Double ? ( Double ) value : new Double ( value . toString ( ) ) ) ; } else if ( clazz . equals ( float . class ) || clazz . isAssignableFrom ( Float . class ) ) { return Bytes . toBytes ( value instanceof Float ? ( Float ) value : new Float ( value . toString ( ) ) ) ; } else if ( clazz . equals ( short . class ) || clazz . isAssignableFrom ( Short . class ) ) { return Bytes . toBytes ( value instanceof Short ? ( Short ) value : new Short ( value . toString ( ) ) ) ; } else if ( clazz . equals ( BigDecimal . class ) ) { return Bytes . toBytes ( value instanceof BigDecimal ? ( BigDecimal ) value : new BigDecimal ( value . toString ( ) ) ) ; } else { if ( value . getClass ( ) . isAssignableFrom ( String . class ) ) { value = PropertyAccessorFactory . getPropertyAccessor ( clazz ) . fromString ( clazz , value . toString ( ) ) ; } return PropertyAccessorFactory . getPropertyAccessor ( clazz ) . toBytes ( value ) ; } }
Gets the bytes.

@param value
the value
@param clazz
the clazz
@return the bytes