From 8803aab42af7f484afcc3b8aa835a3f50c036978 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Wed, 19 Feb 2020 19:32:35 +0100 Subject: [PATCH] Checkstyle --- .../informatik/ui/command/CommandFactory.java | 66 +++++++++++++++++++ .../informatik/ui/command/CreateEngine.java | 3 +- .../informatik/ui/command/CreateTrainSet.java | 3 +- 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/src/edu/kit/informatik/ui/command/CommandFactory.java b/src/edu/kit/informatik/ui/command/CommandFactory.java index 3871a81..631a2b0 100644 --- a/src/edu/kit/informatik/ui/command/CommandFactory.java +++ b/src/edu/kit/informatik/ui/command/CommandFactory.java @@ -9,29 +9,95 @@ import edu.kit.informatik.ui.InvalidInputException; * @version 1.0 */ public final class CommandFactory { + /** + * Regex to match a number, accepting leading plus sign and zeros. + */ public static final String NUMBER = "[+-]?\\d+"; + /** + * Regex to accept two numbers separated by a comma. + */ public static final String VECTOR = NUMBER + "," + NUMBER; + /** + * Regex to accept one word consisting of letters and digits. + */ public static final String ALPHANUMERIC_WORD = "[\\p{L}\\d]+"; + /** + * Regex to accept one rolling stock identifier. + */ public static final String ROLLING_STOCK_IDENTIFIER = "(" + ALPHANUMERIC_WORD + "-" + ALPHANUMERIC_WORD + ")|W" + NUMBER; + /** + * Name of the add track command. + */ public static final String ADD_TRACK = "add track"; + /** + * Name of the add switch command. + */ public static final String ADD_SWITCH = "add switch"; + /** + * Name of the delete track command. + */ public static final String DELETE_TRACK = "delete track"; + /** + * Name of the list tracks command. + */ public static final String LIST_TRACKS = "list tracks"; + /** + * Name of the set switch command. + */ public static final String SET_SWITCH = "set switch"; + /** + * Name of the create engine command. + */ public static final String CREATE_ENGINE = "create engine"; + /** + * Name of the list engines command. + */ public static final String LIST_ENGINES = "list engines"; + /** + * Name of the create coach command. + */ public static final String CREATE_COACH = "create coach"; + /** + * Name of the list coaches command. + */ public static final String LIST_COACHES = "list coaches"; + /** + * Name of the create train-set command. + */ public static final String CREATE_TRAIN_SET = "create train-set"; + /** + * Name of the list train-sets command. + */ public static final String LIST_TRAIN_SETS = "list train-sets"; + /** + * Name of the delete rolling stock command. + */ public static final String DELETE_ROLLING_STOCK = "delete rolling stock"; + /** + * Name of the add train command. + */ public static final String ADD_TRAIN = "add train"; + /** + * Name of the delete train command. + */ public static final String DELETE_TRAIN = "delete train"; + /** + * Name of the list train command. + */ public static final String LIST_TRAINS = "list trains"; + /** + * Name of the show train command. + */ public static final String SHOW_TRAIN = "show train"; + /** + * Name of the put train command. + */ public static final String PUT_TRAIN = "put train"; + /** + * Name of the step command. + */ public static final String STEP = "step"; /** diff --git a/src/edu/kit/informatik/ui/command/CreateEngine.java b/src/edu/kit/informatik/ui/command/CreateEngine.java index 8075837..a9848d8 100644 --- a/src/edu/kit/informatik/ui/command/CreateEngine.java +++ b/src/edu/kit/informatik/ui/command/CreateEngine.java @@ -24,7 +24,8 @@ import static edu.kit.informatik.ui.command.CommandFactory.NUMBER; */ public class CreateEngine extends Command { private static final Pattern CREATE_ENGINE_ARGUMENTS - = Pattern.compile(" (electrical|diesel|steam) (" + ALPHANUMERIC_WORD + ") (" + ALPHANUMERIC_WORD + ") (" + NUMBER + ") (true|false) (true|false)"); + = Pattern.compile(" (electrical|diesel|steam) (" + ALPHANUMERIC_WORD + ") (" + ALPHANUMERIC_WORD + ") (" + + NUMBER + ") (true|false) (true|false)"); /** * Type of the new engine. diff --git a/src/edu/kit/informatik/ui/command/CreateTrainSet.java b/src/edu/kit/informatik/ui/command/CreateTrainSet.java index a8b770d..7104064 100644 --- a/src/edu/kit/informatik/ui/command/CreateTrainSet.java +++ b/src/edu/kit/informatik/ui/command/CreateTrainSet.java @@ -20,7 +20,8 @@ import static edu.kit.informatik.ui.command.CommandFactory.NUMBER; */ public class CreateTrainSet extends Command { private static final Pattern CREATE_TRAIN_SET_ARGUMENTS - = Pattern.compile(" (" + ALPHANUMERIC_WORD + ") (" + ALPHANUMERIC_WORD + ") (" + NUMBER + ") (true|false) (true|false)"); + = Pattern.compile(" (" + ALPHANUMERIC_WORD + ") (" + ALPHANUMERIC_WORD + ") (" + + NUMBER + ") (true|false) (true|false)"); /** * Series (class) of the new train set.