Package groovy.json
Class DefaultJsonGenerator.ClosureConverter
- java.lang.Object
- 
- groovy.json.DefaultJsonGenerator.ClosureConverter
 
- 
- All Implemented Interfaces:
- JsonGenerator.Converter
 - Enclosing class:
- DefaultJsonGenerator
 
 protected static class DefaultJsonGenerator.ClosureConverter extends java.lang.Object implements JsonGenerator.Converter A converter that handles converting a given type using a closure.- Since:
- 2.5.0
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected Closure<?>closureprotected intparamCountprotected java.lang.Class<?>type
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedClosureConverter(java.lang.Class<?> type, Closure<?> closure)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectconvert(java.lang.Object value, java.lang.String key)Converts a given value.booleanequals(java.lang.Object o)Any two Converter instances registered for the same type are considered to be equal.booleanhandles(java.lang.Class<?> type)Returnstrueif this converter can handle conversions of the given type.inthashCode()java.lang.StringtoString()
 
- 
- 
- 
Field Detail- 
typeprotected final java.lang.Class<?> type 
 - 
closureprotected final Closure<?> closure 
 - 
paramCountprotected final int paramCount 
 
- 
 - 
Constructor Detail- 
ClosureConverterprotected ClosureConverter(java.lang.Class<?> type, Closure<?> closure)
 
- 
 - 
Method Detail- 
handlespublic boolean handles(java.lang.Class<?> type) Returnstrueif this converter can handle conversions of the given type.- Specified by:
- handlesin interface- JsonGenerator.Converter
- Parameters:
- type- the type of the object to convert
- Returns:
- true if this converter can successfully convert values of the given type
 
 - 
convertpublic java.lang.Object convert(java.lang.Object value, java.lang.String key)Converts a given value.- Specified by:
- convertin interface- JsonGenerator.Converter
- Parameters:
- value- the object to convert
- key- the key name for the value, may be- null
- Returns:
- the converted object
 
 - 
equalspublic boolean equals(java.lang.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.- Overrides:
- equalsin class- java.lang.Object
- Parameters:
- o- the object with which to compare.
- Returns:
- trueif this object contains the same class;- falseotherwise.
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-