2 * Copyright (c) 2015 Cable Television Laboratories, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.pcmm.gates.impl;
11 import org.pcmm.base.impl.PCMMBaseObject;
12 import org.pcmm.gates.IGateID;
13 import org.umu.cops.stack.COPSMsgParser;
16 * Implementation of the IGateID interface
18 public class GateID extends PCMMBaseObject implements IGateID {
27 * @param gateId - the ID value
29 public GateID(final int gateId) {
30 super(SNum.GATE_ID, STYPE);
35 public int getGateID() {
40 protected byte[] getBytes() {
41 return COPSMsgParser.intToBytes(gateId);
45 public boolean equals(final Object o) {
49 if (!(o instanceof GateID)) {
52 if (!super.equals(o)) {
55 final GateID gateID = (GateID) o;
56 return gateId == gateID.gateId;
60 public int hashCode() {
61 int result = super.hashCode();
62 result = 31 * result + gateId;
67 * Returns a GateID object from a byte array
68 * @param data - the data to parse
69 * @return - the object
70 * TODO - make me more robust as RuntimeExceptions can be thrown here.
72 public static GateID parse(final byte[] data) {
73 return new GateID(COPSMsgParser.bytesToInt(data[0], data[1], data[2], data[3]));