blob: 527a0701162ff9c4ca48a1e404ac75f58c9d2590 [file] [log] [blame]
Satish Kf6d87cb2015-11-30 19:59:22 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Satish Kf6d87cb2015-11-30 19:59:22 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.iptopology.api.device;
17
18import com.google.common.base.MoreObjects;
19import org.onosproject.iptopology.api.PrefixIdentifier;
20import org.onosproject.iptopology.api.PrefixTed;
21import org.onosproject.net.AbstractDescription;
22import org.onosproject.net.SparseAnnotations;
23
24/**
25 * Default implementation of immutable Prefix description.
26 */
27public class DefaultPrefixDescription extends AbstractDescription
28 implements PrefixDescription {
29
30 private final PrefixIdentifier prefixIdentifier;
31 private final PrefixTed prefixTed;
32
33
34 /**
35 * Creates prefix description using the supplied information.
36 *
37 * @param prefixIdentifier prefix identifier
38 * @param prefixTed prefix traffic engineering parameters
39 * @param annotations optional key/value annotations map
40 */
41 public DefaultPrefixDescription(PrefixIdentifier prefixIdentifier, PrefixTed prefixTed,
42 SparseAnnotations...annotations) {
43 super(annotations);
44 this.prefixIdentifier = prefixIdentifier;
45 this.prefixTed = prefixTed;
46 }
47
48 /**
49 * Default constructor for serialization.
50 */
51 private DefaultPrefixDescription() {
52 this.prefixIdentifier = null;
53 this.prefixTed = null;
54 }
55
56 /**
57 * Creates prefix description using the supplied information.
58 *
59 * @param base PrefixDescription to get basic information from
60 * @param annotations optional key/value annotations map
61 */
62 public DefaultPrefixDescription(PrefixDescription base,
63 SparseAnnotations annotations) {
64 this(base.prefixIdentifier(), base.prefixTed(), annotations);
65 }
66
67 @Override
68 public PrefixIdentifier prefixIdentifier() {
69 return prefixIdentifier;
70 }
71
72 @Override
73 public PrefixTed prefixTed() {
74 return prefixTed;
75 }
76
77 @Override
78 public String toString() {
79 return MoreObjects.toStringHelper(getClass())
80 .add("prefixIdentifier", prefixIdentifier)
81 .add("prefixTed", prefixTed)
82 .add("annotations", annotations())
83 .toString();
84 }
85
86}