ObjectId
Date: 2015-03-03

org.bson.types

## Class ObjectId

- java.lang.Object
- - org.bson.types.ObjectId

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<ObjectId>

      public class ObjectId
      extends java.lang.Object
      implements java.lang.Comparable<ObjectId>, java.io.Serializable

  A globally unique identifier for objects.

  Consists of 12 bytes, divided as follows:

  >      0123456
  >          7891011
  >      timemachine
  >          pidinc

  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ObjectId()` Create a new object id.
    `ObjectId(byte[] b)`
    `ObjectId(java.util.Date time)`
    `ObjectId(java.util.Date time, int inc)`
    `ObjectId(java.util.Date time, int machine, int inc)`
    `ObjectId(int time, int machine, int inc)` Creates an ObjectId
    `ObjectId(java.lang.String s)` Creates a new instance from a string.
    `ObjectId(java.lang.String s, boolean babble)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `_flip(int x)`
    `int` | `_inc()`
    `int` | `_machine()`
    `int` | `_time()`
    `static java.lang.String` | `babbleToMongod(java.lang.String b)`
    `int` | `compareTo(ObjectId id)`
    `boolean` | `equals(java.lang.Object o)`
    `static ObjectId` | `get()` Gets a new object id.
    `static int` | `getCurrentInc()` Gets the current value of the auto increment
    `static int` | `getGenMachineId()` Gets the generated machine ID, identifying the machine / process / class loader
    `int` | `getInc()`
    `int` | `getMachine()`
    `long` | `getTime()` Gets the time of this ID, in milliseconds
    `int` | `getTimeSecond()` Gets the time of this ID, in seconds
    `int` | `hashCode()`
    `boolean` | `isNew()`
    `static boolean` | `isValid(java.lang.String s)` Checks if a string could be an `ObjectId`.
    `static ObjectId` | `massageToObjectId(java.lang.Object o)` Turn an object into an `ObjectId`, if possible.
    `void` | `notNew()`
    `byte[]` | `toByteArray()`
    `java.lang.String` | `toString()`
    `java.lang.String` | `toStringBabble()`
    `java.lang.String` | `toStringMongod()`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ObjectId

          public ObjectId(java.util.Date time)

    - #### ObjectId

          public ObjectId(java.util.Date time,
                  int inc)

    - #### ObjectId

          public ObjectId(java.util.Date time,
                  int machine,
                  int inc)

    - #### ObjectId

          public ObjectId(java.lang.String s)

      Creates a new instance from a string.
      Parameters:
        `s` - the string to convert
      Throws:
        `java.lang.IllegalArgumentException` - if the string is not a valid id

    - #### ObjectId

          public ObjectId(java.lang.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 Detail

    - #### get

          public static ObjectId get()

      Gets a new object id.
      Returns:
        the new id

    - #### isValid

          public static boolean isValid(java.lang.String s)

      Checks if a string could be an `ObjectId`.
      Returns:
        whether the string could be an object id

    - #### massageToObjectId

          public static ObjectId massageToObjectId(java.lang.Object o)

      Turn an object into an `ObjectId`, if possible. Strings will be converted into `ObjectId`s, if possible, and `ObjectId`s will be cast and returned. Passing in `null` returns `null`.
      Parameters:
        `o` - the object to convert
      Returns:
        an `ObjectId` if it can be massaged, null otherwise

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object o)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### toStringBabble

          public java.lang.String toStringBabble()

    - #### toStringMongod

          public java.lang.String toStringMongod()

    - #### toByteArray

          public byte[] toByteArray()

    - #### babbleToMongod

          public static java.lang.String babbleToMongod(java.lang.String b)

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### compareTo

          public int compareTo(ObjectId id)

      Specified by:
        `compareTo` in interface `java.lang.Comparable<ObjectId>`

    - #### getMachine

          public int getMachine()

    - #### getTime

          public long getTime()

      Gets the time of this ID, in milliseconds

    - #### getTimeSecond

          public int getTimeSecond()

      Gets the time of this ID, in seconds

    - #### getInc

          public int getInc()

    - #### _time

          public int _time()

    - #### _machine

          public int _machine()

    - #### _inc

          public int _inc()

    - #### isNew

          public boolean isNew()

    - #### notNew

          public void notNew()

    - #### getGenMachineId

          public static int getGenMachineId()

      Gets the generated machine ID, identifying the machine / process / class loader

    - #### getCurrentInc

          public static int getCurrentInc()

      Gets the current value of the auto increment

    - #### _flip

          public static int _flip(int x)