Skip to content

Commit

Permalink
Minor warnings removal
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 6, 2023
1 parent 44051d5 commit 0e76830
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,13 @@ public JsonGenerator overrideFormatFeatures(int values, int mask) {
/**********************************************************
*/

@Override // since 2.13
public Object currentValue() {
return _streamWriteContext.getCurrentValue();
@Override
public JsonStreamContext getOutputContext() {
return _streamWriteContext;
}

@Override
public Object getCurrentValue() {
@Override // since 2.13
public Object currentValue() {
return _streamWriteContext.getCurrentValue();
}

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

@Deprecated // since 2.17
@Override
public void setCurrentValue(Object v) {
_streamWriteContext.setCurrentValue(v);
}
public Object getCurrentValue() { return currentValue(); }

@Deprecated // since 2.17
@Override
public JsonStreamContext getOutputContext() {
return _streamWriteContext;
}
public void setCurrentValue(Object v) { assignCurrentValue(v); }

/*
/**********************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

package com.fasterxml.jackson.dataformat.ion;

import org.junit.Rule;
import org.junit.Test;
import org.junit.Before;
import org.junit.rules.ExpectedException;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonNode;

Expand All @@ -33,6 +31,8 @@

import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

public class IonGeneratorTest {
private static final Map<String, String> testObject;
Expand All @@ -59,9 +59,6 @@ public class IonGeneratorTest {
private IonValue testObjectIon;
private JsonNode testObjectTree;

@Rule
public ExpectedException thrown = ExpectedException.none();

@Before
public void setUp() throws Exception {
final IonFactory factory = new IonFactory();
Expand Down Expand Up @@ -127,16 +124,24 @@ public void testTreeWriteVerifiesOnce() throws Exception {
@Test
public void testWriteFieldNameFailsInSexp() throws Exception {
joiGenerator.writeStartSexp();
thrown.expect(JsonGenerationException.class);
thrown.expectMessage("Can not write a field name, expecting a value");
joiGenerator.writeFieldName("foo");
try {
joiGenerator.writeFieldName("foo");
fail("Should not pass");
} catch (JsonGenerationException e) {
assertEquals("Can not write a field name, expecting a value",
e.getMessage());
}
}

@Test
public void testWriteStartSexpFailsWithoutWriteFieldName() throws Exception {
joiGenerator.writeStartObject();
thrown.expect(JsonGenerationException.class);
thrown.expectMessage("Can not start a sexp, expecting field name");
joiGenerator.writeStartSexp();
try {
joiGenerator.writeStartSexp();
fail("Should not pass");
} catch (JsonGenerationException e) {
assertEquals("Can not start a sexp, expecting field name",
e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,31 +158,6 @@ public void setSchema(ProtobufSchema schema)
_pbContext = _rootContext = ProtobufWriteContext.createRootContext(schema.getRootType());
}

@Override
public StreamWriteConstraints streamWriteConstraints() {
return _streamWriteConstraints;
}

@Override // since 2.13
public Object currentValue() {
return _pbContext.getCurrentValue();
}

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

@Override // since 2.13
public void assignCurrentValue(Object v) {
_pbContext.setCurrentValue(v);
}

@Override
public void setCurrentValue(Object v) {
_pbContext.setCurrentValue(v);
}

/*
/**********************************************************
/* Versioned
Expand Down Expand Up @@ -221,6 +196,11 @@ public boolean canUseSchema(FormatSchema schema) {
/**********************************************************
*/

@Override
public StreamWriteConstraints streamWriteConstraints() {
return _streamWriteConstraints;
}

/**
* Not sure whether to throw an exception or just do no-op; for now,
* latter.
Expand Down Expand Up @@ -265,6 +245,30 @@ public void setSchema(FormatSchema schema)
setSchema((ProtobufSchema) schema);
}

/*
/**********************************************************
/* Overridden methods, output context (and related)
/**********************************************************
*/

@Override // since 2.13
public Object currentValue() {
return _pbContext.getCurrentValue();
}

@Override // since 2.13
public void assignCurrentValue(Object v) {
_pbContext.setCurrentValue(v);
}

@Deprecated // since 2.17
@Override
public Object getCurrentValue() { return currentValue(); }

@Deprecated // since 2.17
@Override
public void setCurrentValue(Object v) { assignCurrentValue(v); }

/*
/**********************************************************************
/* Overridden methods; writing field names
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,13 @@ public JsonGenerator overrideFormatFeatures(int values, int mask) {
/**********************************************************
*/

@Override // since 2.13
public Object currentValue() {
return _streamWriteContext.getCurrentValue();
@Override
public JsonStreamContext getOutputContext() {
return _streamWriteContext;
}

@Override
public Object getCurrentValue() {
@Override // since 2.13
public Object currentValue() {
return _streamWriteContext.getCurrentValue();
}

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

@Deprecated // since 2.17
@Override
public void setCurrentValue(Object v) {
_streamWriteContext.setCurrentValue(v);
}
public Object getCurrentValue() { return currentValue(); }

@Deprecated // since 2.17
@Override
public JsonStreamContext getOutputContext() {
return _streamWriteContext;
}
public void setCurrentValue(Object v) { assignCurrentValue(v); }

/*
/**********************************************************
Expand Down

0 comments on commit 0e76830

Please sign in to comment.