Class Processor<T>

java.lang.Object
edu.ie3.datamodel.io.processor.Processor<T>
Type Parameters:
T - Type parameter of the class to handle
Direct Known Subclasses:
EntityProcessor

public abstract class Processor<T> extends Object
Basic sketch and skeleton for a processors including all functions that apply for all needed subtypes of processors
  • Field Details

    • logger

      protected static final org.slf4j.Logger logger
    • registeredClass

      protected final Class<? extends T> registeredClass
  • Constructor Details

    • Processor

      protected Processor(Class<? extends T> foreSeenClass)
      Instantiates a Processor for a foreseen class
      Parameters:
      foreSeenClass - Class and its children that are foreseen to be handled with this processor
  • Method Details

    • mapFieldNameToGetter

      protected SortedMap<String,Method> mapFieldNameToGetter(Class<?> cls)
      Maps the foreseen table fields to the objects getters
      Parameters:
      cls - class to use for mapping
      Returns:
      an array of strings of all field values of the class
    • mapFieldNameToGetter

      protected SortedMap<String,Method> mapFieldNameToGetter(Class<?> cls, Collection<String> ignoreFields)
      Maps the foreseen table fields to the objects getters and ignores the specified fields
      Parameters:
      cls - class to use for mapping
      ignoreFields - A collection of all field names to ignore during process
      Returns:
      an array of strings of all field values of the class
    • putUuidFirst

      public static <V> SortedMap<String,V> putUuidFirst(Map<String,V> unsorted)
      Ensure, that the uuid field is put first. All other fields are sorted alphabetically. Additionally, the map is immutable
      Type Parameters:
      V - Type of the values in the map
      Parameters:
      unsorted - The unsorted map
      Returns:
      The sorted map - what a surprise!
    • processObject

      protected LinkedHashMap<String,String> processObject(Object object, Map<String,Method> fieldNameToGetter)
      Processes the object to a map from field name to value as String representation
      Parameters:
      object - The object to process
      fieldNameToGetter - Mapping from field name to getter
      Returns:
      Mapping from field name to value as String representation
    • processMethodResult

      protected String processMethodResult(Object methodReturnObject, Method method, String fieldName)
      Processes the returned object to String by taking care of different conventions.
      Parameters:
      methodReturnObject - Return object to process
      method - The method, that is invoked
      fieldName - Name of the foreseen field
      Returns:
      A String representation of the result
    • processVoltageLevel

      protected String processVoltageLevel(VoltageLevel voltageLevel, String fieldName)
      Handling of elements of type VoltageLevel
      Parameters:
      voltageLevel - the voltage level that should be processed
      fieldName - the field name that should be generated (either v_rated or volt_lvl)
      Returns:
      the resulting string of a VoltageLevel attribute value for the provided field or an empty string when an invalid field name is provided
    • handleQuantity

      protected String handleQuantity(javax.measure.Quantity<?> quantity, String fieldName)
      Standard method to process a Quantity to a String based on a method return object
      Parameters:
      quantity - the quantity that should be processed
      fieldName - the field name the quantity is set to
      Returns:
      an optional string with the normalized to StandardUnits value of the quantity or empty if an error occurred during processing
    • handleProcessorSpecificQuantity

      protected abstract Optional<String> handleProcessorSpecificQuantity(javax.measure.Quantity<?> quantity, String fieldName)
      This method should handle all quantities that are model processor specific e.g. we need to handle active power p different for ResultEntitys and SystemParticipantInputs Hence from the generalized method handleQuantity(Quantity, String), this allows for the specific handling of child implementations. See the implementation @ ResultEntityProcessor for details.
      Parameters:
      quantity - the quantity that should be processed
      fieldName - the field name the quantity is set to
      Returns:
      an optional string with the normalized to StandardUnits value of the quantity or empty if an error occurred during processing
    • processUUIDArray

      protected String processUUIDArray(UUID[] uuids)
    • processOperationTime

      protected String processOperationTime(OperationTime operationTime, String fieldName)
      Handling of elements of type OperationTime
      Parameters:
      operationTime - the operation time that should be processed
      fieldName - the field name that should be generated (either operatesFrom or operatesUntil)
      Returns:
      the resulting string of a OperationTime attribute value for the provided field or an empty string when an invalid field name is provided
    • processZonedDateTime

      protected String processZonedDateTime(ZonedDateTime zonedDateTime)
      Standard method to process a ZonedDateTime to a String based on a method return object NOTE: this method does NOT check if the provided object is of type ZonedDateTime. This has to be done manually BEFORE calling this method!
      Parameters:
      zonedDateTime - representation of the ZonedDateTime
      Returns:
      string representation of the ZonedDateTime
    • quantityValToOptionalString

      protected Optional<String> quantityValToOptionalString(javax.measure.Quantity<?> quantity)
      Converts a given quantity to String by extracting the value and applying the toString method to it
      Parameters:
      quantity - Quantity to convert
      Returns:
      A string of the quantity's value
    • getHeaderElements

      public abstract String[] getHeaderElements()
      Return all header elements of the table
      Returns:
      all header elements of the table
    • getRegisteredClass

      protected Class<? extends T> getRegisteredClass()
      Reveal the registered class
      Returns:
      the registered class
    • getEligibleEntityClasses

      protected abstract List<Class<? extends T>> getEligibleEntityClasses()
      Returns a (unmodifiable) List of classes that this Processors is capable of processing
      Returns:
      The unmodifiable List of eligible classes