Package: groovy.json

## [Java] Class ClosureConverter

- groovy.json.DefaultJsonGenerator.ClosureConverter

- All Implemented Interfaces and Traits:
    Converter

      protected static class DefaultJsonGenerator.ClosureConverter

  A converter that handles converting a given type using a closure.

  Since:
    2.5.0

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected Closure<?>` | `closure` |
    `protected int` | `paramCount` |
    `protected Class<?>` | `type` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `protected DefaultJsonGenerator.ClosureConverter (Class<?> type, Closure<?> closure)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `Object` | `convert(Object value, String key)` Converts a given value.
    `` | `boolean` | `equals(Object o)` Any two Converter instances registered for the same type are considered to be equal.
    `` | `boolean` | `handles(Class<?> type)` Returns `true` if this converter can handle conversions of the given type.
    `` | `int` | `hashCode()`
    `` | `String` | `toString()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Field Detail

    - #### protected final Closure<?> closure

    - #### protected final int paramCount

    - #### protected final Class<?> type

  - ### Constructor Detail

    - #### protected DefaultJsonGenerator.ClosureConverter(Class<?> type, Closure<?> closure)

  - ### Method Detail

    - #### @Override public Object convert(Object value, String key)

      Converts a given value.

      Parameters:
        `value` - the object to convert
        `key` - the key name for the value, may be `null`
      Returns:
        the converted object

    - #### @Override public boolean equals(Object o)

      Any two Converter instances registered for the same type are considered to be equal. This comparison makes managing instances in a Set easier; since there is no chaining of Converters it makes sense to only allow one per type.

      Parameters:
        `o` - the object with which to compare.
      Returns:
        `true` if this object contains the same class; `false` otherwise.

    - #### @Override public boolean handles(Class<?> type)

      Returns `true` if this converter can handle conversions of the given type.

      Parameters:
        `type` - the type of the object to convert
      Returns:
        true if this converter can successfully convert values of the given type

    - #### @Override public int hashCode()

    - #### @Override public String toString()