Package groovy.json

Class DefaultJsonGenerator.ClosureConverter

    • Field Detail

      • type

        protected final Class<?> type
      • closure

        protected final Closure<?> closure
      • paramCount

        protected final int paramCount
    • Constructor Detail

      • ClosureConverter

        protected ClosureConverter​(Class<?> type,
                                   Closure<?> closure)
    • Method Detail

      • handles

        public boolean handles​(Class<?> type)
        Returns true if this converter can handle conversions of the given type.
        Specified by:
        handles in interface JsonGenerator.Converter
        type - the type of the object to convert
        true if this converter can successfully convert values of the given type
      • convert

        public Object convert​(Object value,
                              String key)
        Converts a given value.
        Specified by:
        convert in interface JsonGenerator.Converter
        value - the object to convert
        key - the key name for the value, may be null
        the converted object
      • equals

        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.
        equals in class Object
        o - the object with which to compare.
        true if this object contains the same class; false otherwise.
      • hashCode

        public int hashCode()
        hashCode in class Object