java.lang.Object
com.github.hypfvieh.util.TypeUtil
Class providing a set of methods for converting and/or checking of various data types.
- Autor:
- hypfvieh
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic <T> List<T> createList(T... _entries) Creates a list from a varargs parameter array.static <T> Map<T, T> createMap(T... _args) Creates a map from the even-sized parameter array.static PropertiescreateProperties(String... _keysAndVals) Factory method forPropertiesfrom an even-sized String array.static PatterncreateRegExPatternIfValid(String _regExStr) Creates a RegEx Pattern object, if given String is a valid regular expression.static intdefaultIfNotInteger(String _possibleInt, int _default) Returns integer converted from string or default if string could not be converted to int.static <T> TdefaultIfNull(T _val, T _default) Returns the default if value is null or value if value is not null.static booleanVeraltet.static intindexOfByteArray(byte[] _heyStackArray, byte[] _needleArray) Retrieves the position of a byte array in another byte array.static booleanVeraltet.static booleanChecks if the given string is a valid double (including negative values).static booleanChecks if the given string is a valid double.static booleanChecks if the given string is a valid double (including negative values) using the given separator.static booleanChecks if the given string is a valid double.static booleanCheck if string is integer (including negative integers).static booleanCheck if string is an either positive or negative integer.static booleanisValidNetworkPort(int _port, boolean _allowWellKnown) Check if the given value is a valid network port (1 - 65535).static booleanisValidNetworkPort(String _str, boolean _allowWellKnown) static booleanisValidRegex(String _regExStr) Checks if given String is a valid regular expression.Split a List into equal parts.splitListToSubLists(List<T> _list, int _listCount) Splits a given list to _listCount subLists.Splits _map to a list of maps where each map has _nbElements.static booleanVeraltet, zur Entfernung: Dieses API-Element wird in einer zukünftigen Version entfernt.static voidthrowIfAnyNull(String _errMsg, Object... _objects) Veraltet.
-
Methodendetails
-
strToBool
Veraltet, zur Entfernung: Dieses API-Element wird in einer zukünftigen Version entfernt.Returns true if string matches certain boolean values.- Parameter:
_str- string to validate- Gibt zurück:
- true if string represents a true (like 'yes','ja',1) value, false otherwise
-
isDouble
Checks if the given string is a valid double (including negative values). Separator is based on the used locale.- Parameter:
_str- string to check- Gibt zurück:
- true if valid double, false otherwise
-
isDouble
Checks if the given string is a valid double (including negative values) using the given separator.- Parameter:
_str- string to check_separator- separator to use- Gibt zurück:
- true if valid double, false otherwise
-
isDouble
Checks if the given string is a valid double. The used separator is based on the used system locale- Parameter:
_str- string to validate_allowNegative- set to true if negative double should be allowed- Gibt zurück:
- true if given string is double, false otherwise
-
isDouble
Checks if the given string is a valid double.- Parameter:
_str- string to validate_separator- seperator used (e.g. "." (dot) or "," (comma))_allowNegative- set to true if negative double should be allowed- Gibt zurück:
- true if given string is double, false otherwise
-
isInteger
Check if string is integer (including negative integers).- Parameter:
_str- string to check- Gibt zurück:
- true if integer (positive or negative), false otherwise
-
isInteger
Check if string is an either positive or negative integer.- Parameter:
_str- string to validate_allowNegative- negative integer allowed- Gibt zurück:
- true if integer, false otherwise
-
isValidNetworkPort
public static boolean isValidNetworkPort(int _port, boolean _allowWellKnown) Check if the given value is a valid network port (1 - 65535).- Parameter:
_port- 'port' to check_allowWellKnown- allow ports below 1024 (aka reserved well known ports)- Gibt zurück:
- true if int is a valid network port, false otherwise
-
isValidNetworkPort
- Parameter:
_str- string to check_allowWellKnown- allow well known port- Gibt zurück:
- true if valid port, false otherwise
- Siehe auch:
-
isValidRegex
Checks if given String is a valid regular expression.- Parameter:
_regExStr- regex string to check- Gibt zurück:
- true if given string is valid regex, false otherwise
-
createRegExPatternIfValid
Creates a RegEx Pattern object, if given String is a valid regular expression.- Parameter:
_regExStr- regex string to check- Gibt zurück:
- Pattern-Object or null if given String is no valid RegEx
-
createList
Creates a list from a varargs parameter array. The generic list is created with the same type as the parameters.- Typparameter:
T- list type- Parameter:
_entries- list entries- Gibt zurück:
- list
-
createMap
Creates a map from the even-sized parameter array.- Typparameter:
T- map type- Parameter:
_args- parameter array, any type- Gibt zurück:
- map of parameter type
-
isAnyNull
Veraltet.Checks if any of the passed in objects is null.- Parameter:
_objects- array of objects, may be null- Gibt zurück:
- true if null found, false otherwise
-
throwIfAnyNull
Veraltet.- Parameter:
_errMsg- error message_objects- objects to check- Siehe auch:
-
equalsOne
Veraltet.Returns true if the specified object equals at least one of the specified other objects.- Parameter:
_obj- object_arrObj- array of objects to compare to- Gibt zurück:
- true if equal, false otherwise or if either parameter is null
-
splitMap
public static <K,V> List<Map<K,V>> splitMap(Map<K, V> _map, int _nbElements) throws InstantiationException, IllegalAccessExceptionSplits _map to a list of maps where each map has _nbElements. Last map in list maybe shorter if _map.size() is not divideable by _nElements.- Typparameter:
K- key typeV- value type- Parameter:
_map- map to split_nbElements- elements per map- Gibt zurück:
- List of Maps
- Löst aus:
IllegalAccessException- on errorInstantiationException- on error
-
splitList
Split a List into equal parts. Last list could be shorter than _elements.- Typparameter:
T- type- Parameter:
_list- list to split_elements- elements per list- Gibt zurück:
- list of lists
-
splitListToSubLists
Splits a given list to _listCount subLists. Last list maybe shorter or longer than all previous list (depending on _list size).- Parameter:
_list- list to split_listCount- sublists to create- Gibt zurück:
- List of Lists, null if _list was null, empty list if _list was empty
-
createProperties
Factory method forPropertiesfrom an even-sized String array.- Parameter:
_keysAndVals- String array of keys and values, may be null or even-numbered String array- Gibt zurück:
- new Properties object
-
defaultIfNotInteger
Returns integer converted from string or default if string could not be converted to int.- Parameter:
_possibleInt- string to convert_default- default to use if string cannot be converted- Gibt zurück:
- int
-
defaultIfNull
public static <T> T defaultIfNull(T _val, T _default) Returns the default if value is null or value if value is not null.- Typparameter:
T- type to check/return- Parameter:
_val- value to check fornull_default- default to use when value is null- Gibt zurück:
- value or default
- Seit:
- 1.2.1 - 2022-05-19
-
indexOfByteArray
public static int indexOfByteArray(byte[] _heyStackArray, byte[] _needleArray) Retrieves the position of a byte array in another byte array.- Parameter:
_heyStackArray- array to search_needleArray- array to find- Gibt zurück:
- position of found array or -1 if not found
- Seit:
- 1.2.1 - 2024-03-21
-
CompareUtil.equalsOne(Object, Object...)