Refactoring: using final

This commit is contained in:
qvalentin 2022-03-06 15:54:47 +01:00
parent c8225dbdca
commit 7452d3526b
2 changed files with 5 additions and 4 deletions

View File

@ -7,10 +7,10 @@ package category;
*/
public class Category {
private CategoryName name;
private CategoryId id;
private final CategoryName name;
private final CategoryId id;
public Category(CategoryName name, CategoryId id) {
public Category(final CategoryName name, final CategoryId id) {
this.name = name;
this.id = id;
}

View File

@ -5,6 +5,7 @@ import exeptions.IllegalValueObjectArgument;
import java.util.Objects;
public class CategoryName {
private final String name;
public String getName() {
@ -21,7 +22,7 @@ public class CategoryName {
throw new IllegalValueObjectArgument("A Category name can not be null.");
}
if (name.isBlank() || name.isEmpty() || name.length() < 3) {
if (name.isBlank() || name.length() < 3) {
throw new IllegalValueObjectArgument("A Category name must be a valid string of at least 3 characters.");
}
}