Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [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 | */ |
Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame^] | 16 | package org.onosproject.net.resource.link; |
Toshio Koide | 485b478 | 2014-10-20 19:34:21 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | fe0f4b1 | 2014-10-30 21:19:02 -0700 | [diff] [blame] | 18 | import com.google.common.base.MoreObjects; |
Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame^] | 19 | import org.onosproject.net.resource.ResourceAllocation; |
| 20 | import org.onosproject.net.resource.ResourceType; |
Brian O'Connor | fe0f4b1 | 2014-10-30 21:19:02 -0700 | [diff] [blame] | 21 | |
Brian O'Connor | 41718fc | 2014-10-30 16:57:21 -0700 | [diff] [blame] | 22 | import java.util.Objects; |
| 23 | |
Toshio Koide | 485b478 | 2014-10-20 19:34:21 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Representation of allocated lambda resource. |
| 26 | */ |
Toshio Koide | d707d7a | 2014-10-23 12:37:51 -0700 | [diff] [blame] | 27 | public class LambdaResourceAllocation extends LambdaResourceRequest |
| 28 | implements ResourceAllocation { |
Sho SHIMIZU | 94b7ff4 | 2015-05-06 17:51:49 -0700 | [diff] [blame] | 29 | private final LambdaResource lambda; |
Toshio Koide | fa0dff6 | 2014-10-23 11:46:44 -0700 | [diff] [blame] | 30 | |
Toshio Koide | d1865a4 | 2014-10-23 12:44:55 -0700 | [diff] [blame] | 31 | @Override |
| 32 | public ResourceType type() { |
| 33 | return ResourceType.LAMBDA; |
| 34 | } |
| 35 | |
Toshio Koide | fa0dff6 | 2014-10-23 11:46:44 -0700 | [diff] [blame] | 36 | /** |
Sho SHIMIZU | 94b7ff4 | 2015-05-06 17:51:49 -0700 | [diff] [blame] | 37 | * Creates a new {@link LambdaResourceAllocation} with {@link LambdaResource} |
Toshio Koide | fa0dff6 | 2014-10-23 11:46:44 -0700 | [diff] [blame] | 38 | * object. |
| 39 | * |
| 40 | * @param lambda allocated lambda |
| 41 | */ |
Sho SHIMIZU | 94b7ff4 | 2015-05-06 17:51:49 -0700 | [diff] [blame] | 42 | public LambdaResourceAllocation(LambdaResource lambda) { |
Toshio Koide | fa0dff6 | 2014-10-23 11:46:44 -0700 | [diff] [blame] | 43 | this.lambda = lambda; |
| 44 | } |
| 45 | |
Toshio Koide | 485b478 | 2014-10-20 19:34:21 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Returns the lambda resource. |
| 48 | * |
| 49 | * @return the lambda resource |
| 50 | */ |
Sho SHIMIZU | 94b7ff4 | 2015-05-06 17:51:49 -0700 | [diff] [blame] | 51 | public LambdaResource lambda() { |
Toshio Koide | fa0dff6 | 2014-10-23 11:46:44 -0700 | [diff] [blame] | 52 | return lambda; |
| 53 | } |
Brian O'Connor | 41718fc | 2014-10-30 16:57:21 -0700 | [diff] [blame] | 54 | |
| 55 | @Override |
| 56 | public int hashCode() { |
| 57 | return Objects.hash(lambda); |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public boolean equals(Object obj) { |
| 62 | if (this == obj) { |
| 63 | return true; |
| 64 | } |
| 65 | if (obj == null || getClass() != obj.getClass()) { |
| 66 | return false; |
| 67 | } |
| 68 | final LambdaResourceAllocation other = (LambdaResourceAllocation) obj; |
| 69 | return Objects.equals(this.lambda, other.lambda); |
| 70 | } |
Brian O'Connor | fe0f4b1 | 2014-10-30 21:19:02 -0700 | [diff] [blame] | 71 | |
| 72 | @Override |
| 73 | public String toString() { |
| 74 | return MoreObjects.toStringHelper(this) |
| 75 | .add("lambda", lambda) |
| 76 | .toString(); |
| 77 | } |
Toshio Koide | 485b478 | 2014-10-20 19:34:21 -0700 | [diff] [blame] | 78 | } |