Skip to content

Commit b012aec

Browse files
committed
More deprecation, now on generator side
1 parent 3a34d55 commit b012aec

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

src/main/java/com/fasterxml/jackson/core/JsonGenerator.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ public Object getOutputTarget() {
410410
* @since 2.13 (added as replacement for older {@link #getCurrentValue()}
411411
*/
412412
public Object currentValue() {
413-
// TODO: implement directly in 2.14 or later, make getCurrentValue() call this
414-
return getCurrentValue();
413+
JsonStreamContext ctxt = getOutputContext();
414+
return (ctxt == null) ? null : ctxt.getCurrentValue();
415415
}
416416

417417
/**
@@ -425,20 +425,23 @@ public Object currentValue() {
425425
* @since 2.13 (added as replacement for older {@link #setCurrentValue}
426426
*/
427427
public void assignCurrentValue(Object v) {
428-
// TODO: implement directly in 2.14 or later, make setCurrentValue() call this
429-
setCurrentValue(v);
428+
JsonStreamContext ctxt = getOutputContext();
429+
if (ctxt != null) {
430+
ctxt.setCurrentValue(v);
431+
}
430432
}
431433

432-
// TODO: deprecate in 2.14 or later
433434
/**
434435
* Alias for {@link #currentValue()}, to be deprecated in later
435436
* Jackson 2.x versions (and removed from Jackson 3.0).
436437
*
437438
* @return Location of the last processed input unit (byte or character)
439+
*
440+
* @deprecated Since 2.17 use {@link #currentValue()} instead
438441
*/
442+
@Deprecated
439443
public Object getCurrentValue() {
440-
JsonStreamContext ctxt = getOutputContext();
441-
return (ctxt == null) ? null : ctxt.getCurrentValue();
444+
return currentValue();
442445
}
443446

444447
// TODO: deprecate in 2.14 or later
@@ -447,12 +450,12 @@ public Object getCurrentValue() {
447450
* Jackson 2.x versions (and removed from Jackson 3.0).
448451
*
449452
* @param v Current value to assign for the current context of this generator
453+
*
454+
* @deprecated Since 2.17 use {@link #currentValue()} instead
450455
*/
456+
@Deprecated
451457
public void setCurrentValue(Object v) {
452-
JsonStreamContext ctxt = getOutputContext();
453-
if (ctxt != null) {
454-
ctxt.setCurrentValue(v);
455-
}
458+
assignCurrentValue(v);
456459
}
457460

458461
/*

src/main/java/com/fasterxml/jackson/core/base/GeneratorBase.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ protected GeneratorBase(int features, ObjectCodec codec, IOContext ioContext, Js
151151
@Override public Version version() { return PackageVersion.VERSION; }
152152

153153
@Override
154-
public Object getCurrentValue() {
154+
public Object currentValue() {
155155
return _writeContext.getCurrentValue();
156156
}
157157

158158
@Override
159-
public void setCurrentValue(Object v) {
159+
public void assignCurrentValue(Object v) {
160160
if (_writeContext != null) {
161161
_writeContext.setCurrentValue(v);
162162
}
@@ -312,7 +312,7 @@ public void writeStartObject(Object forValue) throws IOException
312312
{
313313
writeStartObject();
314314
if (forValue != null) {
315-
setCurrentValue(forValue);
315+
assignCurrentValue(forValue);
316316
}
317317
}
318318

src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ public JsonGeneratorDelegate(JsonGenerator d, boolean delegateCopyMethods) {
6666
@Override public void assignCurrentValue(Object v) { delegate.assignCurrentValue(v); }
6767
@Override public Object currentValue() { return delegate.currentValue(); }
6868

69-
// TODO: deprecate in 2.14 or later
69+
@Deprecated // since 2.17
7070
@Override
7171
public void setCurrentValue(Object v) { delegate.setCurrentValue(v); }
7272

73-
// TODO: deprecate in 2.14 or later
73+
@Deprecated // since 2.17
7474
@Override
7575
public Object getCurrentValue() { return delegate.getCurrentValue(); }
7676

src/test/java/com/fasterxml/jackson/core/util/TestDelegates.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public void testGeneratorDelegateArrays() throws IOException
376376

377377
final Object MARKER = new Object();
378378
del.writeStartArray(MARKER);
379-
assertSame(MARKER, del.getCurrentValue());
379+
assertSame(MARKER, del.currentValue());
380380

381381
del.writeArray(new int[] { 1, 2, 3 }, 0, 3);
382382
del.writeArray(new long[] { 1, 123456, 2 }, 1, 1);
@@ -397,7 +397,7 @@ public void testGeneratorDelegateComments() throws IOException
397397

398398
final Object MARKER = new Object();
399399
del.writeStartArray(MARKER, 5);
400-
assertSame(MARKER, del.getCurrentValue());
400+
assertSame(MARKER, del.currentValue());
401401

402402
del.writeNumber((short) 1);
403403
del.writeNumber(12L);

0 commit comments

Comments
 (0)