Package groovy.json

Class DefaultJsonGenerator.ClosureConverter

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Closure<?> closure  
      protected int paramCount  
      protected java.lang.Class<?> type  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ClosureConverter​(java.lang.Class<?> type, Closure<?> closure)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object convert​(java.lang.Object value, java.lang.String key)
      Converts a given value.
      boolean equals​(java.lang.Object o)
      Any two Converter instances registered for the same type are considered to be equal.
      boolean handles​(java.lang.Class<?> type)
      Returns true if this converter can handle conversions of the given type.
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • type

        protected final java.lang.Class<?> type
      • closure

        protected final Closure<?> closure
      • paramCount

        protected final int paramCount
    • Constructor Detail

      • ClosureConverter

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

      • handles

        public boolean handles​(java.lang.Class<?> type)
        Returns true if this converter can handle conversions of the given type.
        Specified by:
        handles in 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
      • convert

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

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

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object