Thomas Vachuska | f6ec97b | 2016-02-22 10:59:23 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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.net.intent; |
| 18 | |
| 19 | import com.google.common.base.MoreObjects; |
| 20 | import org.onosproject.core.ApplicationId; |
| 21 | import org.onosproject.net.NetworkResource; |
| 22 | import org.onosproject.net.flowobjective.Objective; |
| 23 | |
| 24 | import java.util.Collection; |
| 25 | |
| 26 | /** |
| 27 | * Intent expressed as (and backed by) a collection of flow objectives through |
| 28 | * which the intent is to be accomplished. |
| 29 | */ |
| 30 | public class FlowObjectiveIntent extends Intent { |
| 31 | |
| 32 | private final Collection<Objective> objectives; |
| 33 | |
| 34 | /** |
| 35 | * Constructor for serialization. |
| 36 | */ |
| 37 | protected FlowObjectiveIntent() { |
| 38 | super(); |
| 39 | this.objectives = null; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Creates a flow objective intent with the specified objectives and |
| 44 | * resources. |
| 45 | * |
| 46 | * @param appId application id |
| 47 | * @param objectives backing flow objectives |
| 48 | * @param resources backing network resources |
| 49 | */ |
| 50 | public FlowObjectiveIntent(ApplicationId appId, |
| 51 | Collection<Objective> objectives, |
| 52 | Collection<NetworkResource> resources) { |
| 53 | this(appId, null, objectives, resources); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Creates a flow objective intent with the specified objectives and |
| 58 | * resources. |
| 59 | * |
| 60 | * @param appId application id |
| 61 | * @param key intent key |
| 62 | * @param objectives backing flow objectives |
| 63 | * @param resources backing network resources |
| 64 | */ |
| 65 | public FlowObjectiveIntent(ApplicationId appId, Key key, |
| 66 | Collection<Objective> objectives, |
| 67 | Collection<NetworkResource> resources) { |
| 68 | super(appId, key, resources, DEFAULT_INTENT_PRIORITY); |
| 69 | this.objectives = objectives; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Returns the collection of backing flow objectives. |
| 74 | * |
| 75 | * @return flow objectives |
| 76 | */ |
| 77 | Collection<Objective> objectives() { |
| 78 | return objectives; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | @Override |
| 83 | public boolean isInstallable() { |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public String toString() { |
| 89 | return MoreObjects.toStringHelper(this) |
| 90 | .add("id", id()) |
| 91 | .add("key", key()) |
| 92 | .add("appId", appId()) |
| 93 | .add("resources", resources()) |
| 94 | .add("objectives", objectives) |
| 95 | .toString(); |
| 96 | } |
| 97 | } |