upload
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m10s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m10s
This commit is contained in:
@@ -17,6 +17,10 @@ public class TaskManager {
|
||||
|
||||
public Task createTask(String name, String description) {
|
||||
|
||||
if(!checkOnlyLetterOrDigit(name)) {
|
||||
throw new TaskAlreadyExistsException("Only Letters or Digit are allowed in the name: " + name);
|
||||
}
|
||||
|
||||
boolean taskExited = this.taskMap.values().stream().anyMatch(task -> task.getName().equals(name));
|
||||
if(taskExited) {
|
||||
throw new TaskAlreadyExistsException("Task already exits, with the name: " + name);
|
||||
@@ -55,4 +59,29 @@ public class TaskManager {
|
||||
.orElseThrow().getTaskID());
|
||||
|
||||
}
|
||||
|
||||
private boolean checkOnlyLetterOrDigit(String text) {
|
||||
boolean result = true;
|
||||
|
||||
for(int i = 0; i < text.length(); i++) {
|
||||
char c = text.charAt(i);
|
||||
if(!Character.isLetterOrDigit(c)) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private boolean checkOnlyLetter(String text) {
|
||||
boolean result = true;
|
||||
|
||||
for(int i = 0; i < text.length(); i++) {
|
||||
char c = text.charAt(i);
|
||||
if(!Character.isLetter(c)) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user