in harry-core/src/harry/util/ByteUtils.java [103:139]
public static ByteBuffer objectToBytes(Object obj)
{
if (obj instanceof Integer)
return bytes((int) obj);
else if (obj instanceof Byte)
return bytes((byte) obj);
else if (obj instanceof Boolean)
return bytes( (byte) (((boolean) obj) ? 1 : 0));
else if (obj instanceof Short)
return bytes((short) obj);
else if (obj instanceof Long)
return bytes((long) obj);
else if (obj instanceof Float)
return bytes((float) obj);
else if (obj instanceof Double)
return bytes((double) obj);
else if (obj instanceof UUID)
return bytes((UUID) obj);
else if (obj instanceof InetAddress)
return bytes((InetAddress) obj);
else if (obj instanceof String)
return bytes((String) obj);
else if (obj instanceof List)
{
throw new UnsupportedOperationException("Please use ByteUtils from integration package");
}
else if (obj instanceof Set)
{
throw new UnsupportedOperationException("Please use ByteUtils from integration package");
}
else if (obj instanceof ByteBuffer)
return (ByteBuffer) obj;
else
throw new IllegalArgumentException(String.format("Cannot convert value %s of type %s",
obj,
obj.getClass()));
}