use Lombok
This commit is contained in:
16
build.gradle
16
build.gradle
@@ -9,3 +9,19 @@ if (publishScript.exists()) {
|
|||||||
|
|
||||||
project.group = projectGroup
|
project.group = projectGroup
|
||||||
project.version = projectVersion
|
project.version = projectVersion
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
libs = [
|
||||||
|
lombok: 'org.projectlombok:lombok:1.18.12'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly libs.lombok
|
||||||
|
annotationProcessor libs.lombok
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package ghast;
|
package ghast;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -10,14 +12,11 @@ import java.nio.file.Path;
|
|||||||
|
|
||||||
import static java.text.MessageFormat.format;
|
import static java.text.MessageFormat.format;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class AssetsManager {
|
public class AssetsManager {
|
||||||
|
|
||||||
private AssetsManager() {
|
public void saveTo(String resourceName, Path targetPath) {
|
||||||
// this is utility class
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void saveTo(String resourceName, Path targetPath) {
|
|
||||||
URL resourceUrl = AssetsManager.class.getClassLoader().getResource(resourceName);
|
URL resourceUrl = AssetsManager.class.getClassLoader().getResource(resourceName);
|
||||||
if (resourceUrl == null) {
|
if (resourceUrl == null) {
|
||||||
throw new AssetsException(format("Asset \"{0}\" not found", resourceName));
|
throw new AssetsException(format("Asset \"{0}\" not found", resourceName));
|
||||||
@@ -28,7 +27,7 @@ public final class AssetsManager {
|
|||||||
|
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
int count;
|
int count;
|
||||||
while((count = inputStream.read(buffer)) != -1) {
|
while ((count = inputStream.read(buffer)) != -1) {
|
||||||
outputStream.write(buffer, 0, count);
|
outputStream.write(buffer, 0, count);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -36,7 +35,7 @@ public final class AssetsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveTo(String resourceName, File targetPath) {
|
public void saveTo(String resourceName, File targetPath) {
|
||||||
saveTo(resourceName, targetPath.toPath());
|
saveTo(resourceName, targetPath.toPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user