Class SystemUtil
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The major version number of the Java runtime (JRE), such as 8, 11, or 17. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
addWithoutDuplicates
(List<T> dest, List<? extends T> source) Deprecated.use CollectionsPlume.adjoinAllstatic <T> T[]
concatenate
(T[] array1, T... array2) Deprecated.use StringsPlume.concatenatestatic <T> T[]
concatenate
(T firstElt, T[] array, T lastElt) Deprecated.use PlumeUtil.concatstatic boolean
Deprecated.use UtilPlume.getBooleanSystemPropertystatic boolean
getBooleanSystemProperty
(String key, boolean defaultValue) Deprecated.use UtilPlume.getBooleanSystemPropertystatic int
Deprecated.use fieldjreVersion
insteadReturns the release value passed to the compiler or null if release was not passed.Returns the pathname to the tools.jar file, or null if it does not exist.static <T> List<T>
intersection
(List<? extends T> list1, List<? extends T> list2) Deprecated.use CollectionsPlume.listIntersectionstatic int
mapCapacity
(int numElements) Deprecated.use CollectionsPlume.mapCapacitystatic int
mapCapacity
(Collection<?> c) Deprecated.use CollectionsPlume.mapCapacitystatic int
mapCapacity
(Map<?, ?> m) Deprecated.use CollectionsPlume.mapCapacityDeprecated.use Files.readAllLinesstatic void
sleep
(long millis) Deprecated.use SystemPlume.sleepstatic <T> List<T>
Deprecated.use CollectionsPlume.listUnionstatic <T extends Comparable<T>>
List<T>withoutDuplicatesSorted
(List<T> values) Returns a list with the same contents as its argument, but sorted and without duplicates.
-
Field Details
-
jreVersion
public static final int jreVersionThe major version number of the Java runtime (JRE), such as 8, 11, or 17.
-
-
Method Details
-
getJreVersion
Deprecated.use fieldjreVersion
insteadReturns the major version number from the "java.version" system property, such as 8, 11, or 17.This is different from the version passed to the compiler via --release; use
getReleaseValue(ProcessingEnvironment)
to get that version.Extract the major version number from the "java.version" system property. Two possible formats are considered. Up to Java 8, from a version string like `1.8.whatever`, this method extracts 8. Since Java 9, from a version string like `11.0.1`, this method extracts 11.
Starting in Java 9, there is the int
Runtime.version().feature()
, but that does not exist on JDK 8.- Returns:
- the major version of the Java runtime
-
getReleaseValue
Returns the release value passed to the compiler or null if release was not passed.- Parameters:
env
- the ProcessingEnvironment- Returns:
- the release value or null if none was passed
-
getToolsJar
Returns the pathname to the tools.jar file, or null if it does not exist. Returns null on Java 9 and later.- Returns:
- the pathname to the tools.jar file, or null
-
union
Deprecated.use CollectionsPlume.listUnionReturns a list that contains all the distinct elements of the two lists: that is, the union of the two arguments.For very short lists, this is likely more efficient than creating a set and converting back to a list.
- Type Parameters:
T
- the type of the list elements- Parameters:
list1
- a listlist2
- a list- Returns:
- a list that contains all the distinct elements of the two lists
-
addWithoutDuplicates
Deprecated.use CollectionsPlume.adjoinAllAdds, to dest, all the elements of source that are not already in dest.For very short lists, this is likely more efficient than creating a set and converting back to a list.
- Type Parameters:
T
- the type of the list elements- Parameters:
dest
- a list to add tosource
- a list of elements to add
-
intersection
@Deprecated public static <T> List<T> intersection(List<? extends T> list1, List<? extends T> list2) Deprecated.use CollectionsPlume.listIntersectionReturns a list that contains all the elements that are in both lists: that is, the set difference of the two arguments.For very short lists, this is likely more efficient than creating a set and converting back to a list.
- Type Parameters:
T
- the type of the list elements- Parameters:
list1
- a listlist2
- a list- Returns:
- a list that contains all the elements of
list1
that are not inlist2
-
withoutDuplicatesSorted
Returns a list with the same contents as its argument, but sorted and without duplicates. May return its argument if its argument is sorted and has no duplicates, but is not guaranteed to do so. The argument is not modified.This is like
withoutDuplicates
, but requires the list elements to implementComparable
, and thus can be more efficient.- Type Parameters:
T
- the type of elements invalues
- Parameters:
values
- a list of values- Returns:
- the values, with duplicates removed
-
readFile
Deprecated.use Files.readAllLinesReturn a list of Strings, one per line of the file.- Parameters:
argFile
- argument file- Returns:
- a list of Strings, one per line of the file
- Throws:
IOException
- when reading the argFile
-
sleep
Deprecated.use SystemPlume.sleepLike Thread.sleep, but does not throw any exceptions, so it is easier for clients to use. Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds.- Parameters:
millis
- the length of time to sleep in milliseconds
-
concatenate
Deprecated.use PlumeUtil.concatConcatenates an element, an array, and an element.- Type Parameters:
T
- the type of the array elements- Parameters:
firstElt
- the first elementarray
- the arraylastElt
- the last elemeent- Returns:
- a new array containing first element, the array, and the last element, in that order
-
getBooleanSystemProperty
Deprecated.use UtilPlume.getBooleanSystemPropertyReturn true if the system property is set to "true". Return false if the system property is not set or is set to "false". Otherwise, errs.- Parameters:
key
- system property to check- Returns:
- true if the system property is set to "true". Return false if the system property is not set or is set to "false". Otherwise, errs.
-
getBooleanSystemProperty
Deprecated.use UtilPlume.getBooleanSystemPropertyReturn its boolean value if the system property is set. Return defaultValue if the system property is not set. Errs if the system property is set to a non-boolean value.- Parameters:
key
- system property to checkdefaultValue
- value to use if the property is not set- Returns:
- the boolean value of
key
ordefaultValue
ifkey
is not set
-
concatenate
Deprecated.use StringsPlume.concatenateConcatenates two arrays. Can be invoked varargs-style.- Type Parameters:
T
- the type of the array elements- Parameters:
array1
- the first arrayarray2
- the second array- Returns:
- a new array containing the contents of the given arrays, in order
-
mapCapacity
Deprecated.use CollectionsPlume.mapCapacityGiven an expected number of elements, returns the capacity that should be passed to a HashMap or HashSet constructor, so that the set or map will not resize.- Parameters:
numElements
- the maximum expected number of elements in the map or set- Returns:
- the initial capacity to pass to a HashMap or HashSet constructor
-
mapCapacity
Deprecated.use CollectionsPlume.mapCapacityGiven an expected number of elements, returns the capacity that should be passed to a HashMap or HashSet constructor, so that the set or map will not resize.- Parameters:
c
- a collection whose size is the maximum expected number of elements in the map or set- Returns:
- the initial capacity to pass to a HashMap or HashSet constructor
-
mapCapacity
Deprecated.use CollectionsPlume.mapCapacityGiven an expected number of elements, returns the capacity that should be passed to a HashMap or HashSet constructor, so that the set or map will not resize.- Parameters:
m
- a map whose size is the maximum expected number of elements in the map or set- Returns:
- the initial capacity to pass to a HashMap or HashSet constructor
-