<commit_before>/*
 * Copyright 2017-present Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onosproject.mapping.web.codec;

import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.mapping.instructions.MappingInstruction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Mapping instruction codec.
 */
public final class MappingInstructionCodec extends JsonCodec<MappingInstruction> {

    protected static final Logger log = LoggerFactory.getLogger(MappingInstruction.class);

    protected static final String TYPE = "type";
    protected static final String SUBTYPE = "subtype";
    protected static final String UNICAST_WEIGHT = "unicastWeight";
    protected static final String UNICAST_PRIORITY = "unicastPriority";
    protected static final String MULTICAST_WEIGHT = "multicastWeight";
    protected static final String MULTICAST_PRIORITY = "multicastPriority";

    protected static final String MISSING_MEMBER_MESSAGE =
                                        " member is required in Instruction";
    protected static final String ERROR_MESSAGE =
                                        " not specified in Instruction";

    @Override
    public ObjectNode encode(MappingInstruction instruction, CodecContext context) {
        checkNotNull(instruction, "Mapping instruction cannot be null");

        return new EncodeMappingInstructionCodecHelper(instruction, context).encode();
    }
}<commit_msg>Fix: Add missing decode method for MappingInstructionCodec<commit_after>/*
 * Copyright 2017-present Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onosproject.mapping.web.codec;

import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.mapping.instructions.MappingInstruction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Mapping instruction codec.
 */
public final class MappingInstructionCodec extends JsonCodec<MappingInstruction> {

    protected static final Logger log = LoggerFactory.getLogger(MappingInstruction.class);

    protected static final String TYPE = "type";
    protected static final String SUBTYPE = "subtype";
    protected static final String UNICAST_WEIGHT = "unicastWeight";
    protected static final String UNICAST_PRIORITY = "unicastPriority";
    protected static final String MULTICAST_WEIGHT = "multicastWeight";
    protected static final String MULTICAST_PRIORITY = "multicastPriority";

    protected static final String MISSING_MEMBER_MESSAGE =
                                        " member is required in Instruction";
    protected static final String ERROR_MESSAGE =
                                        " not specified in Instruction";

    @Override
    public ObjectNode encode(MappingInstruction instruction, CodecContext context) {
        checkNotNull(instruction, "Mapping instruction cannot be null");

        return new EncodeMappingInstructionCodecHelper(instruction, context).encode();
    }

    @Override
    public MappingInstruction decode(ObjectNode json, CodecContext context) {
        if (json == null || !json.isObject()) {
            return null;
        }

        return new DecodeMappingInstructionCodecHelper(json, context).decode();
    }
}
{'fraction_non_alphanumeric': 0.0705295138888889, 'fraction_numerical': 0.004340277777777778, 'mean_word_length': 3.791060291060291, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7397244', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1127, 'n_words': 401}