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