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
The newest version!
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
* The closeable helper class.
* @author Cyan ([email protected])
* @see lombok.extern.slf4j.Slf4j
* @since Jdk1.8
*/
@Slf4j
public class CloseableHelper {
/**
* close
* The close method.
* @param close {@link java.io.Closeable} The close parameter is Closeable
type.
* @see java.io.Closeable
*/
public static void close(Closeable... close) {
if (GeneralUtils.isNotEmpty(close)) {
for (Closeable closeable : close) {
close(closeable);
}
}
}
/**
* close
* The close method.
* @param closeable {@link java.io.Closeable} The closeable parameter is Closeable
type.
* @see java.io.Closeable
*/
public static void close(Closeable closeable) {
if (GeneralUtils.isNotEmpty(closeable)) {
try {
closeable.close();
} catch (IOException ignored) {
}
}
}
/**
* interrupt
* The interrupt method.
* @param threads {@link java.lang.Thread} The threads parameter is Thread
type.
* @see java.lang.Thread
*/
public static void interrupt(Thread... threads) {
if (GeneralUtils.isNotEmpty(threads)) {
for (Thread thread : threads) {
if (thread != null) {
if (thread.isAlive()) {
thread.interrupt();
}
}
}
}
}
}