Class EnumExtractor

java.lang.Object
org.jolokia.service.serializer.json.EnumExtractor
All Implemented Interfaces:
Extractor

public class EnumExtractor extends Object implements Extractor
Extractor for extracting enums. Enums are represented by the canonical name (Enum.name()).
Since:
18.02.13
Author:
roland
  • Constructor Details

    • EnumExtractor

      public EnumExtractor()
  • Method Details

    • getType

      public Class<?> getType()
      Type for which this extractor can objects of this type
      Specified by:
      getType in interface Extractor
      Returns:
      type which can be handled
    • extractObject

      public Object extractObject(ObjectToJsonConverter pConverter, Object pValue, Deque<String> pPathPart, boolean jsonify) throws AttributeNotFoundException
      Extract an object from pValue. In the simplest case, this is the value itself. For more complex data types, it is converted into a JSON structure if possible (and if 'jsonify' is true). pExtraArgs is not null, this returns only a substructure, specified by the path represented by this stack
      Specified by:
      extractObject in interface Extractor
      Parameters:
      pConverter - the global converter in order to be able do dispatch for serializing inner data types
      pValue - the value to convert
      pPathPart - extra arguments which contain e.g. a path
      jsonify - whether to convert to a JSON object/list or whether the plain object should be returned. The later is required for writing an inner value
      Returns:
      the extracted object
      Throws:
      AttributeNotFoundException - if the inner path does not exist.
    • setObjectValue

      public Object setObjectValue(StringToObjectConverter pConverter, Object pInner, String pAttribute, Object pValue) throws IllegalAccessException, InvocationTargetException
      If this extractor is able to set a value (see Extractor.canSetValue()), this method sets the value even on an inner object
      Specified by:
      setObjectValue in interface Extractor
      Parameters:
      pConverter - the global converter in order to be able do dispatch for serializing inner data types
      pInner - object on which to set the value
      pAttribute - attribute of the object to set
      pValue - the new value to set
      Returns:
      the old value
      Throws:
      IllegalAccessException - if the attribute to set to is not accessible
      InvocationTargetException - reflection error
    • canSetValue

      public boolean canSetValue()
      Whether this extractor is able to set a value.
      Specified by:
      canSetValue in interface Extractor
      Returns:
      true if this extractor can set a value, false otherwise.