Skip to content

Commit

Permalink
Refactor: Use Java record with @builder for League, Region and Team (…
Browse files Browse the repository at this point in the history
…hattrickdata)
  • Loading branch information
sgcr committed Sep 10, 2024
1 parent 0bde841 commit 8e04966
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/main/java/core/net/OnlineWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ private static Matchdetails downloadMatchDetails(int matchID, MatchType matchTyp
}
String arenaString = MyConnector.instance().downloadArena(details.getArenaID());
HOMainFrame.instance().setWaitInformation();
details.setRegionId(XMLArenaParser.parseArenaFromString(arenaString).getRight().getRegion().getId());
details.setRegionId(XMLArenaParser.parseArenaFromString(arenaString).getRight().getRegion().id());
} catch (Exception e) {
String msg = getLangString("Downloadfehler") + ": Error fetching Matchdetails XML.: ";
// Info
Expand Down
20 changes: 6 additions & 14 deletions src/main/java/hattrickdata/HattrickDataInfo.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
package hattrickdata;

import core.util.HODateTime;
import lombok.*;
import lombok.experimental.SuperBuilder;
import lombok.Builder;

@Getter
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
@ToString
public class HattrickDataInfo {

private String fileName;
private String version;
private int userId;
private HODateTime fetchedDate;
@Builder
public record HattrickDataInfo(String fileName,
String version,
int userId,
HODateTime fetchedDate) {
}
13 changes: 1 addition & 12 deletions src/main/java/hattrickdata/League.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
package hattrickdata;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

@Getter
@Builder
@AllArgsConstructor
@EqualsAndHashCode
@ToString
public class League {

private int id;
private String name;
public record League(int id, String name) {
}
13 changes: 1 addition & 12 deletions src/main/java/hattrickdata/Region.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
package hattrickdata;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

@Getter
@Builder
@AllArgsConstructor
@EqualsAndHashCode
@ToString
public class Region {

private int id;
private String name;
public record Region(int id, String name) {
}
13 changes: 1 addition & 12 deletions src/main/java/hattrickdata/Team.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
package hattrickdata;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

@Getter
@Builder
@AllArgsConstructor
@EqualsAndHashCode
@ToString
public class Team {

private int id;
private String name;
public record Team(int id, String name) {
}

0 comments on commit 8e04966

Please sign in to comment.