Elffuss BraidHub

kikocis/java-driver public

Update JsonCodec example.
Changeset44e46587819e9583feb6eb5ae97f1a928c1a66232e13bf8bd4d14315c1926ed5
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-22 18:05 +01:00
CommitterAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-22 18:05 +01:00
Parents641f8153a8fc

Browse the files at this changeset

1 file changed

modified manual/custom_codecs/README.md +5 −5
@@ -89,7 +89,7 @@
8989 byte[] b = new byte[bytes.remaining()];
9090 // always duplicate the ByteBuffer instance before consuming it!
9191 bytes.duplicate().get(b);
92- return (T)objectMapper.readValue(b, toJacksonJavaType());
92+ return (T) objectMapper.readValue(b, toJacksonJavaType());
9393 } catch (IOException e) {
9494 throw new InvalidTypeException(e.getMessage(), e);
9595 }
@@ -98,7 +98,7 @@
9898 @Override
9999 public String format(T value) throws InvalidTypeException {
100100 if (value == null)
101- return NULL;
101+ return "NULL";
102102 String json;
103103 try {
104104 json = objectMapper.writeValueAsString(value);
@@ -111,13 +111,13 @@
111111 @Override
112112 @SuppressWarnings("unchecked")
113113 public T parse(String value) throws InvalidTypeException {
114- if (value == null || value.isEmpty() || value.equals(NULL))
114+ if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL"))
115115 return null;
116116 if (value.charAt(0) != '\'' || value.charAt(value.length() - 1) != '\'')
117117 throw new InvalidTypeException("JSON strings must be enclosed by single quotes");
118118 String json = value.substring(1, value.length() - 1).replace("''", "'");
119119 try {
120- return (T)objectMapper.readValue(json, toJacksonJavaType());
120+ return (T) objectMapper.readValue(json, toJacksonJavaType());
121121 } catch (IOException e) {
122122 throw new InvalidTypeException(e.getMessage(), e);
123123 }
@@ -126,7 +126,7 @@
126126 protected JavaType toJacksonJavaType() {
127127 return TypeFactory.defaultInstance().constructType(getJavaType().getType());
128128 }
129-
129+
130130 }
131131 ```
132132