Skip to content

Commit e7bb682

Browse files
authored
Mark methods static in shell.core (#2623)
We have a number of methods which can be made static, this patch updates them all. Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
1 parent 3db06c0 commit e7bb682

18 files changed

Lines changed: 42 additions & 42 deletions

File tree

shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/ArgumentCompleter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public ArgumentCompleter(ActionCommand command, boolean scoped) {
174174
@SuppressWarnings({
175175
"unchecked", "rawtypes"
176176
})
177-
private Completer getDefaultCompleter(Field field, boolean multi) {
177+
private static Completer getDefaultCompleter(Field field, boolean multi) {
178178
Completer completer = null;
179179
Class<?> type = field.getType();
180180
GenericType genericType = new GenericType(field.getGenericType());

shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/DefaultActionPreparator.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ protected Object convert(Action action, Object value, Type toType) throws Except
252252
return new DefaultConverter(action.getClass().getClassLoader()).convert(value, toType);
253253
}
254254

255-
private Argument replaceDefaultArgument(Field field, Argument argument) {
255+
private static Argument replaceDefaultArgument(Field field, Argument argument) {
256256
if (Argument.DEFAULT.equals(argument.name())) {
257257
final Argument delegate = argument;
258258
final String name = field.getName();
@@ -299,7 +299,7 @@ public char mask() {
299299
return argument;
300300
}
301301

302-
private void assertIndexesAreCorrect(Class<? extends Action> actionClass, List<Argument> orderedArguments) {
302+
private static void assertIndexesAreCorrect(Class<? extends Action> actionClass, List<Argument> orderedArguments) {
303303
for (int i = 0; i < orderedArguments.size(); i++) {
304304
if (orderedArguments.get(i) == null) {
305305
throw new IllegalArgumentException("Missing argument for index: " + i + " on Action " + actionClass.getName());
@@ -427,7 +427,7 @@ public Object getDefaultValue(Action action, Field field) {
427427
return null;
428428
}
429429

430-
private String loadDescription(Class<?> clazz, String desc) {
430+
private static String loadDescription(Class<?> clazz, String desc) {
431431
if (desc != null && desc.startsWith("classpath:")) {
432432
desc = loadClassPathResource(clazz, desc.substring("classpath:".length()));
433433
}
@@ -444,11 +444,11 @@ public String getDefaultValueString(Object o) {
444444
}
445445
}
446446

447-
private void printDefaultsTo(PrintStream out, String value) {
447+
private static void printDefaultsTo(PrintStream out, String value) {
448448
out.println(" (defaults to " + value + ")");
449449
}
450450

451-
private void printMeta(PrintStream out, boolean required, boolean multivalued) {
451+
private static void printMeta(PrintStream out, boolean required, boolean multivalued) {
452452
if (required || multivalued) {
453453
String text = " (";
454454
if (required) {
@@ -493,7 +493,7 @@ static void printFormatted(String prefix, String str, int termWidth, PrintStream
493493
}
494494
}
495495

496-
private String loadClassPathResource(Class<?> clazz, String path) {
496+
private static String loadClassPathResource(Class<?> clazz, String path) {
497497
InputStream is = clazz.getResourceAsStream(path);
498498
if (is == null) {
499499
is = clazz.getClassLoader().getResourceAsStream(path);

shell/core/src/main/java/org/apache/karaf/shell/impl/console/CommandsCompleter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ public int complete(Session session, CommandLine commandLine, List<String> candi
328328

329329
protected abstract Collection<String> getNames(Session session);
330330

331-
private boolean verifyCompleter(Session session, Completer completer, String argument) {
331+
private static boolean verifyCompleter(Session session, Completer completer, String argument) {
332332
List<String> candidates = new ArrayList<>();
333333
return completer.complete(session, new ArgumentCommandLine(argument, argument.length()), candidates) != -1 && !candidates.isEmpty();
334334
}

shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public ConsoleSessionImpl(SessionFactory factory,
233233

234234
}
235235

236-
private void merge(List<Candidate> candidates) {
236+
private static void merge(List<Candidate> candidates) {
237237
Map<String, Candidate> map = new HashMap<>();
238238
for (Candidate c : candidates) {
239239
map.merge(c.value(), c, (c1, c2) -> c1.descr() != null ? c1 : c2);
@@ -493,7 +493,7 @@ private void doExecute(CharSequence command) {
493493
}
494494
}
495495

496-
private String getStatusLine(Job job, int width, String status) {
496+
private static String getStatusLine(Job job, int width, String status) {
497497
StringBuilder sb = new StringBuilder();
498498
for (int i = 0; i < width - 1; i++) {
499499
sb.append(' ');
@@ -565,12 +565,12 @@ public String readLine(String prompt, Character mask) throws IOException {
565565
return reader.readLine(prompt, mask);
566566
}
567567

568-
private String loadCompletionMode() {
568+
private static String loadCompletionMode() {
569569
return ShellUtil.loadPropertyFromShellCfg("completionMode", java.util.function.Function.identity(),
570570
Session.COMPLETION_MODE_GLOBAL);
571571
}
572572

573-
private boolean loadDisableEofExit() {
573+
private static boolean loadDisableEofExit() {
574574
return ShellUtil.loadPropertyFromShellCfg("disableEofExit", Boolean::parseBoolean, false);
575575
}
576576

@@ -660,7 +660,7 @@ protected String doGetPrompt(String var, String def) {
660660
}
661661
}
662662

663-
private String getPid() {
663+
private static String getPid() {
664664
String name = ManagementFactory.getRuntimeMXBean().getName();
665665
String[] parts = name.split("@");
666666
return parts[0];

shell/core/src/main/java/org/apache/karaf/shell/impl/console/JLineTerminal.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public MouseEvent readMouseEvent(IntSupplier supplier) {
256256
return terminal.readMouseEvent(supplier);
257257
}
258258

259-
private Signal signal(org.apache.karaf.shell.api.console.Signal sig) {
259+
private static Signal signal(org.apache.karaf.shell.api.console.Signal sig) {
260260
switch (sig) {
261261
case INT:
262262
return Signal.INT;
@@ -272,7 +272,7 @@ private Signal signal(org.apache.karaf.shell.api.console.Signal sig) {
272272
throw new UnsupportedOperationException();
273273
}
274274

275-
private org.apache.karaf.shell.api.console.Signal signal(Signal sig) {
275+
private static org.apache.karaf.shell.api.console.Signal signal(Signal sig) {
276276
switch (sig) {
277277
case INT:
278278
return org.apache.karaf.shell.api.console.Signal.INT;

shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/Procedural.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,12 @@ protected Object doContinue(CommandSession session, Process process, Object[] ar
535535
throw new ContinueException();
536536
}
537537

538-
private boolean isTrue(CommandSession session, Function function) throws Exception {
538+
private static boolean isTrue(CommandSession session, Function function) throws Exception {
539539
checkInterrupt();
540540
return isTrue(function.execute(session, null));
541541
}
542542

543-
private boolean isTrue(Object result) throws InterruptedException {
543+
private static boolean isTrue(Object result) throws InterruptedException {
544544
checkInterrupt();
545545

546546
if (result == null)
@@ -563,13 +563,13 @@ private boolean isTrue(Object result) throws InterruptedException {
563563
return true;
564564
}
565565

566-
private void checkInterrupt() throws InterruptedException {
566+
private static void checkInterrupt() throws InterruptedException {
567567
if (Thread.currentThread().isInterrupted())
568568
throw new InterruptedException("interrupted");
569569
}
570570

571571
@SuppressWarnings("unchecked")
572-
private Collection<Object> getElements(Options opt) {
572+
private static Collection<Object> getElements(Options opt) {
573573
Collection<Object> elements = null;
574574
if (opt.argObjects().size() > 0) {
575575
Object o = opt.argObjects().remove(0);
@@ -582,7 +582,7 @@ private Collection<Object> getElements(Options opt) {
582582
return elements;
583583
}
584584

585-
private List<Function> getFunctions(Options opt) {
585+
private static List<Function> getFunctions(Options opt) {
586586
List<Function> functions = new ArrayList<>();
587587
for (Object o : opt.argObjects()) {
588588
if (o instanceof Function) {

shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/CommandListHelpProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public String getHelp(Session session, String path) {
8080
}
8181
}
8282

83-
private Set<Command> getCommands(Session session, String path) {
83+
private static Set<Command> getCommands(Session session, String path) {
8484
// TODO: this is not really clean
8585

8686
List<Command> commands = session.getRegistry().getCommands();

shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/CommandsHelpProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public String getHelp(Session session, String path) {
4545
return baos.toString();
4646
}
4747

48-
private Set<Command> getCommands(Session session, String path) {
48+
private static Set<Command> getCommands(Session session, String path) {
4949
// TODO: this is not really clean
5050

5151
List<Command> commands = session.getRegistry().getCommands();

shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/HelpCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public String getHelp(final Session session, String path) {
190190
return props.get("data");
191191
}
192192

193-
private String removeNewLine(String help) {
193+
private static String removeNewLine(String help) {
194194
if (help != null && help.endsWith("\n")) {
195195
help = help.substring(0, help.length() - 1);
196196
}

shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/ShellHelpProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public String getHelp(Session session, String path) {
9494
return null;
9595
}
9696

97-
private Set<Command> getCommands(Session session, String path) {
97+
private static Set<Command> getCommands(Session session, String path) {
9898
// TODO: this is not really clean
9999

100100
List<Command> commands = session.getRegistry().getCommands();

0 commit comments

Comments
 (0)