Skip to content

Commit

Permalink
WindowPosition: turn into a record class
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rybak committed Apr 13, 2022
1 parent 5390718 commit d67d406
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/main/java/dev/andrybak/resoday/gui/WindowPosition.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit d67d406

Please sign in to comment.