Skip to content

Commit

Permalink
Add builders
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackYps committed Nov 27, 2023
1 parent 725114d commit 8b78481
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,69 @@
package com.faforever.client.builders;

import com.faforever.client.domain.LeagueScoreJournalBean;
import com.faforever.client.domain.LeagueSeasonBean;
import com.faforever.client.domain.SubdivisionBean;

public class LeagueScoreJournalBeanBuilder {
public static LeagueScoreJournalBeanBuilder create() {
return new LeagueScoreJournalBeanBuilder();
}

private final LeagueScoreJournalBean leagueScoreJournalBean = new LeagueScoreJournalBean();

public LeagueScoreJournalBeanBuilder defaultValues() {
gameId(1);
loginId(100);
gameCount(11);
scoreBefore(5);
scoreAfter(6);
season(LeagueSeasonBeanBuilder.create().defaultValues().get());
divisionBefore(SubdivisionBeanBuilder.create().defaultValues().get());
divisionAfter(SubdivisionBeanBuilder.create().defaultValues().get());
return this;
}

public LeagueScoreJournalBeanBuilder gameId(int gameId) {
leagueScoreJournalBean.setGameId(gameId);
return this;
}

public LeagueScoreJournalBeanBuilder loginId(int loginId) {
leagueScoreJournalBean.setLoginId(loginId);
return this;
}

public LeagueScoreJournalBeanBuilder gameCount(int gameCount) {
leagueScoreJournalBean.setGameCount(gameCount);
return this;
}

public LeagueScoreJournalBeanBuilder scoreBefore(int scoreBefore) {
leagueScoreJournalBean.setScoreBefore(scoreBefore);
return this;
}

public LeagueScoreJournalBeanBuilder scoreAfter(int scoreAfter) {
leagueScoreJournalBean.setScoreAfter(scoreAfter);
return this;
}

public LeagueScoreJournalBeanBuilder season(LeagueSeasonBean season) {
leagueScoreJournalBean.setSeason(season);
return this;
}

public LeagueScoreJournalBeanBuilder divisionBefore(SubdivisionBean divisionBefore) {
leagueScoreJournalBean.setDivisionBefore(divisionBefore);
return this;
}

public LeagueScoreJournalBeanBuilder divisionAfter(SubdivisionBean divisionAfter) {
leagueScoreJournalBean.setDivisionAfter(divisionAfter);
return this;
}

public LeagueScoreJournalBean get() {
return leagueScoreJournalBean;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.faforever.client.builders;

import com.faforever.client.domain.LeagueScoreJournalBean;

import java.util.ArrayList;
import java.util.List;

public class LeagueScoresListBuilder {
private final List<LeagueScoreJournalBean> leagueScores = new ArrayList<>();

public static LeagueScoresListBuilder create() {
return new LeagueScoresListBuilder();
}

public LeagueScoresListBuilder defaultValues() {
append(LeagueScoreJournalBeanBuilder.create().defaultValues().get());
return this;
}

public LeagueScoresListBuilder append(LeagueScoreJournalBean leagueScore) {
leagueScores.add(leagueScore);
return this;
}

public LeagueScoresListBuilder replace(List<LeagueScoreJournalBean> leagueScore) {
this.leagueScores.clear();
this.leagueScores.addAll(leagueScore);
return this;
}

public List<LeagueScoreJournalBean> get() {
return leagueScores;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.faforever.client.domain.FeaturedModBean;
import com.faforever.client.domain.GamePlayerStatsBean;
import com.faforever.client.domain.LeagueScoreJournalBean;
import com.faforever.client.domain.MapVersionBean;
import com.faforever.client.domain.PlayerBean;
import com.faforever.client.domain.ReplayBean;
Expand Down Expand Up @@ -36,6 +37,7 @@ public ReplayBeanBuilder defaultValues() {
chatMessages(ReplayChatMessageListBuilder.create().defaultValues().get());
teamPlayerStats(PlayerStatsMapBuilder.create().defaultValues().get());
gameOptions(GameOptionListBuilder.create().defaultValues().get());
leagueScores(LeagueScoresListBuilder.create().defaultValues().get());
return this;
}

Expand Down Expand Up @@ -128,6 +130,11 @@ public ReplayBeanBuilder local(boolean local) {
replayBean.setLocal(local);
return this;
}

public ReplayBeanBuilder leagueScores(List<LeagueScoreJournalBean> leagueScores) {
replayBean.setLeagueScores(leagueScores);
return this;
}

public ReplayBean get() {
return replayBean;
Expand Down

0 comments on commit 8b78481

Please sign in to comment.