Skip to content

Commit

Permalink
Refactoring. Use records, move field to constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ullenius committed Jul 20, 2023
1 parent c7faf34 commit 302d56f
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/main/java/se/anosh/spctag/dao/Xid6Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ final class Xid6Reader {
mappningar.put((byte) 0x36, new Id(Xid6Tag.MIXING, Type.NUMBER));
}

private final Path filename;
private Xid6 xid6 = null;

final BiConsumer<Id, byte[]> year = (id, data) -> xid6.setYear( (data[0] & 0xFF | data[1] << 8 & 0xFF00)); // little endian uint16
Expand Down Expand Up @@ -97,8 +96,8 @@ private void setData(final Xid6Tag tag, final byte b) {
);

Xid6Reader(String filename) throws IOException {
this.filename = Paths.get(filename);
parseXid6(this.filename);
Path filename1 = Paths.get(filename);
parseXid6(filename1);
}

private void parseXid6(Path spc) throws IOException {
Expand Down Expand Up @@ -260,22 +259,15 @@ private static class ChunkHeader {
}
}

private static final class Id {
Id(Xid6Tag tag, Type type) {
this.tag = tag;
this.type = type;
}

final Xid6Tag tag;
final Type type;
private record Id(Xid6Tag tag, Type type) {

@Override
public String toString() {
return "Id{" +
"name='" + tag + '\'' +
", type=" + type +
'}';
public String toString() {
return "Id{" +
"name='" + tag + '\'' +
", type=" + type +
'}';
}
}
}

}

0 comments on commit 302d56f

Please sign in to comment.