From 2c576a3a04d97a76fbaa56cdcc4328c31a5c1946 Mon Sep 17 00:00:00 2001 From: Eric Mays Date: Sun, 11 Jan 2026 17:39:31 -0500 Subject: [PATCH 1/3] Add round method and lines from resource --- .classpath | 6 ++++-- pom.xml | 2 +- src/main/java/com/mays/util/MathUtil.java | 15 +++++++++++++++ src/main/java/com/mays/util/Util.java | 11 ++++++++++- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/mays/util/MathUtil.java diff --git a/.classpath b/.classpath index f2cab10..7f54482 100644 --- a/.classpath +++ b/.classpath @@ -14,20 +14,21 @@ + - - + + @@ -36,5 +37,6 @@ + diff --git a/pom.xml b/pom.xml index 80164cb..c3e6c2f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.github.emays parent - 0.0.7 + 0.0.8-SNAPSHOT diff --git a/src/main/java/com/mays/util/MathUtil.java b/src/main/java/com/mays/util/MathUtil.java new file mode 100644 index 0000000..e0f08a0 --- /dev/null +++ b/src/main/java/com/mays/util/MathUtil.java @@ -0,0 +1,15 @@ +package com.mays.util; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +public class MathUtil { + + private MathUtil() { + } + + public static BigDecimal round(double value, int scale) { + return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP); + } + +} diff --git a/src/main/java/com/mays/util/Util.java b/src/main/java/com/mays/util/Util.java index 11aad84..ece50f1 100644 --- a/src/main/java/com/mays/util/Util.java +++ b/src/main/java/com/mays/util/Util.java @@ -1,6 +1,9 @@ package com.mays.util; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.Path; @@ -23,7 +26,7 @@ public static PrintWriter newPrintWriter(Path path) throws IOException { return new PrintWriter(Files.newBufferedWriter(path)); } - public static void trFile(String fr, String to, String in_file, String out_file) throws IOException { + public static void trFile(String fr, String to, String in_file, String out_file) throws IOException { Stream lines = Files.lines(Paths.get(in_file)).map(line -> line.replace(fr, to)); Files.write(Paths.get(out_file), iterable(lines)); } @@ -45,6 +48,12 @@ public static Iterable lines(Path path) throws IOException { return iterable(Files.lines(path)); } + public static Stream getResourceLines(String resource) { + InputStream stream = Util.class.getResourceAsStream(resource); + BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); + return reader.lines(); + } + public static String tabDelimitedString(List fields) { return delimitedString("\t", fields); } From c2275172c33ef73ef31a423f4d6d67f0762201e8 Mon Sep 17 00:00:00 2001 From: Eric Mays Date: Fri, 30 Jan 2026 17:41:57 -0500 Subject: [PATCH 2/3] Throw exception in getResourceLines when resource not found --- .classpath | 1 - src/main/java/com/mays/util/Util.java | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.classpath b/.classpath index 7f54482..8252b41 100644 --- a/.classpath +++ b/.classpath @@ -28,7 +28,6 @@ - diff --git a/src/main/java/com/mays/util/Util.java b/src/main/java/com/mays/util/Util.java index ece50f1..6dca70f 100644 --- a/src/main/java/com/mays/util/Util.java +++ b/src/main/java/com/mays/util/Util.java @@ -1,6 +1,7 @@ package com.mays.util; import java.io.BufferedReader; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -48,8 +49,10 @@ public static Iterable lines(Path path) throws IOException { return iterable(Files.lines(path)); } - public static Stream getResourceLines(String resource) { + public static Stream getResourceLines(String resource) throws FileNotFoundException { InputStream stream = Util.class.getResourceAsStream(resource); + if (stream == null) + throw new FileNotFoundException(resource); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); return reader.lines(); } From ba585c5419e11eb3a0ab4a7fdef139f740240a4e Mon Sep 17 00:00:00 2001 From: Eric Mays Date: Sun, 1 Feb 2026 14:43:45 -0500 Subject: [PATCH 3/3] Update parent to release version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c3e6c2f..ebabb23 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.github.emays parent - 0.0.8-SNAPSHOT + 0.0.8