View Javadoc

1   package com.atlassian.vcache.internal.core.cas;
2   
3   import com.atlassian.vcache.CasIdentifier;
4   
5   import java.io.Serializable;
6   
7   /**
8    * Implementation of {@link CasIdentifier} that uses current time as the unique identifier.
9    *
10   * @since 1.1.0
11   */
12  public class IdentifiedData implements Serializable, CasIdentifier {
13      // Using nano time to create a "unique" identifier. See NOTED.md file for more.
14      private final long casId = System.nanoTime();
15  
16      @Override
17      public boolean equals(Object o) {
18          if (this == o) {
19              return true;
20          }
21          if (!(o instanceof IdentifiedData)) {
22              return false;
23          }
24  
25          final IdentifiedData that = (IdentifiedData) o;
26  
27          return casId == that.casId;
28      }
29  }