Checkstyle

This commit is contained in:
Arne Keller 2020-02-19 19:32:35 +01:00
parent 1f3802d380
commit 8803aab42a
3 changed files with 70 additions and 2 deletions

View File

@ -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";
/**

View File

@ -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.

View File

@ -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.