Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
dprzybyl committed Nov 2, 2023
1 parent 0653f43 commit bc690c0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package com.cognifide.apm.core.actions;

import static java.lang.String.format;

import com.cognifide.apm.api.actions.ActionResult;
import com.cognifide.apm.api.actions.Message;
import com.cognifide.apm.api.status.Status;
Expand Down Expand Up @@ -123,7 +121,7 @@ private static String checkCommonAuthorizable(List<ActionResult> actionResults)
for (ActionResult actionResult : actionResults) {
String current = actionResult.getAuthorizable();
if (current != null && !StringUtils.equals(current, pattern)) {
String error = format("Cannot create CompositeActionResult, mismatch of authorizables. Found: %s Expected: %s",
String error = String.format("Cannot create CompositeActionResult, mismatch of authorizables. Found: %s Expected: %s",
actionResult.getAuthorizable(), pattern);
throw new IllegalArgumentException(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@

package com.cognifide.apm.core.actions;

import static java.util.Collections.singletonList;

import com.cognifide.apm.api.actions.annotations.Flag;
import com.cognifide.apm.api.actions.annotations.Named;
import com.cognifide.apm.api.actions.annotations.Required;
import com.cognifide.apm.core.crypto.DecryptionService;
import com.cognifide.apm.core.grammar.ApmType;
import com.cognifide.apm.core.grammar.argument.Arguments;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -62,7 +61,7 @@ public static class RequiredParameterDescriptor extends ParameterDescriptor {
public RequiredParameterDescriptor(Class<? extends ApmType> type, int index, Required required) {
super(type);
this.index = index;
this.argumentDescriptions = singletonList(new ArgumentDescription(
this.argumentDescriptions = Collections.singletonList(new ArgumentDescription(
required != null ? required.value() : "(" + index + ")",
"required",
required != null ? required.description() : ""
Expand Down Expand Up @@ -101,7 +100,7 @@ public static class NamedParameterDescriptor extends ParameterDescriptor {
public NamedParameterDescriptor(Class<? extends ApmType> type, Named named) {
super(type);
this.name = named.value();
this.argumentDescriptions = singletonList(new ArgumentDescription(
this.argumentDescriptions = Collections.singletonList(new ArgumentDescription(
name, "named", named.description()
));
}
Expand Down Expand Up @@ -168,7 +167,7 @@ public static class FlagParameterDescriptor extends ParameterDescriptor {

public FlagParameterDescriptor(Class<? extends ApmType> type, Flag flag) {
super(type);
this.argumentDescriptions = singletonList(new ArgumentDescription(flag.value(), "flag", flag.description()));
this.argumentDescriptions = Collections.singletonList(new ArgumentDescription(flag.value(), "flag", flag.description()));
this.flag = flag.value();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
*/
package com.cognifide.apm.core.logger;

import static org.apache.commons.lang3.StringUtils.defaultString;

import com.cognifide.apm.api.services.ExecutionResult.Entry;
import com.cognifide.apm.api.status.Status;
import com.google.common.collect.ImmutableList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang3.StringUtils;

public class ProgressEntry implements Entry {

Expand All @@ -44,11 +43,11 @@ public class ProgressEntry implements Entry {
public ProgressEntry(Status status, List<String> messages, String command, String authorizable,
List<String> parameters, Position position) {
this.status = status != null ? status : Status.SUCCESS;
this.command = defaultString(command);
this.command = StringUtils.defaultString(command);
this.position = position;
this.messages = messages != null ? ImmutableList.copyOf(messages) : Collections.emptyList();
this.parameters = parameters != null ? ImmutableList.copyOf(parameters) : Collections.emptyList();
this.authorizable = defaultString(authorizable);
this.authorizable = StringUtils.defaultString(authorizable);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
*/
package com.cognifide.apm.core.progress;

import static java.lang.String.format;
import static java.util.Collections.singletonList;

import com.cognifide.apm.api.actions.ActionResult;
import com.cognifide.apm.api.actions.Message;
import com.cognifide.apm.api.status.Status;
Expand Down Expand Up @@ -87,14 +84,14 @@ private List<String> toParameters(Arguments arguments) {
}
final List<String> parameters = new ArrayList<>();
arguments.getRequired().forEach(it -> parameters.add(it.toString()));
arguments.getNamed().forEach((key, value) -> parameters.add(format("%s=%s", key, value)));
arguments.getFlags().forEach(it -> parameters.add(format("--%s", it)));
arguments.getNamed().forEach((key, value) -> parameters.add(String.format("%s=%s", key, value)));
arguments.getFlags().forEach(it -> parameters.add(String.format("--%s", it)));
return parameters;
}

@Override
public void addEntry(Status status, String message) {
this.entries.add(shortEntry("", singletonList(message), status));
this.entries.add(shortEntry("", Collections.singletonList(message), status));
}

@Override
Expand All @@ -104,7 +101,7 @@ public void addEntry(Status status, List<String> messages) {

@Override
public void addEntry(Status status, String message, String command) {
this.entries.add(shortEntry(command, singletonList(message), status));
this.entries.add(shortEntry(command, Collections.singletonList(message), status));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package com.cognifide.apm.core.scripts;

import static java.lang.String.format;

import com.cognifide.apm.api.scripts.Script;
import com.cognifide.apm.api.services.ScriptFinder;
import com.cognifide.apm.core.Apm;
Expand Down Expand Up @@ -178,7 +176,7 @@ private List<String> validate(FileDescriptor file) {
private static void ensurePropertyMatchesPattern(List<String> errors, String property, String value,
Pattern pattern) {
if (!pattern.matcher(value).matches()) {
errors.add(format("Invalid %s: \"%s\"", property, value));
errors.add(String.format("Invalid %s: \"%s\"", property, value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package com.cognifide.apm.core.ui.models;

import static org.apache.commons.lang3.StringUtils.defaultIfEmpty;

import com.cognifide.apm.api.scripts.Script;
import com.cognifide.apm.core.history.History;
import com.cognifide.apm.core.history.HistoryEntry;
Expand Down Expand Up @@ -81,7 +79,7 @@ public final class ScriptsRowModel {
@PostConstruct
private void afterCreated() {
this.isFolder = isFolder(resource);
this.scriptName = defaultIfEmpty(getProperty(resource, JcrConstants.JCR_TITLE), resource.getName());
this.scriptName = StringUtils.defaultIfEmpty(getProperty(resource, JcrConstants.JCR_TITLE), resource.getName());
if (!isFolder) {
Optional.ofNullable(resource.adaptTo(ScriptModel.class)).ifPresent(script -> {
ScriptHistory scriptHistory = history.findScriptHistory(resource.getResourceResolver(), script);
Expand Down

0 comments on commit bc690c0

Please sign in to comment.