Skip to content

Commit ffeb90b

Browse files
authored
Clean up of Ion module (#408)
1 parent bb3f600 commit ffeb90b

File tree

16 files changed

+36
-34
lines changed

16 files changed

+36
-34
lines changed

avro/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ abstractions.
5454
<dependency>
5555
<groupId>ch.qos.logback</groupId>
5656
<artifactId>logback-classic</artifactId>
57-
<version>1.2.11</version>
57+
<version>1.2.12</version>
5858
<scope>test</scope>
5959
</dependency>
6060
<!-- For validating more complex comparisons -->

ion/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ SomeType otherValue = mapper.readValue(data, SomeType.class);
3434

3535
### java.time JSR 310
3636

37-
With version 2.12 (to be released in September 2020), there will be optional support for
37+
Version 2.12 (released on November 28, 2020) added support for
3838
(de)serializing some `java.time` classes directly from/to Ion timestamp values.
39-
To enable it, you need to registed module `IonJavaTimeModule` like so:
39+
To enable it, you need to register module `IonJavaTimeModule` like so:
4040

4141
```java
4242
IonObjectMapper mapper = IonObjectMapper.builder()

ion/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
66
<!-- that they should prefer consuming it instead. -->
77
<!-- do_not_remove: published-with-gradle-metadata -->
8-
<modelVersion>4.0.0</modelVersion>
8+
<modelVersion>4.0.0</modelVersion>
99
<parent>
1010
<groupId>com.fasterxml.jackson.dataformat</groupId>
1111
<artifactId>jackson-dataformats-binary</artifactId>
@@ -85,8 +85,8 @@ tree model)
8585
will have to use `moduleInfoFile` as anything else requires JDK 9+
8686
-->
8787
<plugin>
88-
<groupId>org.moditect</groupId>
89-
<artifactId>moditect-maven-plugin</artifactId>
88+
<groupId>org.moditect</groupId>
89+
<artifactId>moditect-maven-plugin</artifactId>
9090
</plugin>
9191
</plugins>
9292
</build>

ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonGenerator.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.IOException;
2020
import java.math.BigDecimal;
2121
import java.math.BigInteger;
22+
import java.nio.charset.StandardCharsets;
2223
import java.util.Calendar;
2324

2425
import com.fasterxml.jackson.core.Base64Variant;
@@ -220,7 +221,7 @@ public JacksonFeatureSet<StreamWriteCapability> getWriteCapabilities() {
220221
@Override
221222
public void writeNumber(int value) throws IOException {
222223
_verifyValueWrite("write numeric value");
223-
_writer.writeInt((long)value);
224+
_writer.writeInt(value);
224225
}
225226

226227
@Override
@@ -248,7 +249,7 @@ public void writeNumber(double value) throws IOException {
248249
@Override
249250
public void writeNumber(float value) throws IOException {
250251
_verifyValueWrite("write numeric value");
251-
_writer.writeFloat((double) value);
252+
_writer.writeFloat(value);
252253
}
253254

254255
@Override
@@ -314,7 +315,7 @@ public void writeString(char[] buffer, int offset, int length) throws IOExceptio
314315
@Override
315316
public void writeUTF8String(byte[] buffer, int offset, int length) throws IOException {
316317
// Ion doesn't have matching optimized method, so:
317-
writeString(new String(buffer, offset, length, "UTF-8"));
318+
writeString(new String(buffer, offset, length, StandardCharsets.UTF_8));
318319
}
319320

320321
/*

ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantDeserializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public JsonDeserializer<T> createContextual(DeserializationContext ctxt, BeanPro
9595

9696
final JsonFormat.Value format = findFormatOverrides(ctxt, property, handledType());
9797
if (format != null) {
98-
return new IonTimestampInstantDeserializer<T>(this,
98+
return new IonTimestampInstantDeserializer<>(this,
9999
format.getFeature(Feature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE));
100100
}
101101
return this;

ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindRoundtripTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ public void testNullFields() throws IOException
130130
doTests(new Bean(), new IonObjectMapper());
131131
}
132132

133-
private void doTests(Bean bean, IonObjectMapper mapper) throws IOException
134-
{
133+
private void doTests(Bean bean, IonObjectMapper mapper) {
135134
for (RoundTrippers rt : RoundTrippers.values()) {
136135
try
137136
{
@@ -156,9 +155,9 @@ public void testIonRoot() throws IOException {
156155
Bean bean = m.readValue(root, Bean.class);
157156
assertNotNull(bean);
158157
assertEquals(bean.a, "test");
159-
assertTrue(bean.b == 0.25);
158+
assertEquals(0.25, bean.b, 0.0);
160159
assertArrayEquals(new byte[0], bean.data);
161-
assertEquals(bean.state, true);
160+
assertTrue(bean.state);
162161
assertNotNull(bean.sub);
163162
assertEquals("yellow", bean.sub.getValue());
164163
assertEquals("testSymbol", bean.symbol);
@@ -211,7 +210,7 @@ private void _testRoundTrip(Bean bean, RoundTrippers rt, IonObjectMapper m) thro
211210

212211
assertNotNull(result);
213212
assertEquals(bean.a, result.a);
214-
assertTrue(bean.b == result.b);
213+
assertEquals(bean.b, result.b, 0.0);
215214
assertArrayEquals(bean.data, result.data);
216215
assertEquals(bean.state, result.state);
217216
if (bean.sub == null)
@@ -227,6 +226,6 @@ private void _testRoundTrip(Bean bean, RoundTrippers rt, IonObjectMapper m) thro
227226
assertEquals(bean.enumVal, result.enumVal);
228227
assertEquals(bean.bigDec, result.bigDec);
229228
assertEquals(bean.bigInt, result.bigInt);
230-
assertTrue(bean.f == result.f);
229+
assertEquals(bean.f, result.f, 0.0);
231230
}
232231
}

ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonGeneratorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class IonGeneratorTest {
4444
"}";
4545

4646
static {
47-
final Map<String, String> map = new HashMap<String, String>();
47+
final Map<String, String> map = new HashMap<>();
4848
map.put("a", "A");
4949
map.put("b", "B");
5050
map.put("c", "C");
@@ -78,7 +78,7 @@ public void setUp() throws Exception {
7878
@Test
7979
public void testSimpleWrite() throws Exception {
8080
joiGenerator.writeBoolean(true);
81-
assertThat(output.get(0), is((IonValue)ionSystem.newBool(true)));
81+
assertThat(output.get(0), is(ionSystem.newBool(true)));
8282
}
8383

8484
@Test

ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonParserTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void testGetNumberTypeAndValue() throws Exception {
6464
IonParser decimalParser = new IonFactory().createParser(ionDecimal);
6565
Assert.assertEquals(JsonToken.VALUE_NUMBER_FLOAT, decimalParser.nextToken());
6666
Assert.assertEquals(JsonParser.NumberType.BIG_DECIMAL, decimalParser.getNumberType());
67-
Assert.assertTrue(new BigDecimal("" + decimalValue).compareTo((BigDecimal)decimalParser.getNumberValue()) == 0);
67+
Assert.assertEquals(0, new BigDecimal("" + decimalValue).compareTo((BigDecimal) decimalParser.getNumberValue()));
6868

6969
Double floatValue = Double.MAX_VALUE;
7070
IonValue ionFloat = ion.newFloat(floatValue);
@@ -78,7 +78,7 @@ public void testGetNumberTypeAndValue() throws Exception {
7878
IonParser bigDecimalParser = new IonFactory().createParser(ionBigDecimal);
7979
Assert.assertEquals(JsonToken.VALUE_NUMBER_FLOAT, bigDecimalParser.nextToken());
8080
Assert.assertEquals(JsonParser.NumberType.BIG_DECIMAL, bigDecimalParser.getNumberType());
81-
Assert.assertTrue(bigDecimalValue.compareTo((BigDecimal)bigDecimalParser.getNumberValue()) == 0);
81+
Assert.assertEquals(0, bigDecimalValue.compareTo((BigDecimal) bigDecimalParser.getNumberValue()));
8282
}
8383

8484
@Test

ion/src/test/java/com/fasterxml/jackson/dataformat/ion/PolymorphicRoundtripTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ public void testSelectivePolymorphism() throws IOException {
124124
// to be chosen (and we expect that first id to be the most narrow type, ChildBeanSub).
125125
Bean deserialized = mapper.readValue(serialized, Bean.class);
126126

127-
assertTrue(deserialized.child.getClass().equals(ChildBeanSub.class));
127+
assertEquals(deserialized.child.getClass(), ChildBeanSub.class);
128128
assertEquals(((ChildBeanSub) original.child).extraField, ((ChildBeanSub) deserialized.child).extraField);
129129

130130
// second, try deserializing with the wider type (ChildBean). We're losing data (extraField)
131131
preferredTypeId = getClass().getCanonicalName() + "$ChildBean";
132132
deserialized = mapper.readValue(serialized, Bean.class);
133133

134-
assertTrue(deserialized.child.getClass().equals(ChildBean.class));
134+
assertEquals(deserialized.child.getClass(), ChildBean.class);
135135
assertEquals(original.child.someField, deserialized.child.someField);
136136

137137
// third, try deserializing into an Object. The child node should deserialize, but immediately fail mapping.
@@ -319,7 +319,7 @@ class MultipleClassNameIdResolver extends ClassNameIdResolver implements Multipl
319319

320320
@Override
321321
public String[] idsFromValue(Object value) {
322-
List<String> ids = new ArrayList<String>();
322+
List<String> ids = new ArrayList<>();
323323
Class<?> cls = value.getClass();
324324
while (null != cls) {
325325
ids.add(super.idFromValueAndType(value, cls));

ion/src/test/java/com/fasterxml/jackson/dataformat/ion/SimpleIonWriteTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private void _writeSimple(JsonGenerator gen) throws IOException
8383
gen.writeStartObject();
8484
gen.writeStringField("a", "value");
8585
gen.writeNumberField("b", 42);
86-
((IonGenerator)gen).writeFieldName("c");
86+
gen.writeFieldName("c");
8787
((IonGenerator)gen).writeNull(IonType.INT);
8888
gen.writeEndObject();
8989
gen.close();

0 commit comments

Comments
 (0)