Class Utils
java.lang.Object
org.lfenergy.compas.sct.commons.util.Utils
- 
Method SummaryModifier and TypeMethodDescriptionstatic intblanksFirstComparator(String s1, String s2) Comparator for String Difference withCharSequence.compare(CharSequence, CharSequence)is that blank strings are considered equals and inferior to any not blank String.static <T> TcopySclElement(T object, Class<T> clazz) creates a copy of Scl elementstatic Stringentering()Generic messagestatic booleanequalsOrBothBlank(String s1, String s2) Checks if strings are equals or both blank.static <T,R> boolean equalsOrNotSet(T o1, T o2, Predicate<T> isSet, Function<T, R> getValue) Test if two fields with primitive values are equals or are both not set.static StringextractField(String s, String regexDelimiter, int index) Split string s using regexDelimiter into an array, and return element at given index.static Optional<AbstractLNAdapter<?>>getActiveLNodeSource(LDeviceAdapter lDeviceAdapter, LDEPFSettingData setting) provides Active LN Object that satisfies the LDEPF settings attributes (lnClass, lnInst, prefix)static Optional<LDeviceAdapter>getActiveSourceLDevice(IEDAdapter iedAdapter, LDEPFSettingData setting) provides Active LDevice for LDEPF setting's inst attributestatic booleanChecks if two ExtRefs fed by same Control Blockstatic booleanisIcdHeaderMatch(IEDAdapter iedAdapter, LDEPFSettingData setting) verify whether the IED satisfies the LDEPF settings for the private element `TCompasICDHeader`static booleanisValidDataTypeTemplate(AbstractLNAdapter<?> lnAdapter, LDEPFSettingData setting) verify whether the LN satisfies the LDEPF settings for Data Type Template elements.static Stringleaving()Generic message for leaving a methode callstatic StringGeneric message for leaving a methode call, its calculates CPU time taken by methode executionstatic booleanlnClassEquals(List<String> lnClass1, String lnClass2) Check if lnClass as List os the same as lnClass as a String.static StringlongToMacAddress(long macAddress) Converts long representation of a MAC-Address, by converting it to hexadecimal and separating every 2 characters by a hyphen(-).macAddressSequence(String startInclusive, String endInclusive) Create a new Iterator that provides all ordered MAC-Addresses value included in given range.static longmacAddressToLong(String macAddress) Converts a MAC-Address to its long representation, by concatenating the digits and converting it from hexadecimal to long.static StringRemove all digits at the end of the string, if anystatic PrimitiveIterator.OfLongsequence(long startInclusive, long endInclusive) Create a new Iterator that provides all ordered long value in the given rangestatic StringtoHex(long number, int length) Convert number to hexadecimal, with uppercase letters (A to F) and a minimum length (using left padding with zero when necessary).static StringxpathAttributeFilter(String name, String value) Builds stringstatic StringxpathAttributeFilter(String name, Collection<String> value) Builds string
- 
Method Details- 
enteringGeneric message- Returns:
- >>> Entering: :: + methode name
 
- 
leavingGeneric message for leaving a methode call, its calculates CPU time taken by methode execution- Parameters:
- startTime- methode call start time
- Returns:
- message with methode name and duration
 
- 
leavingGeneric message for leaving a methode call- Returns:
- >>> Entering: :: + methode name
 
- 
equalsOrNotSetTest if two fields with primitive values are equals or are both not set.- Parameters:
- o1- object to compare
- o2- object to compare
- isSet- predicate that returns if fields is set
- getValue- getter that return the unboxed field
- Returns:
- true if both fields are set and are equals, or if both fields are not set. False otherwise.
 
- 
xpathAttributeFilterBuilds string- Parameters:
- name- name to display
- value- value to display
- Returns:
- not (name) or name=value
 
- 
xpathAttributeFilterBuilds string- Parameters:
- name- name to display
- value- values to display
- Returns:
- not (name) or name=values
 
- 
equalsOrBothBlankChecks if strings are equals or both blank. Blank means : null, empty string or whitespaces (as defined byCharacter.isWhitespace(char)) only string.- Parameters:
- s1- first string
- s2- seconde string
- Returns:
- true if strings are equals or both blank, false otherwise
- See Also:
- 
- StringUtils.isBlank(CharSequence)
 
 
- 
blanksFirstComparatorComparator for String Difference withCharSequence.compare(CharSequence, CharSequence)is that blank strings are considered equals and inferior to any not blank String. Blank means : null, empty string or whitespaces (as defined byCharacter.isWhitespace(char)) only string. Note: this comparator imposes orderings that are inconsistent with equals.- Parameters:
- s1- first String to compare
- s2- second String to compare
- Returns:
- when s1 and s2 are not blank, same result as CharSequence.compare(CharSequence, CharSequence), zero when s1 and s2 are both blanks, negative integer when s1 is blank and s2 is not, positive integer when s1 is not blank but s2 is.
- See Also:
- 
- Comparator.compare(Object, Object)
- StringUtils.isBlank(CharSequence)
- Comparator.nullsFirst(Comparator)
 
 
- 
removeTrailingDigitsRemove all digits at the end of the string, if any- Parameters:
- s- input string
- Returns:
- s without digits at the end. Guarantees that the last character of the return value is not a digit. If s is composed only of digits, the result is an empty string
- See Also:
 
- 
extractFieldSplit string s using regexDelimiter into an array, and return element at given index.- Parameters:
- s- string to split
- regexDelimiter- delimiter
- index- index of the element in the split array (0 being the first element). If index is a negative integer, position is counted from the end (-1 behind the last element).
- Returns:
- the element at position index in the split array, or null if index is out of bound
- See Also:
 
- 
lnClassEqualsCheck if lnClass as List os the same as lnClass as a String. For some reason, xjc plugin generates a List<String> instead of a String for the lnClass attribute. When marshalling an XML file, lnClass is represented as a List with a single element.- Parameters:
- lnClass1- lnClass attribute value represented as a list
- lnClass2- lnClass attribute value represented as a String
- Returns:
- true if lnClass2 is blank and lnClass1 is either null, empty or contains a blank String.
         true if lnClass2 is not blank and lnClass1 contains lnClass2.
         false otherwise.
 Blank means : null, empty string or whitespaces (as defined by Character.isWhitespace(char)) only string.
- Throws:
- IllegalArgumentException- when lnClass1 contains more than one element
 
- 
sequenceCreate a new Iterator that provides all ordered long value in the given range- Parameters:
- startInclusive- the first long in the range (inclusive)
- endInclusive- the last long in the range (inclusive). Cannot exceed Long.MAX_VALUE - 1.
- Returns:
- new Iterator. When endInclusive < startInclusive, return an empty iterator.
 
- 
macAddressSequenceCreate a new Iterator that provides all ordered MAC-Addresses value included in given range. See macAddressToLong for the format of MAC-Addresses range, and see longToMacAddress for the format of MAC-Addresses output- Parameters:
- startInclusive- the first MAC-Address in the range (inclusive)
- endInclusive- the last MAC-Address in the range (inclusive)
- Returns:
- new Iterator
- See Also:
 
- 
longToMacAddressConverts long representation of a MAC-Address, by converting it to hexadecimal and separating every 2 characters by a hyphen(-). See macAddressToLong for the reversing method.- Parameters:
- macAddress- a long between 0 and 0xFFFFFFFFFFFF
- Returns:
- MAC address separated by hyphens(-). Letters are uppercase (A to F)
- See Also:
 
- 
macAddressToLongConverts a MAC-Address to its long representation, by concatenating the digits and converting it from hexadecimal to long. See longToMacAddress for the reversing method.- Parameters:
- macAddress- macAddress should be 6 groups of 2 hexadecimal digits (0 to 9 and A to F or a to f) separated by hyphens(–) or colons(:)
- Returns:
- long between 0 and 0xFFFFFFFFFFFF representing this MAC-Address
- See Also:
 
- 
toHexConvert number to hexadecimal, with uppercase letters (A to F) and a minimum length (using left padding with zero when necessary).- Parameters:
- number- number to be converted in hexadecimal
- length- minimum length of resulting string. When hexadecimal form of number does not reach length, left padding with "0" is done.
- Returns:
- hexadecimal, with uppercase letters (A to F) and minimum length of length. Note that the length of return value can exceed "length" parameter when number hexadecimal form is longer than "length" parameter.
 
- 
copySclElementcreates a copy of Scl element- Type Parameters:
- T- type of the object
- Parameters:
- object- object to copy
- clazz- class type of the object
- Returns:
- copy of the object
 
- 
isExtRefFeedBySameControlBlockChecks if two ExtRefs fed by same Control Block- Parameters:
- t1- extref to compare
- t2- extref to compare
- Returns:
- true if the two ExtRef are fed by same Control Block, otherwise false
 
- 
isIcdHeaderMatchverify whether the IED satisfies the LDEPF settings for the private element `TCompasICDHeader`
- 
getActiveSourceLDevicepublic static Optional<LDeviceAdapter> getActiveSourceLDevice(IEDAdapter iedAdapter, LDEPFSettingData setting) provides Active LDevice for LDEPF setting's inst attribute
- 
getActiveLNodeSourcepublic static Optional<AbstractLNAdapter<?>> getActiveLNodeSource(LDeviceAdapter lDeviceAdapter, LDEPFSettingData setting) provides Active LN Object that satisfies the LDEPF settings attributes (lnClass, lnInst, prefix)
- 
isValidDataTypeTemplatepublic static boolean isValidDataTypeTemplate(AbstractLNAdapter<?> lnAdapter, LDEPFSettingData setting) verify whether the LN satisfies the LDEPF settings for Data Type Template elements.
 
-