코드 템플릿
- Controller
- View
- Constant
- Model
- Validate
# 구현 기능 목록
## 기능
## 입력
## 출력
## 예외
private final InputController inputController;
private final OutputView outputView;
public Controller(InputController inputController, OutputView outputView) {
this.inputController = inputController;
this.outputView = outputView;
}
public void run() {
}
private final InputView inputView;
private final OutputView outputView;
public InputController(InputView inputView, OutputView outputView) {
this.inputView = inputView;
this.outputView = outputView;
}
public Object getXX() {
while (true) {
try {
return readXX();
} catch (IllegalArgumentException exception) {
outputView.printErrorMessage(exception);
}
}
}
private Object readXX() {
String value = inputView.readXX();
return XX.from(value);
}
public String readXX() {
System.out.println("blah blah");
String value = readLine();
System.out.println();
return value;
}
protected String readLine() {
return Console.readLine();
}
public static final String ERROR_FORM = "[ERROR] %s%n";
public void printErrorMessage(Throwable throwable) {
System.out.printf(ERROR_FORM, throwable.getMessage());
System.out.println();
}
INVALID_XX("유효하지 않은 값입니다."),
RETRY_INPUT("다시 입력해 주세요.");
private final String message;
ErrorMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public static final Pattern NUMERIC_PATTERN = Pattern.compile("^[0-9]+$");
public static final Pattern KOREAN_AND_ENGLISH_PATTERN = Pattern.compile("^[ㄱ-ㅎ가-힣A-Za-z]+$");
private static void validate(String value) {
if (value.trim().isEmpty()) {
throw new IllegalArgumentException();
}
if (value.startsWith(",") || value.endsWith(",")) {
throw new IllegalArgumentException();
}
if (value.contains(",,")) {
throw new IllegalArgumentException();
}
}
private static void validate(String value) {
try {
if (Integer.parseInt(value) < 0) {
throw new IllegalArgumentException();
}
} catch (NumberFormatException exception) {
throw new IllegalArgumentException();
}
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof X target)) {
return false;
}
return // TODO:
}
@Override
public int hashCode() {
return Objects.hash(vo);
}
public static final DecimalFormat NUMBER_FORMAT = new DecimalFormat("###,###");
private String formatted(Integer value) {
return NUMBER_FORMAT.format(value);
}
private void printValues(Iterator<Crew> iterator) {
while (iterator.hasNext()) {
System.out.print(iterator.next().getName());
if (iterator.hasNext()) {
System.out.print(" : ");
}
}
System.out.println();
}
public void forEach(BiConsumer<? super K, ? super V> action) {
map.forEach(action);
}
public void forEach(Consumer<? super T> action) {
list.forEach(action);
}
public static ENUM_TYPE valueOfName(String name) {
return Arrays.stream(values())
.filter(s -> s.cmd.equals(name))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(ErrorMessage.));
}