tony-liu | aff59a7 | 2016-10-21 15:41:46 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016-present 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 | |
| 17 | package org.onosproject.tetunnel.api.tunnel.path; |
| 18 | |
| 19 | import com.google.common.collect.ImmutableList; |
| 20 | import com.google.common.collect.Lists; |
| 21 | import org.onosproject.tetunnel.api.lsp.TeLspKey; |
| 22 | |
| 23 | import java.util.List; |
| 24 | |
| 25 | /** |
| 26 | * Default implementation of TE path. |
| 27 | */ |
| 28 | public class DefaultTePath implements TePath { |
| 29 | |
| 30 | private final Type type; |
| 31 | private final List<TeLspKey> lsps; |
| 32 | private final List<TeRouteSubobject> explicitRoute; |
| 33 | private final List<TePath> secondaryPaths; |
| 34 | |
| 35 | /** |
| 36 | * Creates a default implementation of TE path with supplied information. |
| 37 | * |
| 38 | * @param type type of TE Path |
| 39 | * @param lsps LSPs of the TE Path |
| 40 | * @param explicitRoute explicit route of the (Explicit) TE path |
| 41 | * @param secondaryPaths secondary paths of the TE path |
| 42 | */ |
| 43 | public DefaultTePath(Type type, List<TeLspKey> lsps, |
| 44 | List<TeRouteSubobject> explicitRoute, |
| 45 | List<TePath> secondaryPaths) { |
| 46 | this.type = type; |
| 47 | if (lsps == null) { |
| 48 | this.lsps = Lists.newArrayList(); |
| 49 | } else { |
| 50 | this.lsps = Lists.newArrayList(lsps); |
| 51 | } |
| 52 | if (explicitRoute == null) { |
| 53 | this.explicitRoute = Lists.newArrayList(); |
| 54 | } else { |
| 55 | this.explicitRoute = Lists.newArrayList(explicitRoute); |
| 56 | } |
| 57 | if (secondaryPaths == null) { |
| 58 | this.secondaryPaths = Lists.newArrayList(); |
| 59 | } else { |
| 60 | this.secondaryPaths = Lists.newArrayList(secondaryPaths); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public Type type() { |
| 66 | return type; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public List<TeLspKey> lsps() { |
| 71 | return ImmutableList.copyOf(lsps); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public List<TeRouteSubobject> explicitRoute() { |
| 76 | return ImmutableList.copyOf(explicitRoute); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public List<TePath> secondaryPaths() { |
| 81 | return ImmutableList.copyOf(secondaryPaths); |
| 82 | } |
| 83 | } |