From d67d40640d89d1a3b895210be8cdb783c5ff23af Mon Sep 17 00:00:00 2001 From: Andrei Rybak Date: Wed, 13 Apr 2022 16:46:20 +0200 Subject: [PATCH] WindowPosition: turn into a record class Because class WindowPosition has only final fields, it can be converted into a record class. Do it automatically, via IntelliJ IDEA's inspection. Note, that it is possible, because Gson isn't used for its serialization -- WindowPosition instances are stored and loaded to and from file via custom `save` and `read` methods. --- .../dev/andrybak/resoday/gui/WindowPosition.java | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/main/java/dev/andrybak/resoday/gui/WindowPosition.java b/src/main/java/dev/andrybak/resoday/gui/WindowPosition.java index 477ef5a..304392d 100644 --- a/src/main/java/dev/andrybak/resoday/gui/WindowPosition.java +++ b/src/main/java/dev/andrybak/resoday/gui/WindowPosition.java @@ -16,22 +16,10 @@ import static java.util.stream.Collectors.toList; -public final class WindowPosition { +public record WindowPosition(int width, int height, int x, int y) { private static final Path WINDOW_POSITION_FILE = Paths.get("window-position.txt"); private static final Pattern PLAIN_POSITIVE_INTEGER_PATTERN = Pattern.compile("^\\d{1,10}$"); - private final int width; - private final int height; - private final int x; - private final int y; - - private WindowPosition(int width, int height, int x, int y) { - this.x = x; - this.y = y; - this.height = height; - this.width = width; - } - public static WindowPosition from(Window w) { return new WindowPosition(w.getWidth(), w.getHeight(), w.getX(), w.getY()); }