io.github.nichetoolkit.rest.helper.CloseableHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-toolkit-utils Show documentation
Show all versions of rest-toolkit-utils Show documentation
Rest toolkit utils project for Spring Boot
package io.github.nichetoolkit.rest.helper;
import io.github.nichetoolkit.rest.util.GeneralUtils;
import lombok.extern.slf4j.Slf4j;
import java.io.Closeable;
import java.io.IOException;
/**
* CloseableHelper
* @author Cyan ([email protected])
* @version v1.0.0
*/
@Slf4j
public class CloseableHelper {
public static void close(Closeable... closeables) {
if (GeneralUtils.isNotEmpty(closeables)) {
for (Closeable closeable : closeables) {
close(closeable);
}
}
}
public static void close(Closeable closeable) {
if (GeneralUtils.isNotEmpty(closeable)) {
try {
closeable.close();
} catch (IOException ignored) {
}
}
}
public static void interrupt(Thread... threads) {
if (GeneralUtils.isNotEmpty(threads)) {
for (Thread thread : threads) {
if (thread != null) {
if (thread.isAlive()) {
thread.interrupt();
}
}
}
}
}
}