use of org.onosproject.net.intent.constraint.MeteredConstraint in project onos by opennetworkinglab.
the class EncodeConstraintCodecHelper method encodeMeteredConstraint.
private ObjectNode encodeMeteredConstraint() {
checkNotNull(constraint, "Metered constraint cannot be null");
final MeteredConstraint meteredConstraint = (MeteredConstraint) constraint;
return context.mapper().createObjectNode().put("metered", meteredConstraint.isUseMetered());
}
use of org.onosproject.net.intent.constraint.MeteredConstraint in project onos by opennetworkinglab.
the class ConstraintCodecTest method meteredConstraint.
/**
* Tests metered constraint.
*/
@Test
public void meteredConstraint() {
Constraint constraint = getConstraint("MeteredConstraint.json");
assertThat(constraint, instanceOf(MeteredConstraint.class));
MeteredConstraint meteredConstraint = (MeteredConstraint) constraint;
assertThat(meteredConstraint.isUseMetered(), is(true));
}
use of org.onosproject.net.intent.constraint.MeteredConstraint in project onos by opennetworkinglab.
the class EncodeConstraintCodecHelper method encode.
/**
* Encodes the constraint in JSON.
*
* @return JSON node
*/
public ObjectNode encode() {
final ObjectNode result;
if (constraint instanceof BandwidthConstraint) {
result = encodeBandwidthConstraint();
} else if (constraint instanceof LinkTypeConstraint) {
result = encodeLinkTypeConstraint();
} else if (constraint instanceof AnnotationConstraint) {
result = encodeAnnotationConstraint();
} else if (constraint instanceof LatencyConstraint) {
result = encodeLatencyConstraint();
} else if (constraint instanceof ObstacleConstraint) {
result = encodeObstacleConstraint();
} else if (constraint instanceof WaypointConstraint) {
result = encodeWaypointConstraint();
} else if (constraint instanceof MeteredConstraint) {
result = encodeMeteredConstraint();
} else if (constraint instanceof TierConstraint) {
result = encodeTierConstraint();
} else {
result = context.mapper().createObjectNode();
}
result.put(ConstraintCodec.TYPE, constraint.getClass().getSimpleName());
return result;
}
Aggregations