public class SystemUtil extends Object
Constructor and Description |
---|
SystemUtil() |
Modifier and Type | Method and Description |
---|---|
static <T> void |
addWithoutDuplicates(List<T> dest,
List<? extends T> source)
Adds, to dest, all the elements of source that are not already in dest.
|
static <T> T[] |
concatenate(T[] array1,
T... array2)
Deprecated.
use StringsPlume.concatenate
|
static <T> T[] |
concatenate(T firstElt,
T[] array,
T lastElt)
Deprecated.
use PlumeUtil.concat
|
static boolean |
getBooleanSystemProperty(String key)
Deprecated.
use UtilPlume.getBooleanSystemProperty
|
static boolean |
getBooleanSystemProperty(String key,
boolean defaultValue)
Deprecated.
use UtilPlume.getBooleanSystemProperty
|
static int |
getJreVersion()
Returns the major JRE version.
|
static @Nullable String |
getReleaseValue(ProcessingEnvironment env)
Returns the release value passed to the compiler or null if release was not passed.
|
static @Nullable String |
getToolsJar()
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)
Returns a list that contains all the elements that are in both lists: that is, the set
difference of the two arguments.
|
static String |
join(CharSequence delimiter,
Iterable<?> values)
Deprecated.
use
StringsPlume.join |
static <T> String |
join(CharSequence delimiter,
T[] objs)
Deprecated.
use
StringsPlume.join |
static String |
joinLines(Iterable<? extends Object> v)
Deprecated.
use
StringsPlume.joinLines |
static <T> String |
joinLines(T... a)
Deprecated.
use
StringsPlume.joinLines |
static int |
mapCapacity(Collection<?> c)
Given 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.
|
static int |
mapCapacity(int numElements)
Given 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.
|
static int |
mapCapacity(Map<?,?> m)
Given 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.
|
static int |
mapCapacity(Set<?> s)
Given 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.
|
static List<String> |
readFile(File argFile)
Deprecated.
use Files.readAllLines
|
static void |
sleep(long millis)
Deprecated.
use SystemPlume.sleep
|
static <T> List<T> |
union(List<T> list1,
List<T> list2)
Returns a list that contains all the distinct elements of the two lists: that is, the union of
the two arguments.
|
@Deprecated public static boolean getBooleanSystemProperty(String key)
key
- system property to check@Deprecated public static boolean getBooleanSystemProperty(String key, boolean defaultValue)
key
- system property to checkdefaultValue
- value to use if the property is not setkey
or defaultValue
if key
is not setpublic static int getJreVersion()
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.
public static @Nullable String getReleaseValue(ProcessingEnvironment env)
env
- the ProcessingEnvironmentpublic static @Nullable String getToolsJar()
public static <T> List<T> union(List<T> list1, List<T> list2)
For very short lists, this is likely more efficient than creating a set and converting back to a list.
T
- the type of the list elementslist1
- a listlist2
- a listpublic static <T> void addWithoutDuplicates(List<T> dest, List<? extends T> source)
For very short lists, this is likely more efficient than creating a set and converting back to a list.
T
- the type of the list elementsdest
- a list to add tosource
- a list of elements to addpublic static <T> List<T> intersection(List<? extends T> list1, List<? extends T> list2)
For very short lists, this is likely more efficient than creating a set and converting back to a list.
T
- the type of the list elementslist1
- a listlist2
- a listlist1
that are not in list2
@Deprecated public static <T> T[] concatenate(T[] array1, T... array2)
T
- the type of the array elementsarray1
- the first arrayarray2
- the second arraypublic static int mapCapacity(int numElements)
numElements
- the maximum expected number of elements in the map or setpublic static int mapCapacity(Collection<?> c)
c
- a collection whose size is the maximum expected number of elements in the map or setpublic static int mapCapacity(Map<?,?> m)
m
- a map whose size is the maximum expected number of elements in the map or setpublic static int mapCapacity(Set<?> s)
s
- a set whose size is the maximum expected number of elements in the map or set@Deprecated public static List<String> readFile(File argFile) throws IOException
argFile
- argument fileIOException
- when reading the argFile@Deprecated public static <T> String join(CharSequence delimiter, T[] objs)
StringsPlume.join
T
- the type of array elementsdelimiter
- the delimiter that separates each elementobjs
- the values whose string representations to join together@Deprecated public static String join(CharSequence delimiter, Iterable<?> values)
StringsPlume.join
delimiter
- the delimiter that separates each elementvalues
- the values whose string representations to join together@Deprecated @SafeVarargs public static <T> String joinLines(T... a)
StringsPlume.joinLines
T
- the type of array elementsa
- array of values to concatenate@Deprecated public static String joinLines(Iterable<? extends Object> v)
StringsPlume.joinLines
v
- list of values to concatenate@Deprecated public static void sleep(long millis)
millis
- the length of time to sleep in milliseconds@Deprecated public static <T> T[] concatenate(T firstElt, T[] array, T lastElt)
T
- the type of the array elementsfirstElt
- the first elementarray
- the arraylastElt
- the last elemeent