Revert "BUG-47 : unfinished PCEP migration to generated DTOs."
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / concepts / LSPIdentifier.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.pcep.concepts;
9
10 import org.opendaylight.protocol.concepts.AbstractIdentifier;
11 import org.opendaylight.protocol.util.ByteArray;
12 import com.google.common.base.Objects.ToStringHelper;
13
14 /**
15  * A 16-bit identifier used in the SENDER_TEMPLATE and the FILTER_SPEC that can
16  * be changed to allow a sender to share resources with itself.
17  */
18 public final class LSPIdentifier extends AbstractIdentifier<LSPIdentifier> {
19
20         private static final long serialVersionUID = 1337756730239265010L;
21
22         private final byte[] lspId;
23
24         /**
25          * Creates LSPIdentifier using byte array as value.
26          *
27          * @param lspId
28          *            value of the LSPIdentifier TLV. Must be exactly 2 bytes long.
29          */
30         public LSPIdentifier(final byte[] lspId) {
31                 if (lspId.length != 2)
32                         throw new IllegalArgumentException("Invalid LSP identifier");
33                 this.lspId = lspId;
34         }
35
36         /**
37          * Gets LSP Id in raw byte array representation.
38          *
39          * @return byte array representation of LSP ID. May be null.
40          */
41         public byte[] getLspId() {
42                 return this.lspId;
43         }
44
45         @Override
46         protected byte[] getBytes() {
47                 return this.lspId;
48         }
49
50         @Override
51         protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
52                 return toStringHelper.add("lspId", ByteArray.toHexString(lspId, "."));
53         }
54
55 }