Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Open Networking Laboratory |
| 3 | * |
| 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 | */ |
| 16 | package org.onosproject.iptopology.api.device; |
| 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | import org.onosproject.iptopology.api.PrefixIdentifier; |
| 20 | import org.onosproject.iptopology.api.PrefixTed; |
| 21 | import org.onosproject.net.AbstractDescription; |
| 22 | import org.onosproject.net.SparseAnnotations; |
| 23 | |
| 24 | /** |
| 25 | * Default implementation of immutable Prefix description. |
| 26 | */ |
| 27 | public 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 | } |