@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { if (parsed instanceof String) return new Constants.Value(fromString((String) parsed)); Number parsedNumber = (Number) parsed; if (!(parsedNumber instanceof Integer || parsedNumber instanceof Long)) throw new MarshalException(String.format("Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); return new Constants.Value(getSerializer().serialize(parsedNumber.longValue())); } catch (ClassCastException exc) { throw new MarshalException(String.format( "Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); } }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { if (parsed instanceof String) return new Constants.Value(fromString((String) parsed)); Number parsedNumber = (Number) parsed; if (!(parsedNumber instanceof Integer || parsedNumber instanceof Long)) throw new MarshalException(String.format("Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); return new Constants.Value(getSerializer().serialize(parsedNumber.longValue())); } catch (ClassCastException exc) { throw new MarshalException(String.format( "Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); } }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { if (parsed instanceof String) return new Constants.Value(fromString((String) parsed)); Number parsedNumber = (Number) parsed; if (!(parsedNumber instanceof Integer || parsedNumber instanceof Long)) throw new MarshalException(String.format("Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); return new Constants.Value(getSerializer().serialize(parsedNumber.longValue())); } catch (ClassCastException exc) { throw new MarshalException(String.format( "Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); } }
@Override public Term fromJSONObject(Object parsed) throws MarshalException { try { if (parsed instanceof String) return new Constants.Value(fromString((String) parsed)); Number parsedNumber = (Number) parsed; if (!(parsedNumber instanceof Integer || parsedNumber instanceof Long)) throw new MarshalException(String.format("Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); return new Constants.Value(getSerializer().serialize(parsedNumber.longValue())); } catch (ClassCastException exc) { throw new MarshalException(String.format( "Expected a bigint value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed)); } }
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException { if (validator instanceof ReversedType<?>) validator = ((ReversedType<?>) validator).baseType; try { // BytesType doesn't want it's input prefixed by '0x'. if (type == Type.HEX && validator instanceof BytesType) return validator.fromString(text.substring(2)); if (validator instanceof CounterColumnType) return LongType.instance.fromString(text); return validator.fromString(text); } catch (MarshalException e) { throw new InvalidRequestException(e.getMessage()); } }
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException { if (validator instanceof ReversedType<?>) validator = ((ReversedType<?>) validator).baseType; try { if (type == Type.HEX) // Note that validator could be BytesType, but it could also be a custom type, so // we hardcode BytesType (rather than using 'validator') in the call below. // Further note that BytesType doesn't want it's input prefixed by '0x', hence the substring. return BytesType.instance.fromString(text.substring(2)); if (validator instanceof CounterColumnType) return LongType.instance.fromString(text); return validator.fromString(text); } catch (MarshalException e) { throw new InvalidRequestException(e.getMessage()); } }
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException { if (validator instanceof ReversedType<?>) validator = ((ReversedType<?>) validator).baseType; try { if (type == Type.HEX) // Note that validator could be BytesType, but it could also be a custom type, so // we hardcode BytesType (rather than using 'validator') in the call below. // Further note that BytesType doesn't want it's input prefixed by '0x', hence the substring. return BytesType.instance.fromString(text.substring(2)); if (validator instanceof CounterColumnType) return LongType.instance.fromString(text); return validator.fromString(text); } catch (MarshalException e) { throw new InvalidRequestException(e.getMessage()); } }
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException { if (validator instanceof ReversedType<?>) validator = ((ReversedType<?>) validator).baseType; try { if (type == Type.HEX) // Note that validator could be BytesType, but it could also be a custom type, so // we hardcode BytesType (rather than using 'validator') in the call below. // Further note that BytesType doesn't want it's input prefixed by '0x', hence the substring. return BytesType.instance.fromString(text.substring(2)); if (validator instanceof CounterColumnType) return LongType.instance.fromString(text); return validator.fromString(text); } catch (MarshalException e) { throw new InvalidRequestException(e.getMessage()); } }
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException { if (validator instanceof ReversedType<?>) validator = ((ReversedType<?>) validator).baseType; try { if (type == Type.HEX) // Note that validator could be BytesType, but it could also be a custom type, so // we hardcode BytesType (rather than using 'validator') in the call below. // Further note that BytesType doesn't want it's input prefixed by '0x', hence the substring. return BytesType.instance.fromString(text.substring(2)); if (validator instanceof CounterColumnType) return LongType.instance.fromString(text); return validator.fromString(text); } catch (MarshalException e) { throw new InvalidRequestException(e.getMessage()); } }