Skip to content

Commit

Permalink
More deprecation, now on generator side
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 6, 2023
1 parent 3a34d55 commit b012aec
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
25 changes: 14 additions & 11 deletions src/main/java/com/fasterxml/jackson/core/JsonGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ public Object getOutputTarget() {
* @since 2.13 (added as replacement for older {@link #getCurrentValue()}
*/
public Object currentValue() {
// TODO: implement directly in 2.14 or later, make getCurrentValue() call this
return getCurrentValue();
JsonStreamContext ctxt = getOutputContext();
return (ctxt == null) ? null : ctxt.getCurrentValue();
}

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

// TODO: deprecate in 2.14 or later
/**
* Alias for {@link #currentValue()}, to be deprecated in later
* Jackson 2.x versions (and removed from Jackson 3.0).
*
* @return Location of the last processed input unit (byte or character)
*
* @deprecated Since 2.17 use {@link #currentValue()} instead
*/
@Deprecated
public Object getCurrentValue() {
JsonStreamContext ctxt = getOutputContext();
return (ctxt == null) ? null : ctxt.getCurrentValue();
return currentValue();
}

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

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ protected GeneratorBase(int features, ObjectCodec codec, IOContext ioContext, Js
@Override public Version version() { return PackageVersion.VERSION; }

@Override
public Object getCurrentValue() {
public Object currentValue() {
return _writeContext.getCurrentValue();
}

@Override
public void setCurrentValue(Object v) {
public void assignCurrentValue(Object v) {
if (_writeContext != null) {
_writeContext.setCurrentValue(v);
}
Expand Down Expand Up @@ -312,7 +312,7 @@ public void writeStartObject(Object forValue) throws IOException
{
writeStartObject();
if (forValue != null) {
setCurrentValue(forValue);
assignCurrentValue(forValue);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public JsonGeneratorDelegate(JsonGenerator d, boolean delegateCopyMethods) {
@Override public void assignCurrentValue(Object v) { delegate.assignCurrentValue(v); }
@Override public Object currentValue() { return delegate.currentValue(); }

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public void testGeneratorDelegateArrays() throws IOException

final Object MARKER = new Object();
del.writeStartArray(MARKER);
assertSame(MARKER, del.getCurrentValue());
assertSame(MARKER, del.currentValue());

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

final Object MARKER = new Object();
del.writeStartArray(MARKER, 5);
assertSame(MARKER, del.getCurrentValue());
assertSame(MARKER, del.currentValue());

del.writeNumber((short) 1);
del.writeNumber(12L);
Expand Down

0 comments on commit b012aec

Please sign in to comment.