Skip to content

Commit 0e76830

Browse files
committed
Minor warnings removal
1 parent 44051d5 commit 0e76830

File tree

4 files changed

+63
-58
lines changed

4 files changed

+63
-58
lines changed

cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORGenerator.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -450,13 +450,13 @@ public JsonGenerator overrideFormatFeatures(int values, int mask) {
450450
/**********************************************************
451451
*/
452452

453-
@Override // since 2.13
454-
public Object currentValue() {
455-
return _streamWriteContext.getCurrentValue();
453+
@Override
454+
public JsonStreamContext getOutputContext() {
455+
return _streamWriteContext;
456456
}
457457

458-
@Override
459-
public Object getCurrentValue() {
458+
@Override // since 2.13
459+
public Object currentValue() {
460460
return _streamWriteContext.getCurrentValue();
461461
}
462462

@@ -465,15 +465,13 @@ public void assignCurrentValue(Object v) {
465465
_streamWriteContext.setCurrentValue(v);
466466
}
467467

468+
@Deprecated // since 2.17
468469
@Override
469-
public void setCurrentValue(Object v) {
470-
_streamWriteContext.setCurrentValue(v);
471-
}
470+
public Object getCurrentValue() { return currentValue(); }
472471

472+
@Deprecated // since 2.17
473473
@Override
474-
public JsonStreamContext getOutputContext() {
475-
return _streamWriteContext;
476-
}
474+
public void setCurrentValue(Object v) { assignCurrentValue(v); }
477475

478476
/*
479477
/**********************************************************

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
package com.fasterxml.jackson.dataformat.ion;
1616

17-
import org.junit.Rule;
1817
import org.junit.Test;
1918
import org.junit.Before;
20-
import org.junit.rules.ExpectedException;
2119
import com.fasterxml.jackson.core.JsonGenerationException;
2220
import com.fasterxml.jackson.databind.JsonNode;
2321

@@ -33,6 +31,8 @@
3331

3432
import static org.hamcrest.Matchers.is;
3533
import static org.hamcrest.MatcherAssert.assertThat;
34+
import static org.junit.Assert.assertEquals;
35+
import static org.junit.Assert.fail;
3636

3737
public class IonGeneratorTest {
3838
private static final Map<String, String> testObject;
@@ -59,9 +59,6 @@ public class IonGeneratorTest {
5959
private IonValue testObjectIon;
6060
private JsonNode testObjectTree;
6161

62-
@Rule
63-
public ExpectedException thrown = ExpectedException.none();
64-
6562
@Before
6663
public void setUp() throws Exception {
6764
final IonFactory factory = new IonFactory();
@@ -127,16 +124,24 @@ public void testTreeWriteVerifiesOnce() throws Exception {
127124
@Test
128125
public void testWriteFieldNameFailsInSexp() throws Exception {
129126
joiGenerator.writeStartSexp();
130-
thrown.expect(JsonGenerationException.class);
131-
thrown.expectMessage("Can not write a field name, expecting a value");
132-
joiGenerator.writeFieldName("foo");
127+
try {
128+
joiGenerator.writeFieldName("foo");
129+
fail("Should not pass");
130+
} catch (JsonGenerationException e) {
131+
assertEquals("Can not write a field name, expecting a value",
132+
e.getMessage());
133+
}
133134
}
134135

135136
@Test
136137
public void testWriteStartSexpFailsWithoutWriteFieldName() throws Exception {
137138
joiGenerator.writeStartObject();
138-
thrown.expect(JsonGenerationException.class);
139-
thrown.expectMessage("Can not start a sexp, expecting field name");
140-
joiGenerator.writeStartSexp();
139+
try {
140+
joiGenerator.writeStartSexp();
141+
fail("Should not pass");
142+
} catch (JsonGenerationException e) {
143+
assertEquals("Can not start a sexp, expecting field name",
144+
e.getMessage());
145+
}
141146
}
142147
}

protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufGenerator.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -158,31 +158,6 @@ public void setSchema(ProtobufSchema schema)
158158
_pbContext = _rootContext = ProtobufWriteContext.createRootContext(schema.getRootType());
159159
}
160160

161-
@Override
162-
public StreamWriteConstraints streamWriteConstraints() {
163-
return _streamWriteConstraints;
164-
}
165-
166-
@Override // since 2.13
167-
public Object currentValue() {
168-
return _pbContext.getCurrentValue();
169-
}
170-
171-
@Override
172-
public Object getCurrentValue() {
173-
return _pbContext.getCurrentValue();
174-
}
175-
176-
@Override // since 2.13
177-
public void assignCurrentValue(Object v) {
178-
_pbContext.setCurrentValue(v);
179-
}
180-
181-
@Override
182-
public void setCurrentValue(Object v) {
183-
_pbContext.setCurrentValue(v);
184-
}
185-
186161
/*
187162
/**********************************************************
188163
/* Versioned
@@ -221,6 +196,11 @@ public boolean canUseSchema(FormatSchema schema) {
221196
/**********************************************************
222197
*/
223198

199+
@Override
200+
public StreamWriteConstraints streamWriteConstraints() {
201+
return _streamWriteConstraints;
202+
}
203+
224204
/**
225205
* Not sure whether to throw an exception or just do no-op; for now,
226206
* latter.
@@ -265,6 +245,30 @@ public void setSchema(FormatSchema schema)
265245
setSchema((ProtobufSchema) schema);
266246
}
267247

248+
/*
249+
/**********************************************************
250+
/* Overridden methods, output context (and related)
251+
/**********************************************************
252+
*/
253+
254+
@Override // since 2.13
255+
public Object currentValue() {
256+
return _pbContext.getCurrentValue();
257+
}
258+
259+
@Override // since 2.13
260+
public void assignCurrentValue(Object v) {
261+
_pbContext.setCurrentValue(v);
262+
}
263+
264+
@Deprecated // since 2.17
265+
@Override
266+
public Object getCurrentValue() { return currentValue(); }
267+
268+
@Deprecated // since 2.17
269+
@Override
270+
public void setCurrentValue(Object v) { assignCurrentValue(v); }
271+
268272
/*
269273
/**********************************************************************
270274
/* Overridden methods; writing field names

smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileGenerator.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -470,13 +470,13 @@ public JsonGenerator overrideFormatFeatures(int values, int mask) {
470470
/**********************************************************
471471
*/
472472

473-
@Override // since 2.13
474-
public Object currentValue() {
475-
return _streamWriteContext.getCurrentValue();
473+
@Override
474+
public JsonStreamContext getOutputContext() {
475+
return _streamWriteContext;
476476
}
477477

478-
@Override
479-
public Object getCurrentValue() {
478+
@Override // since 2.13
479+
public Object currentValue() {
480480
return _streamWriteContext.getCurrentValue();
481481
}
482482

@@ -485,15 +485,13 @@ public void assignCurrentValue(Object v) {
485485
_streamWriteContext.setCurrentValue(v);
486486
}
487487

488+
@Deprecated // since 2.17
488489
@Override
489-
public void setCurrentValue(Object v) {
490-
_streamWriteContext.setCurrentValue(v);
491-
}
490+
public Object getCurrentValue() { return currentValue(); }
492491

492+
@Deprecated // since 2.17
493493
@Override
494-
public JsonStreamContext getOutputContext() {
495-
return _streamWriteContext;
496-
}
494+
public void setCurrentValue(Object v) { assignCurrentValue(v); }
497495

498496
/*
499497
/**********************************************************

0 commit comments

Comments
 (0)