Class ObjectID

java.lang.Object
org.aoju.bus.core.key.ObjectID
All Implemented Interfaces:
Serializable, Comparable<ObjectID>

public class ObjectID extends Object implements Comparable<ObjectID>, Serializable
对象的全局唯一标识符 由12个字节组成,分割如下:
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Details

    • ObjectID

      public ObjectID(Date time)
    • ObjectID

      public ObjectID(Date time, int inc)
    • ObjectID

      public ObjectID(Date time, int machine, int inc)
    • ObjectID

      public ObjectID(String s)
      Creates a new instance from a string.
      Parameters:
      s - the string to convert
      Throws:
      IllegalArgumentException - if the string is not a valid id
    • ObjectID

      public ObjectID(String s, boolean babble)
    • ObjectID

      public ObjectID(byte[] b)
    • ObjectID

      public ObjectID(int time, int machine, int inc)
      Creates an ObjectId
      Parameters:
      time - time in seconds
      machine - machine ID
      inc - incremental value
    • ObjectID

      public ObjectID()
      Create a new object id.
  • Method Details

    • id

      public static String id()
      获取ObjectId.
      Returns:
      the new id
    • get

      public static ObjectID get()
      获取ObjectId
      Returns:
      the new id
    • isValid

      public static boolean isValid(String text)
      检查字符串是否可以是ObjectId
      Parameters:
      text - 字符串
      Returns:
      true/false
    • massageToObjectId

      public static ObjectID massageToObjectId(Object o)
      将对象转换为ObjectId
      Parameters:
      o - 要转换的对象
      Returns:
      objectid/null
    • babbleToMongod

      public static String babbleToMongod(String b)
    • getGenMachineId

      public static int getGenMachineId()
      获取生成的机器ID,标识机器/进程/类 加载程序
      Returns:
      the int
    • getCurrentInc

      public static int getCurrentInc()
      获取自动增量的当前值
      Returns:
      the int
    • _flip

      public static int _flip(int x)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toStringBabble

      public String toStringBabble()
    • toStringMongod

      public String toStringMongod()
    • toByteArray

      public byte[] toByteArray()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(ObjectID id)
      Specified by:
      compareTo in interface Comparable<ObjectID>
    • getMachine

      public int getMachine()
    • getTime

      public long getTime()
      获取此ID的时间(以毫秒为单位)
      Returns:
      the long
    • getTimeSecond

      public int getTimeSecond()
      获取此ID的时间(以秒为单位)
      Returns:
      the int
    • getInc

      public int getInc()
    • _time

      public int _time()
    • _machine

      public int _machine()
    • _inc

      public int _inc()
    • isNew

      public boolean isNew()
    • notNew

      public void notNew()