[Java] Class DefaultJsonGenerator.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
Modifiers | Name | Description |
---|---|---|
protected Closure<?> | closure | |
protected int | paramCount | |
protected Class<?> | type |
Constructor Summary
Constructor and description |
---|
protected ClosureConverter
(Class<?> type, Closure<?> closure) |
Methods Summary
Type Params | Return Type | Name and description |
---|---|---|
public Object |
convert(Object value, String key) Converts a given value. | |
public boolean |
equals(Object o) Any two Converter instances registered for the same type are considered to be equal. | |
public boolean |
handles(Class<?> type) Returns true if this converter can handle conversions of the given type. | |
public int |
hashCode() | |
public String |
toString() |
Inherited Methods Summary
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 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 benull
- 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()
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/groovy/json/DefaultJsonGenerator.ClosureConverter.html