2 * Copyright (c) 2013 Cisco Systems, 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
8 package org.opendaylight.protocol.pcep.concepts;
10 import org.opendaylight.protocol.concepts.AbstractIdentifier;
11 import org.opendaylight.protocol.util.ByteArray;
12 import com.google.common.base.Objects.ToStringHelper;
15 * A 16-bit identifier used in the SESSION that remains constant over the life
18 public final class TunnelIdentifier extends AbstractIdentifier<TunnelIdentifier> {
20 private static final long serialVersionUID = 137237703900885441L;
22 private final byte[] tunnelId;
25 * Creates TunnelIdentifier using byte array as value.
28 * value of the TunnelIdentifier TLV. Must be exactly 2 bytes
31 public TunnelIdentifier(final byte[] tunnelId) {
32 if (tunnelId.length != 2)
33 throw new IllegalArgumentException("Invalid tunnel ID.");
34 this.tunnelId = tunnelId;
38 public byte[] getBytes() {
43 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
44 return toStringHelper.add("tunnelId", ByteArray.toHexString(tunnelId, "."));