# Class Objects (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Objects)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.util.Objects)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.util.Objects)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.util.Objects)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.util.Objects)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.util.Objects)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.util.Objects)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.util.Objects)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.util.Objects)

    public final class Objects

Helper functions that can operate on any `Object`.

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> Objects

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Methods

### equal(Object a, Object b)

    public static boolean equal(Object a, Object b)

Determines whether two possibly-null objects are equal. Returns:

- `true` if `a` and `b` are both null.
- `true` if `a` and `b` are both non-null and they are equal according to [Object#equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-).
- `false` in all other situations.

This assumes that any non-null objects passed to this function conform to the `
equals()` contract.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `a` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |
| `b` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### toStringHelper(Object self)

    public static Objects.ToStringHelper toStringHelper(Object self)

Creates an instance of ToStringHelper.

This is helpful for implementing [Object#toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--). Specification by example:

// Returns "ClassName{}"
Objects.toStringHelper(this)
.toString();

// Returns "ClassName{x=1}"
Objects.toStringHelper(this)
.add("x", 1)
.toString();

// Returns "MyObject{x=1}"
Objects.toStringHelper("MyObject")
.add("x", 1)
.toString();

// Returns "ClassName{x=1, y=foo}"
Objects.toStringHelper(this)
.add("x", 1)
.add("y", "foo")
.toString();

// Returns "ClassName{x=1}"
Objects.toStringHelper(this)
.omitNullValues()
.add("x", 1)
.add("y", null)
.toString();

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `self` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` the object to generate the string for (typically `this`), used only for its class name |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Objects.ToStringHelper` |   |