org.opendaylight.capwap.msgelements.ResultCode.java Source code

Java tutorial

Introduction

Here is the source code for org.opendaylight.capwap.msgelements.ResultCode.java

Source

/*
 * Copyright (c) 2015 Mahesh Govind and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

package org.opendaylight.capwap.msgelements;

import io.netty.buffer.ByteBuf;
import org.opendaylight.capwap.ODLCapwapConsts;
import org.opendaylight.capwap.ODLCapwapMessageElement;
import org.opendaylight.capwap.utils.ByteManager;

/**
 * Created by flat on 17/04/16.
 */
public class ResultCode implements ODLCapwapMessageElement {

    int msgElem = 0;

    long resultCode = 0;

    public ResultCode() {
        this.msgElem = ODLCapwapConsts.CAPWAP_ELMT_TYPE_RESULT_CODE;
    }

    public int getMsgElem() {
        return msgElem;
    }

    public void setMsgElem(int msgElem) {
        this.msgElem = msgElem;
    }

    public long getResultCode() {
        return resultCode;
    }

    public void setResultCode(long resultCode) {
        this.resultCode = resultCode;
    }

    @Override
    public int encode(ByteBuf buf) {
        int start = buf.writerIndex();
        buf.writeBytes(ByteManager.unsignedIntToArray(this.resultCode));
        return buf.writerIndex() - start;
    }

    @Override
    public ODLCapwapMessageElement decode(ByteBuf buf) {
        return null;
    }

    @Override
    public int getType() {
        return this.msgElem;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof ResultCode))
            return false;
        if ((msgElem == ((ResultCode) o).getMsgElem()) && (resultCode == ((ResultCode) o).getResultCode()))
            return true;
        return false;
    }
}