Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -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 | */ |
Madan Jampani | cadd70b | 2016-02-08 13:45:43 -0800 | [diff] [blame] | 16 | package org.onosproject.store.primitives; |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 17 | |
| 18 | import com.google.common.base.Objects; |
| 19 | |
| 20 | /** |
| 21 | * Transaction identifier. |
| 22 | */ |
| 23 | public final class TransactionId { |
| 24 | |
| 25 | public static TransactionId from(String id) { |
| 26 | return new TransactionId(id); |
| 27 | } |
| 28 | |
| 29 | private final String id; |
| 30 | |
| 31 | private TransactionId(String id) { |
| 32 | this.id = id; |
| 33 | } |
| 34 | |
| 35 | @Override |
| 36 | public String toString() { |
| 37 | return id; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public int hashCode() { |
| 42 | return id.hashCode(); |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public boolean equals(Object other) { |
| 47 | if (this == other) { |
| 48 | return true; |
| 49 | } |
| 50 | if (other instanceof TransactionId) { |
| 51 | TransactionId that = (TransactionId) other; |
| 52 | return Objects.equal(this.id, that.id); |
| 53 | } |
| 54 | return false; |
| 55 | } |
| 56 | } |