- java.lang.Object
-
- com.powsybl.iidm.xml.util.IidmXmlUtil
-
public final class IidmXmlUtil extends Object
- Author:
- Miora Ralambotiana
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IidmXmlUtil.ErrorMessage
static interface
IidmXmlUtil.IidmXmlRunnable
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
assertMaximumVersion(String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion maxVersion, NetworkXmlReaderContext context)
Assert that the reader context's IIDM-XML version equals or is less recent than a given IIDM-XML version.static void
assertMaximumVersion(String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion maxVersion, NetworkXmlWriterContext context)
Assert that the writer context's IIDM-XML version equals or is less recent than a given IIDM-XML version.static void
assertMaximumVersion(String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion maxVersion, NetworkXmlReaderContext context)
Assert that the reader context's IIDM-XML version equals or is less recent than a given IIDM-XML version.static void
assertMaximumVersion(String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion maxVersion, NetworkXmlWriterContext context)
Assert that the writer context's IIDM-XML version equals or is less recent than a given IIDM-XML version.static void
assertMinimumVersion(String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlReaderContext context)
Assert that the reader context's IIDM-XML version equals or is more recent than a given IIDM-XML version.static void
assertMinimumVersion(String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context)
Assert that the writer context's IIDM-XML version equals or is more recent than a given IIDM-XML version.static void
assertMinimumVersion(String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlReaderContext context)
Assert that the reader context's IIDM-XML version equals or is more recent than a given IIDM-XML version.static void
assertMinimumVersion(String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context)
Assert that the writer context's IIDM-XML version equals or is more recent than a given IIDM-XML version.static void
assertMinimumVersionAndRunIfNotDefault(boolean valueIsNotDefault, String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlReaderContext context, IidmXmlUtil.IidmXmlRunnable runnable)
Assert that the reader context's IIDM-XML version equals or is more recent than a given IIDM-XML version if the value of an attribute or the state of an equipment is not default (interpretable for previous versions).static void
assertMinimumVersionAndRunIfNotDefault(boolean valueIsNotDefault, String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context, IidmXmlUtil.IidmXmlRunnable runnable)
Assert that the writer context's IIDM-XML version equals or is more recent than a given IIDM-XML version if the value of an attribute or the state of an equipment is not default (interpretable for previous versions).static void
assertMinimumVersionIfNotDefault(boolean valueIsNotDefault, String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlReaderContext context)
Assert that the reader context's IIDM-XML version equals or is more recent than a given IIDM-XML version if the value of an attribute or the state of an equipment is not default (interpretable for previous versions).static void
assertMinimumVersionIfNotDefault(boolean valueIsNotDefault, String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context)
Assert that the writer context's IIDM-XML version equals or is more recent than a given IIDM-XML version if the value of an attribute or the state of an equipment is not default (interpretable for previous versions).static void
assertStrictMaximumVersion(String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion maxVersion, NetworkXmlReaderContext context)
Assert that the reader context's IIDM-XML version is strictly older than a given IIDM-XML version.static void
assertStrictMaximumVersion(String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion maxVersion, NetworkXmlWriterContext context)
Assert that the writer context's IIDM-XML version is strictly older than a given IIDM-XML version.static <C extends AbstractNetworkXmlContext>
voidrunFromMinimumVersion(IidmXmlVersion minVersion, C context, IidmXmlUtil.IidmXmlRunnable runnable)
Run a given runnable if the context's IIDM-XML version equals or is more recent than a given minimum IIDM-XML version.static <C extends AbstractNetworkXmlContext>
voidrunUntilMaximumVersion(IidmXmlVersion maxVersion, C context, IidmXmlUtil.IidmXmlRunnable runnable)
Run a given runnable if the context's IIDM-XML version equals or is older than a given maximum IIDM-XML version.static <T extends Identifiable>
Iterable<T>sorted(Iterable<T> identifiables, ExportOptions exportOptions)
Sort identifiables by their ids.static <T extends Identifiable<T>>
Stream<T>sorted(Stream<T> stream, ExportOptions exportOptions)
Sort identifiables by their ids.static Iterable<? extends Extension<? extends Identifiable<?>>>
sortedExtensions(Iterable<? extends Extension<? extends Identifiable<?>>> extensions, ExportOptions exportOptions)
Sort extensions by their names.static Iterable<VoltageLevel.NodeBreakerView.InternalConnection>
sortedInternalConnections(Iterable<VoltageLevel.NodeBreakerView.InternalConnection> internalConnections, ExportOptions exportOptions)
Sort internal connections first by their side one node value then by their side 2 node value.static Iterable<String>
sortedNames(Iterable<String> names, ExportOptions exportOptions)
Sort names.static Iterable<LoadingLimits.TemporaryLimit>
sortedTemporaryLimits(Iterable<LoadingLimits.TemporaryLimit> temporaryLimits, ExportOptions exportOptions)
Sort temporary limits by their names.static void
writeBooleanAttributeFromMinimumVersion(String rootElementName, String attributeName, boolean value, boolean defaultValue, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context)
Write a mandatory boolean attribute from a given minimum IIDM-XML version.
If the context's IIDM-XML version is strictly older than the given minimum IIDM-XML version, the attribute's value should be default (else an exception is thrown).static void
writeDoubleAttributeFromMinimumVersion(String rootElementName, String attributeName, double value, double defaultValue, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context)
Write a double attribute from a given minimum IIDM-XML version if its value is defined.
If the context's IIDM-XML version is strictly older than the given minimum IIDM-XML version, the attribute's value should be default (else an exception is thrown).static void
writeDoubleAttributeFromMinimumVersion(String rootElementName, String attributeName, double value, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context)
Write a double attribute from a given minimum IIDM-XML version if its value is defined.
If the context's IIDM-XML version is strictly older than the given minimum IIDM-XML version, the attribute's value should be undefined i.e.static void
writeIntAttributeUntilMaximumVersion(String attributeName, int value, IidmXmlVersion maxVersion, NetworkXmlWriterContext context)
Write a mandatory int attribute until a given maximum IIDM-XML version.
-
-
-
Method Detail
-
assertMaximumVersion
public static void assertMaximumVersion(String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion maxVersion, NetworkXmlReaderContext context)
Assert that the reader context's IIDM-XML version equals or is less recent than a given IIDM-XML version. If not, throw an exception with a given type of error message.
-
assertMaximumVersion
public static void assertMaximumVersion(String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion maxVersion, NetworkXmlWriterContext context)
Assert that the writer context's IIDM-XML version equals or is less recent than a given IIDM-XML version. If not, throw an exception or log an error with a given type of error message, depending ofExportOptions.IidmVersionIncompatibilityBehavior
found in theExportOptions
of the given context.
-
assertMaximumVersion
public static void assertMaximumVersion(String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion maxVersion, NetworkXmlReaderContext context)
Assert that the reader context's IIDM-XML version equals or is less recent than a given IIDM-XML version. If not, throw an exception with a given type of error message.
-
assertMaximumVersion
public static void assertMaximumVersion(String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion maxVersion, NetworkXmlWriterContext context)
Assert that the writer context's IIDM-XML version equals or is less recent than a given IIDM-XML version. If not, throw an exception or log an error with a given type of error message, depending ofExportOptions.IidmVersionIncompatibilityBehavior
found in theExportOptions
of the given context.
-
assertMinimumVersion
public static void assertMinimumVersion(String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlReaderContext context)
Assert that the reader context's IIDM-XML version equals or is more recent than a given IIDM-XML version. If not, throw an exception with a given type of error message.
-
assertMinimumVersion
public static void assertMinimumVersion(String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context)
Assert that the writer context's IIDM-XML version equals or is more recent than a given IIDM-XML version. If not, throw an exception or log an error with a given type of error message, depending ofExportOptions.IidmVersionIncompatibilityBehavior
found in theExportOptions
of the given context.
-
assertMinimumVersion
public static void assertMinimumVersion(String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlReaderContext context)
Assert that the reader context's IIDM-XML version equals or is more recent than a given IIDM-XML version. If not, throw an exception with a given type of error message.
-
assertMinimumVersion
public static void assertMinimumVersion(String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context)
Assert that the writer context's IIDM-XML version equals or is more recent than a given IIDM-XML version. If not, throw an exception or log an error with a given type of error message, depending ofExportOptions.IidmVersionIncompatibilityBehavior
found in theExportOptions
of the given context.
-
assertMinimumVersionIfNotDefault
public static void assertMinimumVersionIfNotDefault(boolean valueIsNotDefault, String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlReaderContext context)
Assert that the reader context's IIDM-XML version equals or is more recent than a given IIDM-XML version if the value of an attribute or the state of an equipment is not default (interpretable for previous versions). If not, throw an exception with a given type of error message.
-
assertMinimumVersionIfNotDefault
public static void assertMinimumVersionIfNotDefault(boolean valueIsNotDefault, String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context)
Assert that the writer context's IIDM-XML version equals or is more recent than a given IIDM-XML version if the value of an attribute or the state of an equipment is not default (interpretable for previous versions). If not, throw an exception or log an error with a given type of error message, depending ofExportOptions.IidmVersionIncompatibilityBehavior
found in theExportOptions
of the given context.
-
assertMinimumVersionAndRunIfNotDefault
public static void assertMinimumVersionAndRunIfNotDefault(boolean valueIsNotDefault, String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlReaderContext context, IidmXmlUtil.IidmXmlRunnable runnable)
Assert that the reader context's IIDM-XML version equals or is more recent than a given IIDM-XML version if the value of an attribute or the state of an equipment is not default (interpretable for previous versions). If not, throw an exception with a given type of error message. If the value is not default and no exception has been thrown, run a given runnable.
-
assertMinimumVersionAndRunIfNotDefault
public static void assertMinimumVersionAndRunIfNotDefault(boolean valueIsNotDefault, String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context, IidmXmlUtil.IidmXmlRunnable runnable)
Assert that the writer context's IIDM-XML version equals or is more recent than a given IIDM-XML version if the value of an attribute or the state of an equipment is not default (interpretable for previous versions). If not, throw an exception or log an error with a given type of error message, depending ofExportOptions.IidmVersionIncompatibilityBehavior
found in theExportOptions
of the given context. If the value is not default and the version is compatible, run a given runnable.
-
assertStrictMaximumVersion
public static void assertStrictMaximumVersion(String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion maxVersion, NetworkXmlReaderContext context)
Assert that the reader context's IIDM-XML version is strictly older than a given IIDM-XML version. If not, throw an exception with a given type of error message.
-
assertStrictMaximumVersion
public static void assertStrictMaximumVersion(String rootElementName, String elementName, IidmXmlUtil.ErrorMessage type, IidmXmlVersion maxVersion, NetworkXmlWriterContext context)
Assert that the writer context's IIDM-XML version is strictly older than a given IIDM-XML version. If not, throw an exception or log an error with a given type of error message, depending ofExportOptions.IidmVersionIncompatibilityBehavior
found in theExportOptions
of the given context.
-
runFromMinimumVersion
public static <C extends AbstractNetworkXmlContext> void runFromMinimumVersion(IidmXmlVersion minVersion, C context, IidmXmlUtil.IidmXmlRunnable runnable)
Run a given runnable if the context's IIDM-XML version equals or is more recent than a given minimum IIDM-XML version.
-
runUntilMaximumVersion
public static <C extends AbstractNetworkXmlContext> void runUntilMaximumVersion(IidmXmlVersion maxVersion, C context, IidmXmlUtil.IidmXmlRunnable runnable)
Run a given runnable if the context's IIDM-XML version equals or is older than a given maximum IIDM-XML version.
-
writeBooleanAttributeFromMinimumVersion
public static void writeBooleanAttributeFromMinimumVersion(String rootElementName, String attributeName, boolean value, boolean defaultValue, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context)
Write a mandatory boolean attribute from a given minimum IIDM-XML version.
If the context's IIDM-XML version is strictly older than the given minimum IIDM-XML version, the attribute's value should be default (else an exception is thrown).
-
writeDoubleAttributeFromMinimumVersion
public static void writeDoubleAttributeFromMinimumVersion(String rootElementName, String attributeName, double value, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context)
Write a double attribute from a given minimum IIDM-XML version if its value is defined.
If the context's IIDM-XML version is strictly older than the given minimum IIDM-XML version, the attribute's value should be undefined i.e. NaN (else an exception is thrown).
-
writeDoubleAttributeFromMinimumVersion
public static void writeDoubleAttributeFromMinimumVersion(String rootElementName, String attributeName, double value, double defaultValue, IidmXmlUtil.ErrorMessage type, IidmXmlVersion minVersion, NetworkXmlWriterContext context)
Write a double attribute from a given minimum IIDM-XML version if its value is defined.
If the context's IIDM-XML version is strictly older than the given minimum IIDM-XML version, the attribute's value should be default (else an exception is thrown).
-
writeIntAttributeUntilMaximumVersion
public static void writeIntAttributeUntilMaximumVersion(String attributeName, int value, IidmXmlVersion maxVersion, NetworkXmlWriterContext context) throws XMLStreamException
Write a mandatory int attribute until a given maximum IIDM-XML version.
If the context's IIDM-XML version is strictly more recent than the given maximum IIDM-XML version, do nothing.- Throws:
XMLStreamException
-
sorted
public static <T extends Identifiable> Iterable<T> sorted(Iterable<T> identifiables, ExportOptions exportOptions)
Sort identifiables by their ids.
-
sorted
public static <T extends Identifiable<T>> Stream<T> sorted(Stream<T> stream, ExportOptions exportOptions)
Sort identifiables by their ids.
-
sortedExtensions
public static Iterable<? extends Extension<? extends Identifiable<?>>> sortedExtensions(Iterable<? extends Extension<? extends Identifiable<?>>> extensions, ExportOptions exportOptions)
Sort extensions by their names.
-
sortedTemporaryLimits
public static Iterable<LoadingLimits.TemporaryLimit> sortedTemporaryLimits(Iterable<LoadingLimits.TemporaryLimit> temporaryLimits, ExportOptions exportOptions)
Sort temporary limits by their names.
-
sortedInternalConnections
public static Iterable<VoltageLevel.NodeBreakerView.InternalConnection> sortedInternalConnections(Iterable<VoltageLevel.NodeBreakerView.InternalConnection> internalConnections, ExportOptions exportOptions)
Sort internal connections first by their side one node value then by their side 2 node value.
-
sortedNames
public static Iterable<String> sortedNames(Iterable<String> names, ExportOptions exportOptions)
Sort names.
-
-