Sho SHIMIZU | 91210a7 | 2015-04-29 12:54:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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.net; |
| 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | |
| 20 | /** |
| 21 | * Implementation of Lambda simply designated by an index number of wavelength. |
| 22 | */ |
| 23 | public class IndexedLambda implements Lambda { |
| 24 | |
| 25 | private final long lambda; |
| 26 | |
| 27 | /** |
| 28 | * Creates an instance representing the wavelength specified by the given index number. |
| 29 | * |
| 30 | * @param lambda index number of wavelength |
| 31 | */ |
| 32 | IndexedLambda(long lambda) { |
| 33 | this.lambda = lambda; |
| 34 | } |
| 35 | |
| 36 | @Override |
| 37 | public int hashCode() { |
| 38 | return (int) (lambda ^ (lambda >>> 32)); |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public boolean equals(Object obj) { |
| 43 | if (this == obj) { |
| 44 | return true; |
| 45 | } |
| 46 | if (!(obj instanceof IndexedLambda)) { |
| 47 | return false; |
| 48 | } |
| 49 | |
| 50 | final IndexedLambda that = (IndexedLambda) obj; |
| 51 | return this.lambda == that.lambda; |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public String toString() { |
| 56 | return MoreObjects.toStringHelper(this) |
| 57 | .add("lambda", lambda) |
| 58 | .toString(); |
| 59 | } |
| 60 | } |