org.hibernate.search.elasticsearch.gson.impl

## Class JsonIntegerAccessorImpl

- java.lang.Object
- - org.hibernate.search.elasticsearch.gson.impl.JsonIntegerAccessorImpl

- All Implemented Interfaces:
    JsonAccessor<Integer>

      public class JsonIntegerAccessorImpl
      extends Object

  Author:
    Yoann Rodiere

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JsonIntegerAccessorImpl(JsonAccessor<com.google.gson.JsonElement> parentAccessor)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(com.google.gson.JsonObject root, T newValue)` Add the given primitive value to the element this accessor points to for the given `root`.
    `protected void` | `appendRuntimeRelativePath(StringBuilder path)`
    `protected void` | `appendStaticRelativePath(StringBuilder path, boolean first)`
    `Optional<T>` | `get(com.google.gson.JsonObject root)` Get the current value of the element this accessor points to for the given `root`.
    `protected JsonElementType<Integer>` | `getExpectedElementType()`
    `T` | `getOrCreate(com.google.gson.JsonObject root, Supplier<? extends T> newValueSupplier)` Get the current value of the element this accessor points to for the given `root`, creating it and setting it if it hasn't been set yet.
    `protected JsonAccessor<P>` | `getParentAccessor()`
    `String` | `getStaticAbsolutePath()`
    `void` | `set(com.google.gson.JsonObject root, T newValue)` Set the given value on the element this accessor points to for the given `root`.
    `protected com.google.gson.JsonElement` | `toElement(T value)`
    `String` | `toString()`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.hibernate.search.elasticsearch.gson.impl.JsonAccessor

      `root`

- - ### Constructor Detail

    - #### JsonIntegerAccessorImpl

          public JsonIntegerAccessorImpl(JsonAccessor<com.google.gson.JsonElement> parentAccessor)

  - ### Method Detail

    - #### getExpectedElementType

          protected JsonElementType<Integer> getExpectedElementType()

    - #### get

          public Optional<T> get(com.google.gson.JsonObject root)
                          throws UnexpectedJsonElementTypeException

      Description copied from interface: `JsonAccessor`
      Get the current value of the element this accessor points to for the given `root`.
      Parameters:
        `root` - The root to be accessed.
      Returns:
        An `Optional` containing the current value pointed to by this accessor on the `root`, or `Optional.empty()` if it doesn't exist.
      Throws:
        `UnexpectedJsonElementTypeException` - If an element in the path has unexpected type, preventing access to the element this accessor points to.

    - #### set

          public void set(com.google.gson.JsonObject root,
                          T newValue)
                   throws UnexpectedJsonElementTypeException

      Description copied from interface: `JsonAccessor`
      Set the given value on the element this accessor points to for the given `root`.
      Parameters:
        `root` - The root to be accessed.
        `newValue` - The value to set.
      Throws:
        `UnexpectedJsonElementTypeException` - If an element in the path has unexpected type, preventing access to the element this accessor points to.

    - #### add

          public void add(com.google.gson.JsonObject root,
                          T newValue)
                   throws UnexpectedJsonElementTypeException

      Description copied from interface: `JsonAccessor`
      Add the given primitive value to the element this accessor points to for the given `root`.

      This method differs from `JsonAccessor.set(JsonObject, Object)`:

      - If there is currently no value, the given value is simply `set`.
      - If the current value is an array, the given value is added to this array.
      - If the current value is a primitive or `JsonNull`, the current value is replaced by an array containing the current value followed by the given value.
      - Otherwise (i.e. if the current value is an object), an `UnexpectedJsonElementTypeException` is thrown.
      Parameters:
        `root` - The root to be accessed.
        `newValue` - The value to add.
      Throws:
        `UnexpectedJsonElementTypeException` - If an element in the path has unexpected type, preventing write access to the element this accessor points to.

    - #### getOrCreate

          public T getOrCreate(com.google.gson.JsonObject root,
                               Supplier<? extends T> newValueSupplier)
                        throws UnexpectedJsonElementTypeException

      Description copied from interface: `JsonAccessor`
      Get the current value of the element this accessor points to for the given `root`, creating it and setting it if it hasn't been set yet.
      Parameters:
        `root` - The root to be accessed.
        `newValueSupplier` - The value to set and return if the current value hasn't been set yet.
      Returns:
        The current value pointed to by this accessor on the `root`, always non-null.
      Throws:
        `UnexpectedJsonElementTypeException` - if the element already exists and is not of the expected type, or if an element in the path has unexpected type, preventing access to the element this accessor points to.

    - #### toElement

          protected com.google.gson.JsonElement toElement(T value)

    - #### appendRuntimeRelativePath

          protected void appendRuntimeRelativePath(StringBuilder path)

    - #### appendStaticRelativePath

          protected void appendStaticRelativePath(StringBuilder path,
                                                  boolean first)

    - #### getParentAccessor

          protected JsonAccessor<P> getParentAccessor()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getStaticAbsolutePath

          public String getStaticAbsolutePath()

      Specified by:
        `getStaticAbsolutePath` in interface `JsonAccessor<T>`
      Returns:
        The absolute path representing this accessor, excluding runtime details such as array indices or types. `null` for the root accessor.

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved