Split GenericAviationWeatherMessageScanner into IWXXM version- and message-specific scanners for better maintainability and cleaner responsibility of components.
Implementation suggestion:
In GenericAviationWeatherMessageParser<T>:
Replace single scanner field with private Map<GenericAviationWeatherMessageParser.ScannerKey, GenericAviationWeatherMessageScanner> scanners.
ScannerKey would be a static inner value class with two properties: getNamespaceURI() and getDocumentElementName() being localName of document element. Carefully implement hashCode() (use Objects.hash()) and equals().
In convertMessage() method resolve the scanner responsible for message type and invoke it. Handle missing scanner / unknown message type gracefully.
Refactor GenericAviationWeatherMessageScanner into an interface and create abstract AbstractGenericAviationWeatherMessageScanner base implementation.
Split
GenericAviationWeatherMessageScanner
into IWXXM version- and message-specific scanners for better maintainability and cleaner responsibility of components.Implementation suggestion:
GenericAviationWeatherMessageParser<T>
:private Map<GenericAviationWeatherMessageParser.ScannerKey, GenericAviationWeatherMessageScanner> scanners
.ScannerKey
would be a static inner value class with two properties:getNamespaceURI()
andgetDocumentElementName()
beinglocalName
of document element. Carefully implementhashCode()
(useObjects.hash()
) andequals()
.convertMessage()
method resolve the scanner responsible for message type and invoke it. Handle missing scanner / unknown message type gracefully.GenericAviationWeatherMessageScanner
into an interface and create abstractAbstractGenericAviationWeatherMessageScanner
base implementation.Generic<MESSAGE-TYPE>IWXXMScanner
fi.fmi.avi.converter.iwxxm.<IWXXM-VERSION>.<MESSAGE-TYPE>