Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.store; |
Yuta HIGUCHI | 497c884 | 2014-09-25 14:23:34 -0700 | [diff] [blame] | 17 | |
Jonathan Hart | 403ea93 | 2015-02-20 16:23:00 -0800 | [diff] [blame] | 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| 19 | |
Yuta HIGUCHI | 497c884 | 2014-09-25 14:23:34 -0700 | [diff] [blame] | 20 | /** |
| 21 | * Opaque version structure. |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 22 | * <p> |
| 23 | * Classes implementing this interface must also implement |
| 24 | * {@link #hashCode()} and {@link #equals(Object)}. |
Yuta HIGUCHI | 497c884 | 2014-09-25 14:23:34 -0700 | [diff] [blame] | 25 | */ |
| 26 | public interface Timestamp extends Comparable<Timestamp> { |
| 27 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 28 | @Override |
Sho SHIMIZU | d2e78f9 | 2015-04-10 14:27:39 -0700 | [diff] [blame] | 29 | int hashCode(); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 30 | |
| 31 | @Override |
Sho SHIMIZU | d2e78f9 | 2015-04-10 14:27:39 -0700 | [diff] [blame] | 32 | boolean equals(Object obj); |
Jonathan Hart | 403ea93 | 2015-02-20 16:23:00 -0800 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Tests if this timestamp is newer than the specified timestamp. |
| 36 | * |
| 37 | * @param other timestamp to compare against |
| 38 | * @return true if this instance is newer |
| 39 | */ |
Sho SHIMIZU | d2e78f9 | 2015-04-10 14:27:39 -0700 | [diff] [blame] | 40 | default boolean isNewerThan(Timestamp other) { |
Jonathan Hart | 403ea93 | 2015-02-20 16:23:00 -0800 | [diff] [blame] | 41 | return this.compareTo(checkNotNull(other)) > 0; |
| 42 | } |
Sho SHIMIZU | 2c05f91 | 2015-04-10 14:23:16 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Tests if this timestamp is older than the specified timestamp. |
| 46 | * |
| 47 | * @param other timestamp to compare against |
| 48 | * @return true if this instance is older |
| 49 | */ |
| 50 | default boolean isOlderThan(Timestamp other) { |
| 51 | return this.compareTo(checkNotNull(other)) < 0; |
| 52 | } |
Yuta HIGUCHI | 497c884 | 2014-09-25 14:23:34 -0700 | [diff] [blame] | 53 | } |