2 * Copyright 2014-present Open Networking Foundation
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package io.atomix.utils.time;
18 import com.google.common.base.Preconditions;
21 * Opaque version structure.
23 * Classes implementing this interface must also implement
24 * {@link #hashCode()} and {@link #equals(Object)}.
26 public interface Timestamp extends Comparable<Timestamp> {
32 boolean equals(Object obj);
35 * Tests if this timestamp is newer than the specified timestamp.
37 * @param other timestamp to compare against
38 * @return true if this instance is newer
40 default boolean isNewerThan(Timestamp other) {
41 return this.compareTo(Preconditions.checkNotNull(other)) > 0;
45 * Tests if this timestamp is older than the specified timestamp.
47 * @param other timestamp to compare against
48 * @return true if this instance is older
50 default boolean isOlderThan(Timestamp other) {
51 return this.compareTo(Preconditions.checkNotNull(other)) < 0;