Ray Milkey

Refeactor codec helper classes

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