private GenericTypedValue(AMQType type, Object value) { if (type == null) { throw new NullPointerException("Cannot create a typed value with null type"); } _type = type; _value = type.toNativeValue(value); }
/** * Converts an instance of the type to an equivalent Java native representation, packaged as an * {@link AMQTypedValue} tagged with its AMQP type. * * @param value An instance of the type. * * @return An equivalent Java native representation, tagged with its AMQP type. */ public AMQTypedValue asTypedValue(Object value) { return AMQTypedValue.createAMQTypedValue(this, toNativeValue(value)); }
public static AMQTypedValue createAMQTypedValue(AMQType type, Object value) { switch(type) { case LONG: return new LongTypedValue((Long) AMQType.LONG.toNativeValue(value)); case INT: return new IntTypedValue((Integer) AMQType.INT.toNativeValue(value)); default: return new GenericTypedValue(type, value); } }