Ray Milkey

Refeactor codec helper classes

Change-Id: Ic980293f5df97ed74a73fc54e3dcb197658264f5
...@@ -45,8 +45,8 @@ public final class ConstraintCodec extends JsonCodec<Constraint> { ...@@ -45,8 +45,8 @@ public final class ConstraintCodec extends JsonCodec<Constraint> {
45 public ObjectNode encode(Constraint constraint, CodecContext context) { 45 public ObjectNode encode(Constraint constraint, CodecContext context) {
46 checkNotNull(constraint, "Constraint cannot be null"); 46 checkNotNull(constraint, "Constraint cannot be null");
47 47
48 - final EncodeConstraintCodec encodeCodec = 48 + final EncodeConstraintCodecHelper encodeCodec =
49 - new EncodeConstraintCodec(constraint, context); 49 + new EncodeConstraintCodecHelper(constraint, context);
50 50
51 return encodeCodec.encode(); 51 return encodeCodec.encode();
52 } 52 }
...@@ -55,8 +55,8 @@ public final class ConstraintCodec extends JsonCodec<Constraint> { ...@@ -55,8 +55,8 @@ public final class ConstraintCodec extends JsonCodec<Constraint> {
55 public Constraint decode(ObjectNode json, CodecContext context) { 55 public Constraint decode(ObjectNode json, CodecContext context) {
56 checkNotNull(json, "JSON cannot be null"); 56 checkNotNull(json, "JSON cannot be null");
57 57
58 - final DecodeConstraintCodec decodeCodec = 58 + final DecodeConstraintCodecHelper decodeCodec =
59 - new DecodeConstraintCodec(json); 59 + new DecodeConstraintCodecHelper(json);
60 60
61 return decodeCodec.decode(); 61 return decodeCodec.decode();
62 } 62 }
......
...@@ -63,13 +63,13 @@ public final class CriterionCodec extends JsonCodec<Criterion> { ...@@ -63,13 +63,13 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
63 63
64 @Override 64 @Override
65 public ObjectNode encode(Criterion criterion, CodecContext context) { 65 public ObjectNode encode(Criterion criterion, CodecContext context) {
66 - EncodeCriterionCodec encoder = new EncodeCriterionCodec(criterion, context); 66 + EncodeCriterionCodecHelper encoder = new EncodeCriterionCodecHelper(criterion, context);
67 return encoder.encode(); 67 return encoder.encode();
68 } 68 }
69 69
70 @Override 70 @Override
71 public Criterion decode(ObjectNode json, CodecContext context) { 71 public Criterion decode(ObjectNode json, CodecContext context) {
72 - DecodeCriterionCodec decoder = new DecodeCriterionCodec(json); 72 + DecodeCriterionCodecHelper decoder = new DecodeCriterionCodecHelper(json);
73 return decoder.decode(); 73 return decoder.decode();
74 } 74 }
75 75
......
...@@ -43,7 +43,7 @@ import static org.onlab.util.Tools.nullIsIllegal; ...@@ -43,7 +43,7 @@ import static org.onlab.util.Tools.nullIsIllegal;
43 /** 43 /**
44 * Constraint JSON decoder. 44 * Constraint JSON decoder.
45 */ 45 */
46 -public final class DecodeConstraintCodec { 46 +public final class DecodeConstraintCodecHelper {
47 private final ObjectNode json; 47 private final ObjectNode json;
48 48
49 /** 49 /**
...@@ -51,7 +51,7 @@ public final class DecodeConstraintCodec { ...@@ -51,7 +51,7 @@ public final class DecodeConstraintCodec {
51 * 51 *
52 * @param json object node to decode 52 * @param json object node to decode
53 */ 53 */
54 - public DecodeConstraintCodec(ObjectNode json) { 54 + public DecodeConstraintCodecHelper(ObjectNode json) {
55 this.json = json; 55 this.json = json;
56 } 56 }
57 57
......
...@@ -38,7 +38,7 @@ import static org.onlab.util.Tools.nullIsIllegal; ...@@ -38,7 +38,7 @@ import static org.onlab.util.Tools.nullIsIllegal;
38 /** 38 /**
39 * Decode portion of the criterion codec. 39 * Decode portion of the criterion codec.
40 */ 40 */
41 -public final class DecodeCriterionCodec { 41 +public final class DecodeCriterionCodecHelper {
42 42
43 private final ObjectNode json; 43 private final ObjectNode json;
44 44
...@@ -56,7 +56,7 @@ public final class DecodeCriterionCodec { ...@@ -56,7 +56,7 @@ public final class DecodeCriterionCodec {
56 * 56 *
57 * @param json JSON object to decode 57 * @param json JSON object to decode
58 */ 58 */
59 - public DecodeCriterionCodec(ObjectNode json) { 59 + public DecodeCriterionCodecHelper(ObjectNode json) {
60 this.json = json; 60 this.json = json;
61 decoderMap = new HashMap<>(); 61 decoderMap = new HashMap<>();
62 62
......
...@@ -37,7 +37,7 @@ import static org.onlab.util.Tools.nullIsIllegal; ...@@ -37,7 +37,7 @@ import static org.onlab.util.Tools.nullIsIllegal;
37 /** 37 /**
38 * Decoding portion of the instruction codec. 38 * Decoding portion of the instruction codec.
39 */ 39 */
40 -public final class DecodeInstructionCodec { 40 +public final class DecodeInstructionCodecHelper {
41 private final ObjectNode json; 41 private final ObjectNode json;
42 42
43 /** 43 /**
...@@ -45,7 +45,7 @@ public final class DecodeInstructionCodec { ...@@ -45,7 +45,7 @@ public final class DecodeInstructionCodec {
45 * 45 *
46 * @param json JSON object to decode 46 * @param json JSON object to decode
47 */ 47 */
48 - public DecodeInstructionCodec(ObjectNode json) { 48 + public DecodeInstructionCodecHelper(ObjectNode json) {
49 this.json = json; 49 this.json = json;
50 } 50 }
51 51
......
...@@ -35,7 +35,7 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -35,7 +35,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
35 /** 35 /**
36 * Implementation of encoder for constraint JSON codec. 36 * Implementation of encoder for constraint JSON codec.
37 */ 37 */
38 -public final class EncodeConstraintCodec { 38 +public final class EncodeConstraintCodecHelper {
39 39
40 private final Constraint constraint; 40 private final Constraint constraint;
41 private final CodecContext context; 41 private final CodecContext context;
...@@ -46,7 +46,7 @@ public final class EncodeConstraintCodec { ...@@ -46,7 +46,7 @@ public final class EncodeConstraintCodec {
46 * @param constraint constraint to encode 46 * @param constraint constraint to encode
47 * @param context to use for look ups 47 * @param context to use for look ups
48 */ 48 */
49 - public EncodeConstraintCodec(Constraint constraint, CodecContext context) { 49 + public EncodeConstraintCodecHelper(Constraint constraint, CodecContext context) {
50 this.constraint = constraint; 50 this.constraint = constraint;
51 this.context = context; 51 this.context = context;
52 } 52 }
......
...@@ -52,7 +52,7 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -52,7 +52,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
52 /** 52 /**
53 * Encode portion of the criterion codec. 53 * Encode portion of the criterion codec.
54 */ 54 */
55 -public final class EncodeCriterionCodec { 55 +public final class EncodeCriterionCodecHelper {
56 56
57 private final Criterion criterion; 57 private final Criterion criterion;
58 private final CodecContext context; 58 private final CodecContext context;
...@@ -66,7 +66,7 @@ public final class EncodeCriterionCodec { ...@@ -66,7 +66,7 @@ public final class EncodeCriterionCodec {
66 * @param criterion Criterion to encode 66 * @param criterion Criterion to encode
67 * @param context context of the JSON encoding 67 * @param context context of the JSON encoding
68 */ 68 */
69 - public EncodeCriterionCodec(Criterion criterion, CodecContext context) { 69 + public EncodeCriterionCodecHelper(Criterion criterion, CodecContext context) {
70 this.criterion = criterion; 70 this.criterion = criterion;
71 this.context = context; 71 this.context = context;
72 72
......
...@@ -30,8 +30,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode; ...@@ -30,8 +30,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
30 /** 30 /**
31 * JSON encoding of Instructions. 31 * JSON encoding of Instructions.
32 */ 32 */
33 -public final class EncodeInstructionCodec { 33 +public final class EncodeInstructionCodecHelper {
34 - protected static final Logger log = LoggerFactory.getLogger(EncodeInstructionCodec.class); 34 + protected static final Logger log = LoggerFactory.getLogger(EncodeInstructionCodecHelper.class);
35 private final Instruction instruction; 35 private final Instruction instruction;
36 private final CodecContext context; 36 private final CodecContext context;
37 37
...@@ -41,7 +41,7 @@ public final class EncodeInstructionCodec { ...@@ -41,7 +41,7 @@ public final class EncodeInstructionCodec {
41 * @param instruction instruction to encode 41 * @param instruction instruction to encode
42 * @param context codec context for the encoding 42 * @param context codec context for the encoding
43 */ 43 */
44 - public EncodeInstructionCodec(Instruction instruction, CodecContext context) { 44 + public EncodeInstructionCodecHelper(Instruction instruction, CodecContext context) {
45 this.instruction = instruction; 45 this.instruction = instruction;
46 this.context = context; 46 this.context = context;
47 } 47 }
......
...@@ -56,7 +56,7 @@ public final class InstructionCodec extends JsonCodec<Instruction> { ...@@ -56,7 +56,7 @@ public final class InstructionCodec extends JsonCodec<Instruction> {
56 public ObjectNode encode(Instruction instruction, CodecContext context) { 56 public ObjectNode encode(Instruction instruction, CodecContext context) {
57 checkNotNull(instruction, "Instruction cannot be null"); 57 checkNotNull(instruction, "Instruction cannot be null");
58 58
59 - return new EncodeInstructionCodec(instruction, context).encode(); 59 + return new EncodeInstructionCodecHelper(instruction, context).encode();
60 } 60 }
61 61
62 @Override 62 @Override
...@@ -65,6 +65,6 @@ public final class InstructionCodec extends JsonCodec<Instruction> { ...@@ -65,6 +65,6 @@ public final class InstructionCodec extends JsonCodec<Instruction> {
65 return null; 65 return null;
66 } 66 }
67 67
68 - return new DecodeInstructionCodec(json).decode(); 68 + return new DecodeInstructionCodecHelper(json).decode();
69 } 69 }
70 } 70 }
......
...@@ -72,7 +72,7 @@ public class CriterionCodecTest { ...@@ -72,7 +72,7 @@ public class CriterionCodecTest {
72 */ 72 */
73 @Test 73 @Test
74 public void checkCriterionTypes() throws Exception { 74 public void checkCriterionTypes() throws Exception {
75 - EncodeCriterionCodec encoder = new EncodeCriterionCodec( 75 + EncodeCriterionCodecHelper encoder = new EncodeCriterionCodecHelper(
76 Criteria.dummy(), context); 76 Criteria.dummy(), context);
77 EnumMap<Criterion.Type, Object> formatMap = 77 EnumMap<Criterion.Type, Object> formatMap =
78 getField(encoder, "formatMap"); 78 getField(encoder, "formatMap");
......
...@@ -37,9 +37,11 @@ public class ImmutableCodecsTest { ...@@ -37,9 +37,11 @@ public class ImmutableCodecsTest {
37 assertThatClassIsImmutable(ConnectivityIntentCodec.class); 37 assertThatClassIsImmutable(ConnectivityIntentCodec.class);
38 assertThatClassIsImmutable(ConnectPointCodec.class); 38 assertThatClassIsImmutable(ConnectPointCodec.class);
39 assertThatClassIsImmutable(ConstraintCodec.class); 39 assertThatClassIsImmutable(ConstraintCodec.class);
40 + assertThatClassIsImmutable(EncodeConstraintCodecHelper.class);
41 + assertThatClassIsImmutable(DecodeConstraintCodecHelper.class);
40 assertThatClassIsImmutable(CriterionCodec.class); 42 assertThatClassIsImmutable(CriterionCodec.class);
41 - assertThatClassIsImmutable(EncodeCriterionCodec.class); 43 + assertThatClassIsImmutable(EncodeCriterionCodecHelper.class);
42 - assertThatClassIsImmutable(DecodeCriterionCodec.class); 44 + assertThatClassIsImmutable(DecodeCriterionCodecHelper.class);
43 assertThatClassIsImmutable(DeviceCodec.class); 45 assertThatClassIsImmutable(DeviceCodec.class);
44 assertThatClassIsImmutable(EthernetCodec.class); 46 assertThatClassIsImmutable(EthernetCodec.class);
45 assertThatClassIsImmutable(FlowEntryCodec.class); 47 assertThatClassIsImmutable(FlowEntryCodec.class);
...@@ -47,8 +49,8 @@ public class ImmutableCodecsTest { ...@@ -47,8 +49,8 @@ public class ImmutableCodecsTest {
47 assertThatClassIsImmutable(HostLocationCodec.class); 49 assertThatClassIsImmutable(HostLocationCodec.class);
48 assertThatClassIsImmutable(HostToHostIntentCodec.class); 50 assertThatClassIsImmutable(HostToHostIntentCodec.class);
49 assertThatClassIsImmutable(InstructionCodec.class); 51 assertThatClassIsImmutable(InstructionCodec.class);
50 - assertThatClassIsImmutable(EncodeInstructionCodec.class); 52 + assertThatClassIsImmutable(EncodeInstructionCodecHelper.class);
51 - assertThatClassIsImmutable(DecodeInstructionCodec.class); 53 + assertThatClassIsImmutable(DecodeInstructionCodecHelper.class);
52 assertThatClassIsImmutable(IntentCodec.class); 54 assertThatClassIsImmutable(IntentCodec.class);
53 assertThatClassIsImmutable(LinkCodec.class); 55 assertThatClassIsImmutable(LinkCodec.class);
54 assertThatClassIsImmutable(PathCodec.class); 56 assertThatClassIsImmutable(PathCodec.class);
......