Package edu.ie3.datamodel.io.processor
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
Basic sketch and skeleton for a processors including all functions that apply for all needed
subtypes of processors
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final org.slf4j.Logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns a (unmodifiable)List
of classes that this Processors is capable of processingabstract String[]
Return all header elements of the tableReveal the registered classhandleProcessorSpecificQuantity
(javax.measure.Quantity<?> quantity, String fieldName) This method should handle all quantities that are model processor specific e.g.protected String
handleQuantity
(javax.measure.Quantity<?> quantity, String fieldName) Standard method to process a Quantity to a String based on a method return objectmapFieldNameToGetter
(Class<?> cls) Maps the foreseen table fields to the objects gettersmapFieldNameToGetter
(Class<?> cls, Collection<String> ignoreFields) Maps the foreseen table fields to the objects getters and ignores the specified fieldsprotected String
processMethodResult
(Object methodReturnObject, Method method, String fieldName) Processes the returned object to String by taking care of different conventions.protected LinkedHashMap<String,
String> processObject
(Object object, Map<String, Method> fieldNameToGetter) Processes the object to a map from field name to value as String representationprotected String
processOperationTime
(OperationTime operationTime, String fieldName) Handling of elements of typeOperationTime
protected String
processUUIDArray
(UUID[] uuids) protected String
processVoltageLevel
(VoltageLevel voltageLevel, String fieldName) Handling of elements of typeVoltageLevel
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.putUuidFirst
(Map<String, V> unsorted) Ensure, that the uuid field is put first.quantityValToOptionalString
(javax.measure.Quantity<?> quantity) Converts a given quantity to String by extracting the value and applying the toString method to it
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
registeredClass
-
-
Constructor Details
-
Processor
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
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 mappingignoreFields
- A collection of all field names to ignore during process- Returns:
- an array of strings of all field values of the class
-
putUuidFirst
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 processfieldNameToGetter
- Mapping from field name to getter- Returns:
- Mapping from field name to value as String representation
-
processMethodResult
Processes the returned object to String by taking care of different conventions.- Parameters:
methodReturnObject
- Return object to processmethod
- The method, that is invokedfieldName
- Name of the foreseen field- Returns:
- A String representation of the result
-
processVoltageLevel
Handling of elements of typeVoltageLevel
- Parameters:
voltageLevel
- the voltage level that should be processedfieldName
- 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
Standard method to process a Quantity to a String based on a method return object- Parameters:
quantity
- the quantity that should be processedfieldName
- 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 forResultEntity
s andSystemParticipantInput
s Hence from the generalized methodhandleQuantity(Quantity, String)
, this allows for the specific handling of child implementations. See the implementation @ResultEntityProcessor
for details.- Parameters:
quantity
- the quantity that should be processedfieldName
- 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
-
processOperationTime
Handling of elements of typeOperationTime
- Parameters:
operationTime
- the operation time that should be processedfieldName
- 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
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
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
Return all header elements of the table- Returns:
- all header elements of the table
-
getRegisteredClass
Reveal the registered class- Returns:
- the registered class
-
getEligibleEntityClasses
Returns a (unmodifiable)List
of classes that this Processors is capable of processing- Returns:
- The unmodifiable
List
of eligible classes
-