Skip to content

Commit

Permalink
Run Clean Up tool (#4568)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssoloff authored and RoiEXLab committed Jan 12, 2019
1 parent 3d573d2 commit 9e6f6d0
Show file tree
Hide file tree
Showing 21 changed files with 88 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,20 @@
class ErrorReportUploadAction implements BiConsumer<JFrame, UserErrorReport> {

static final BiConsumer<JFrame, UserErrorReport> OFFLINE_STRATEGY =
(frame, report) ->
DialogBuilder.builder()
.parent(frame)
.title("Unable to connect to server")
.errorMessage(
"TripleA is unable to get the servers network adddress, please restart "
+ "Triplea and try again, if this problem keeps happening please contact Triplea")
.showDialog();
(frame, report) -> DialogBuilder.builder()
.parent(frame)
.title("Unable to connect to server")
.errorMessage(
"TripleA is unable to get the servers network adddress, please restart "
+ "Triplea and try again, if this problem keeps happening please contact Triplea")
.showDialog();

@Nonnull
private final ServiceClient<ErrorReport, ErrorReportResponse> serviceClient;
@Nonnull
private final Consumer<URI> successConfirmation ;
private final Consumer<URI> successConfirmation;
@Nonnull
private final Consumer<ServiceResponse<ErrorReportResponse>> failureConfirmation ;
private final Consumer<ServiceResponse<ErrorReportResponse>> failureConfirmation;


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ final class DownloadLengthReader {
/**
* Gets the download length for the resource at the specified URI.
*
* <p>This method is thread safe.
* <p>
* This method is thread safe.
* </p>
*
* @param uri The resource URI; must not be {@code null}.
* @return The download length (in bytes) or empty if unknown; never {@code null}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ abstract class EditorPanel extends JPanel {

/**
* Checks if a combobox has an active item.
*
* @param comboBox The comboBox to check.
* @param label The label which should be used to indicate an invalid setup.
* @return True, if the combobox is valid, false otherwise.
Expand All @@ -37,6 +38,7 @@ boolean validateComboBox(final JComboBox<?> comboBox, final JLabel label) {

/**
* Turns the label red to indicate an error if valid is true.
*
* @param valid The parameter that decides if an error should be indicated.
* @param label The Label whose color should be changed.
* @return The value of valid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,41 @@
/**
* Server properties.
*
* <p>Generally there is one lobby server, but that server may move.
*
* <p>To keep track of this, we always have a properties file in a constant location that points to
* <p>
* Generally there is one lobby server, but that server may move.
* </p>
* <p>
* To keep track of this, we always have a properties file in a constant location that points to
* the current lobby server.
*
* <p>The properties file may indicate that the server is not available using the ERROR_MESSAGE key.
* </p>
* <p>
* The properties file may indicate that the server is not available using the ERROR_MESSAGE key.
* </p>
*/
@Builder
@Getter
@EqualsAndHashCode
public final class LobbyServerProperties {
/** The host address of the lobby, typically an IP address. */
@Nonnull private final String host;
@Nonnull
private final String host;

/** The port the lobby is listening on. */
@Nonnull private final Integer port;
@Nonnull
private final Integer port;

/** URI for the http lobby server. */
@Nonnull private final URI httpServerUri;
@Nonnull
private final URI httpServerUri;

@Nullable private final String serverErrorMessage;
@Nullable
private final String serverErrorMessage;

/**
* Message from lobby, eg: "welcome, lobby rules are: xyz".
*/
@Nullable private final String serverMessage;
@Nullable
private final String serverMessage;

public Optional<String> getServerMessage() {
return Optional.ofNullable(Strings.emptyToNull(serverMessage));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
@Log
public final class LobbyServerPropertiesFetcher {
private final Function<String, Optional<File>> fileDownloader;
@Nullable private LobbyServerProperties lobbyServerProperties;
@Nullable
private LobbyServerProperties lobbyServerProperties;


LobbyServerPropertiesFetcher(final Function<String, Optional<File>> fileDownloader) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ static IEmailSender newInstance(final String subjectPrefix, final String toAddre
"",
ClientSetting.emailServerHost.getValueOrThrow(),
ClientSetting.emailServerPort.getValueOrThrow(),
ClientSetting.emailServerSecurity.getValueOrThrow()
),
ClientSetting.emailServerSecurity.getValueOrThrow()),
Arrays.withSensitiveArrayAndReturn(ClientSetting.emailUsername::getValueOrThrow, String::new),
Arrays.withSensitiveArrayAndReturn(ClientSetting.emailPassword::getValueOrThrow, String::new),
subjectPrefix,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public boolean hasMessengers() {
public static boolean gameDataHasPlayByEmailOrForumMessengers(final GameData gameData) {
return gameData != null
&& (gameData.getProperties().get(IForumPoster.NAME) != null
|| gameData.getProperties().get(IEmailSender.SUBJECT) != null);
|| gameData.getProperties().get(IEmailSender.SUBJECT) != null);
}

public void setSaveGame(final File saveGameFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public interface IRemoteDiceServer {
String GAME_NAME = "DICE_SERVER_GAME_NAME";
String EMAIL_1 = "DICE_SERVER_EMAIL_1";
String EMAIL_2 = "DICE_SERVER_EMAIL_2";

/**
* Post a request to the dice server, and return the resulting html page as a string.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ private static boolean isLimitRocketDamageToProduction(final GameData data) {
}

/**
* Find Rocket Targets and load up fire rockets for later execution if necessary.
* Directly fired with Sequentially Targeted rockets.
* Find Rocket Targets and load up fire rockets for later execution if necessary.
* Directly fired with Sequentially Targeted rockets.
*/
private void findRocketTargetsAndFireIfNeeded(final IDelegateBridge bridge, final boolean fireRocketsImmediately) {
final GameData data = bridge.getData();
Expand Down Expand Up @@ -202,8 +202,8 @@ private void findRocketTargetsAndFireIfNeeded(final IDelegateBridge bridge, fina
}

/**
* Fire rockets which have been previously targetted (if any), or for Sequentially Targeted rockets target them too.
*/
* Fire rockets which have been previously targetted (if any), or for Sequentially Targeted rockets target them too.
*/
public void fireRockets(final IDelegateBridge bridge) {
if (needToFindRocketTargets) {
findRocketTargetsAndFireIfNeeded(bridge, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface SaveContext {
* @param gameSetting The game setting whose value is to be set.
* @param value The new setting value or {@code null} to clear the setting value.
*/
default <T> void setValue(GameSetting<T> gameSetting, @Nullable T value) {
default <T> void setValue(final GameSetting<T> gameSetting, final @Nullable T value) {
setValue(gameSetting, value, ValueSensitivity.INSENSITIVE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,9 @@ static SelectionComponent<JComponent> forumPosterSettings(
final ClientSetting<char[]> passwordSetting) {
return new AlwaysValidInputSelectionComponent() {

private JTextField usernameField = new JTextField(credentialToString(usernameSetting::getValue), 20);
private JPasswordField passwordField = new JPasswordField(credentialToString(passwordSetting::getValue), 20);
private final JTextField usernameField = new JTextField(credentialToString(usernameSetting::getValue), 20);
private final JPasswordField passwordField =
new JPasswordField(credentialToString(passwordSetting::getValue), 20);

private final JPanel mainPanel = JPanelBuilder.builder()
.verticalBoxLayout()
Expand Down
6 changes: 1 addition & 5 deletions game-core/src/main/java/swinglib/DialogBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,7 @@ public void showDialog() {
() -> {
final int result =
JOptionPane.showConfirmDialog(
withConfirmActionBuilder
.withMessageBuilder
.withTitleBuilder
.withParentBuilder
.parent,
withConfirmActionBuilder.withMessageBuilder.withTitleBuilder.withParentBuilder.parent,
withConfirmActionBuilder.withMessageBuilder.message,
withConfirmActionBuilder.withMessageBuilder.withTitleBuilder.title,
JOptionPane.YES_NO_OPTION,
Expand Down
4 changes: 2 additions & 2 deletions game-core/src/main/java/swinglib/JTextFieldBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public JTextField build() {

Optional.ofNullable(textEnteredAction)
.ifPresent(
action ->
DocumentListenerBuilder.attachDocumentListener(textField, () -> textEnteredAction.accept(textField)));
action -> DocumentListenerBuilder.attachDocumentListener(textField,
() -> textEnteredAction.accept(textField)));

Optional.ofNullable(maxLength)
.map(JTextFieldLimit::new)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class ErrorReportUploadActionTest {
@Mock
private ServiceClient<ErrorReport, ErrorReportResponse> serviceClient;
@Mock
private Consumer<URI> successConfirmation ;
private Consumer<URI> successConfirmation;
@Mock
private Consumer<ServiceResponse<ErrorReportResponse>> failureConfirmation ;
private Consumer<ServiceResponse<ErrorReportResponse>> failureConfirmation;

private ErrorReportUploadAction errorReportUploadAction;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ public class HttpClient<ClientTypeT, RequestT, ResponseT>
implements Function<RequestT, ServiceResponse<ResponseT>> {

private final Consumer<RequestT> rateLimiter = new RateLimiter<>();
@Nonnull private final Class<ClientTypeT> classType;
@Nonnull private final BiFunction<ClientTypeT, RequestT, ResponseT> sendFunction;
@Nonnull private final URI hostUri;
@Nonnull
private final Class<ClientTypeT> classType;
@Nonnull
private final BiFunction<ClientTypeT, RequestT, ResponseT> sendFunction;
@Nonnull
private final URI hostUri;

@Override
public ServiceResponse<ResponseT> apply(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
@EqualsAndHashCode
@Builder
public class ErrorReport {
@Nonnull private final String reportMessage;
@Nonnull private final String gameVersion;
@Nonnull private final String operatingSystem;
@Nonnull private final String javaVersion;
@Nonnull
private final String reportMessage;
@Nonnull
private final String gameVersion;
@Nonnull
private final String operatingSystem;
@Nonnull
private final String javaVersion;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CreateIssueResponse newIssue(


default CreateIssueResponse newIssue(
final IssueClientParams params ,
final IssueClientParams params,
final CreateIssueRequest createIssueRequest) {
final Map<String, Object> tokens = new HashMap<>();
tokens.put("Authorization", "token " + params.getAuthToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
@Builder
public class IssueClientParams {
/** Github Personal access token with repo permissions. */
@Nonnull private final String authToken;
@Nonnull
private final String authToken;
/** The name of the github org, used as part of URL. */
@Nonnull private final String githubOrg;
@Nonnull
private final String githubOrg;
/** The name of the github repo, used as part of URL. */
@Nonnull private final String githubRepo;
@Nonnull
private final String githubRepo;
/** URI of github web service API. */
@Nonnull private final URI uri;
@Nonnull
private final URI uri;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@Getter
@EqualsAndHashCode
public class ErrorReportRequest {
@Nonnull private final ErrorReport errorReport;
@Nonnull private final String clientIp;
@Nonnull
private final ErrorReport errorReport;
@Nonnull
private final String clientIp;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
/** Performs the steps for uploading an error report from the point of view of the server. */
@Builder
public class ErrorUploadStrategy implements Function<ErrorReportRequest, ErrorReportResponse> {
@Nonnull private final Function<ErrorReportRequest, CreateIssueRequest> requestAdapter;
@Nonnull
private final Function<ErrorReportRequest, CreateIssueRequest> requestAdapter;

@Nonnull
private final Function<ServiceResponse<CreateIssueResponse>, ErrorReportResponse> responseAdapter;

@Nonnull private final ServiceClient<CreateIssueRequest, CreateIssueResponse> createIssueClient;
@Nonnull private final Predicate<ErrorReportRequest> allowErrorReport;
@Nonnull
private final ServiceClient<CreateIssueRequest, CreateIssueResponse> createIssueClient;
@Nonnull
private final Predicate<ErrorReportRequest> allowErrorReport;

@Override
public ErrorReportResponse apply(final ErrorReportRequest errorReport) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
@AllArgsConstructor
public enum EnvironmentVariable {
PORT("3304"),

POSTGRES_USER("postgres"),

POSTGRES_PASSWORD("postgres"),

POSTGRES_HOST("localhost"),

POSTGRES_PORT("5432");

private final String defaultValue;
Expand Down

0 comments on commit 9e6f6d0

Please sign in to comment.