public class MiscUtil extends Object
Constructor and Description |
---|
MiscUtil() |
Modifier and Type | Method and Description |
---|---|
static <T> void |
addAllIfNotPresent(List<T> receivingList,
List<T> supplyingList) |
static <T> void |
addIfNotPresent(List<T> receivingList,
T supplyingElement) |
static Boolean |
and(Boolean... operands)
n-ary and that ignores null values.
|
static Date |
asDate(int year,
int month,
int date,
int hrs,
int min,
int sec) |
static Date |
asDate(XMLGregorianCalendar xgc)
Converts an XMLGregorianCalendar to an instance of java.util.Date
|
static Long |
asLong(XMLGregorianCalendar xgc) |
static XMLGregorianCalendar |
asXMLGregorianCalendar(Date date)
Converts a java.util.Date into an instance of XMLGregorianCalendar
|
static XMLGregorianCalendar |
asXMLGregorianCalendar(Long timeInMilis) |
static String |
binaryToHex(byte[] bytes) |
static <T> void |
carthesian(Collection<Collection<T>> dimensions,
Processor<Collection<T>> processor) |
static <K,V> Map<K,V> |
cloneMap(Map<K,V> orig)
Shallow clone
|
static Integer |
compareNullLast(Object o1,
Object o2) |
static String |
concat(Collection<String> stringCollection) |
static <T> boolean |
contains(T element,
T[] array) |
static void |
copyDirectory(File src,
File dst)
Copy a directory and its contents.
|
static void |
copyFile(File sourceFile,
File destFile) |
static <T> Collection<T> |
createCollection(T... items) |
static <T> Collection<T> |
emptyIfNull(Collection<T> collection) |
static <T> List<T> |
emptyIfNull(List<T> list) |
static String |
emptyIfNull(String s) |
static boolean |
equals(Object a,
Object b) |
static <T> T |
extractSingleton(Collection<T> collection) |
static <T> Collection<T> |
filter(Collection<T> input,
Predicate<? super T> predicate) |
static <T> Set<T> |
filter(Set<T> input,
Predicate<? super T> predicate) |
static String |
formatExceptionMessageWithCause(Throwable t) |
static String |
formatExceptionMessageWithCause(Throwable t,
int indent) |
static String |
getClass(Object object) |
static <T> T |
getFirstNonNull(T... values) |
static String |
getFirstNonNullString(Object... values) |
static String |
getObjectName(Object o) |
static <T> T |
getSingleValue(Collection<T> values,
T defaultValue,
String contextDescription) |
static <T> Collection<T> |
getValuesFromDisplayableValues(Collection<? extends DisplayableValue<T>> disps) |
static String |
getValueWithClass(Object object) |
static <T> boolean |
hasDuplicates(Collection<T> collection)
Returns true if the collection contains at least one pair of equals elements.
|
static boolean |
hasNoValue(Collection<?> collection) |
static byte[] |
hexToBinary(String hex) |
static String |
hexToUtf8String(String hex) |
static <E> Function<Object,Stream<E>> |
instancesOf(Class<E> cls) |
static boolean |
isAllNull(Collection<?> collection) |
static boolean |
isBetween(XMLGregorianCalendar date,
XMLGregorianCalendar start,
XMLGregorianCalendar end) |
static boolean |
isCollectionOf(Object object,
Class<?> memberClass) |
static boolean |
isNoValue(Collection<?> collection) |
static <T> List<T> |
join(Collection<T> a,
Collection<T> b) |
static <T> T |
last(List<T> list) |
static <T> boolean |
listEquals(List<T> a,
List<T> b) |
static <V> Collection<V> |
nonNullValues(Collection<V> values) |
static boolean |
nullableCollectionsEqual(Collection<?> c1,
Collection<?> c2) |
static String |
nullIfEmpty(String s) |
static <K,V> Map<K,V> |
paramsToMap(Object[] params) |
static String |
readFile(File file) |
static String |
readZipFile(File file,
Charset charset) |
static <T> T |
runChecked(CheckedFunction<Producer<T>,T> function,
CheckedProducer<T> checkedProducer) |
static List<String> |
splitLines(String string) |
static <T> Stream<T> |
streamOf(Collection<T> collection) |
static String |
stripHtmlMarkup(String htmlString) |
static String |
takeThreadDump(Thread thread)
Thanks for this code go to https://crunchify.com/how-to-generate-java-thread-dump-programmatically/
|
static void |
throwExceptionAsUnchecked(Throwable t) |
static String |
toString(Object o) |
static URL |
toUrlUnchecked(URI uri) |
static <T> Collection<T> |
union(Collection<T>... sets) |
static <T> Collection<? extends T> |
unionExtends(Collection<? extends T>... sets) |
static <T> boolean |
unorderedArrayEquals(T[] a,
T[] b) |
static <T> boolean |
unorderedArrayEquals(T[] a,
T[] b,
Comparator<T> comparator)
Only zero vs non-zero value of comparator is important.
|
static <T> boolean |
unorderedCollectionCompare(Collection<T> a,
Collection<T> b,
Comparator<T> comparator)
Only zero vs non-zero value of comparator is important.
|
static <A,B> boolean |
unorderedCollectionEquals(Collection<A> a,
Collection<B> b,
HeteroComparator<A,B> comparator)
Only zero vs non-zero value of comparator is important.
|
static <T> boolean |
unorderedCollectionEquals(Collection<T> a,
Collection<T> b) |
static <T> int |
unorderedCollectionHashcode(Collection<T> collection,
Predicate<T> filter) |
static <T> T |
unwrapTunnelledException(TunnelException te) |
static void |
writeZipFile(File file,
String entryName,
String content,
Charset charset) |
@NotNull public static <T> Collection<T> union(Collection<T>... sets)
public static <T> Collection<? extends T> unionExtends(Collection<? extends T>... sets)
public static <T> boolean unorderedCollectionEquals(Collection<T> a, Collection<T> b)
public static <T> boolean unorderedCollectionCompare(Collection<T> a, Collection<T> b, Comparator<T> comparator)
public static <A,B> boolean unorderedCollectionEquals(Collection<A> a, Collection<B> b, HeteroComparator<A,B> comparator)
public static <T> boolean unorderedArrayEquals(T[] a, T[] b)
public static <T> boolean unorderedArrayEquals(T[] a, T[] b, Comparator<T> comparator)
public static <T> int unorderedCollectionHashcode(Collection<T> collection, Predicate<T> filter)
public static String readFile(File file) throws IOException
IOException
public static void copyFile(File sourceFile, File destFile) throws IOException
IOException
public static void copyDirectory(File src, File dst) throws IOException
src
- The name of the directory to copy.dst
- The name of the destination directory.IOException
- If the directory could not be copied.@SafeVarargs public static <T> Collection<T> createCollection(T... items)
public static XMLGregorianCalendar asXMLGregorianCalendar(Date date)
date
- Instance of java.util.Date or a null referencepublic static XMLGregorianCalendar asXMLGregorianCalendar(Long timeInMilis)
public static Date asDate(XMLGregorianCalendar xgc)
xgc
- Instance of XMLGregorianCalendar or a null referencepublic static Long asLong(XMLGregorianCalendar xgc)
public static Date asDate(int year, int month, int date, int hrs, int min, int sec)
public static <T> void carthesian(Collection<Collection<T>> dimensions, Processor<Collection<T>> processor)
public static String concat(Collection<String> stringCollection)
public static boolean isAllNull(Collection<?> collection)
public static boolean isNoValue(Collection<?> collection)
public static boolean hasNoValue(Collection<?> collection)
public static boolean isBetween(XMLGregorianCalendar date, XMLGregorianCalendar start, XMLGregorianCalendar end)
public static <T> boolean contains(T element, T[] array)
public static <T> Collection<T> getValuesFromDisplayableValues(Collection<? extends DisplayableValue<T>> disps)
public static String binaryToHex(byte[] bytes)
public static byte[] hexToBinary(String hex)
public static <T> void addAllIfNotPresent(List<T> receivingList, List<T> supplyingList)
public static <T> void addIfNotPresent(List<T> receivingList, T supplyingElement)
public static boolean nullableCollectionsEqual(Collection<?> c1, Collection<?> c2)
@SafeVarargs public static <T> T getFirstNonNull(T... values)
public static <T> T extractSingleton(Collection<T> collection)
public static <T> T getSingleValue(Collection<T> values, T defaultValue, String contextDescription)
public static <T> T last(List<T> list)
@NotNull public static <T> Collection<T> emptyIfNull(Collection<T> collection)
@NotNull public static <T> Stream<T> streamOf(Collection<T> collection)
public static <T> boolean hasDuplicates(Collection<T> collection)
public static String formatExceptionMessageWithCause(Throwable t, int indent)
public static void throwExceptionAsUnchecked(Throwable t)
public static <T> T runChecked(CheckedFunction<Producer<T>,T> function, CheckedProducer<T> checkedProducer) throws CommonException
CommonException
public static <T> T unwrapTunnelledException(TunnelException te) throws CommonException
CommonException
public static <T> Collection<T> filter(Collection<T> input, Predicate<? super T> predicate)
@NotNull public static <V> Collection<V> nonNullValues(@NotNull Collection<V> values)
public static <T> List<T> join(Collection<T> a, Collection<T> b)
public static String takeThreadDump(@Nullable Thread thread)
public static void writeZipFile(File file, String entryName, String content, Charset charset) throws IOException
IOException
public static String readZipFile(File file, Charset charset) throws IOException
IOException
Copyright © 2020 Evolveum. All rights reserved.