Add checkstyle and add 950 billion comments

This commit is contained in:
Alexander Söderberg 2020-09-11 22:36:51 +02:00
parent 784656b891
commit f90ce38a36
No known key found for this signature in database
GPG key ID: C0207FF7EA146678
47 changed files with 1055 additions and 88 deletions

View file

@ -49,13 +49,23 @@ import java.util.function.Function;
*/
public class JLineCommandManager extends CommandManager<JLineCommandSender, SimpleCommandMeta> implements Completer {
/**
* Construct a new JLine command manager
*
* @param executionCoordinatorFunction Function producing a new coordinator
*/
public JLineCommandManager(@Nonnull final Function<CommandTree<JLineCommandSender, SimpleCommandMeta>,
CommandExecutionCoordinator<JLineCommandSender, SimpleCommandMeta>> executionCoordinatorFunction) {
super(executionCoordinatorFunction, CommandRegistrationHandler.nullCommandRegistrationHandler());
}
public static void main(String[] args) throws Exception {
// TODO: REMOVE THIS!!!!
/**
* Main method
*
* @param args Arguments
* @throws Exception Any and all exceptions
*/
public static void main(final String[] args) throws Exception {
final JLineCommandManager jLineCommandManager = new JLineCommandManager(CommandExecutionCoordinator.simpleCoordinator());
final Terminal terminal = TerminalBuilder.builder().build();
LineReader lineReader = LineReaderBuilder.builder()
@ -74,7 +84,8 @@ public class JLineCommandManager extends CommandManager<JLineCommandSender, Simp
.withComponent(String.class, "string", builder ->
builder.asRequired()
.withParser(((commandContext, inputQueue) -> {
final StringBuilder stringBuilder = new StringBuilder();
final StringBuilder stringBuilder =
new StringBuilder();
while (!inputQueue.isEmpty()) {
stringBuilder.append(inputQueue.remove());
if (!inputQueue.isEmpty()) {
@ -86,16 +97,16 @@ public class JLineCommandManager extends CommandManager<JLineCommandSender, Simp
})).build())
.withHandler(commandContext -> commandContext.get("string")
.ifPresent(
System.out::println))
System.out::println))
.build())
.registerCommand(jLineCommandManager.commandBuilder("test", SimpleCommandMeta.empty())
.withComponent(StaticComponent.required("one"))
.withHandler(commandContext -> System.out.println("Test (1)"))
.build())
.withComponent(StaticComponent.required("one"))
.withHandler(commandContext -> System.out.println("Test (1)"))
.build())
.registerCommand(jLineCommandManager.commandBuilder("test", SimpleCommandMeta.empty())
.withComponent(StaticComponent.required("two"))
.withHandler(commandContext -> System.out.println("Test (2)"))
.build());
.withComponent(StaticComponent.required("two"))
.withHandler(commandContext -> System.out.println("Test (2)"))
.build());
System.out.println("Ready...");
while (!shouldStop[0]) {
final String line = lineReader.readLine();
@ -127,7 +138,7 @@ public class JLineCommandManager extends CommandManager<JLineCommandSender, Simp
}
@Override
public void complete(@Nonnull final LineReader lineReader,
public final void complete(@Nonnull final LineReader lineReader,
@Nonnull final ParsedLine parsedLine,
@Nonnull final List<Candidate> list) {
final String line = parsedLine.line();
@ -140,7 +151,7 @@ public class JLineCommandManager extends CommandManager<JLineCommandSender, Simp
@Nonnull
@Override
public SimpleCommandMeta createDefaultCommandMeta() {
public final SimpleCommandMeta createDefaultCommandMeta() {
return SimpleCommandMeta.empty();
}

View file

@ -30,7 +30,7 @@ import javax.annotation.Nonnull;
public class JLineCommandSender implements CommandSender {
@Override
public boolean hasPermission(@Nonnull final String permission) {
public final boolean hasPermission(@Nonnull final String permission) {
return true;
}

View file

@ -0,0 +1,28 @@
//
// MIT License
//
// Copyright (c) 2020 Alexander Söderberg
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
/**
* cloud implementation for JLine3
*/
package com.intellectualsites.commands.jline;