@Override
    public ObjectNode encode(FilteringObjective filteringObjective, CodecContext context) {

        checkNotNull(filteringObjective, NOT_NULL_MESSAGE);

        final JsonCodec<Criterion> criterionCodec = context.codec(Criterion.class);
        final JsonCodec<TrafficTreatment> trafficTreatmentCodec = context.codec(TrafficTreatment.class);

        // encode common properties
        ObjectiveCodecHelper och = new ObjectiveCodecHelper();
        ObjectNode result = och.encode(filteringObjective, context);

        // encode id
        result.put(ID, filteringObjective.id());

        // encode type
        result.put(TYPE, filteringObjective.type().toString());

        // encode key
        if (filteringObjective.key() != null) {
            ObjectNode criterionNode = criterionCodec.encode(filteringObjective.key(), context);
            result.set(KEY, criterionNode);
        }

        // encode meta
        if (filteringObjective.meta() != null) {
            ObjectNode trafficTreatmentNode = trafficTreatmentCodec.encode(filteringObjective.meta(), context);
            result.set(META, trafficTreatmentNode);
        }

        // encode conditions
        ArrayNode conditions = context.mapper().createArrayNode();
        filteringObjective.conditions().forEach(c -> {
            ObjectNode criterionJson = criterionCodec.encode(c, context);
            conditions.add(criterionJson);
        });
        result.set(CONDITIONS, conditions);

        return result;
    }
@Test
    public void testFilteringObjectiveEncode() {

        Criterion condition1 = Criteria.matchVlanId(VlanId.ANY);
        Criterion condition2 = Criteria.matchEthType((short) 0x8844);

        FilteringObjective filteringObj = DefaultFilteringObjective.builder()
                .makePermanent()
                .permit()
                .fromApp(APP_ID)
                .withPriority(60)
                .addCondition(condition1)
                .addCondition(condition2)
                .add();

        // TODO: need to add test case for TrafficTreatment (META in filteringObj)

        ObjectNode filteringObjJson = filteringObjectiveCodec.encode(filteringObj, context);
        assertThat(filteringObjJson, matchesFilteringObjective(filteringObj));
    }