Refactoring: using final
This commit is contained in:
parent
c8225dbdca
commit
7452d3526b
|
@ -7,10 +7,10 @@ package category;
|
||||||
*/
|
*/
|
||||||
public class Category {
|
public class Category {
|
||||||
|
|
||||||
private CategoryName name;
|
private final CategoryName name;
|
||||||
private CategoryId id;
|
private final CategoryId id;
|
||||||
|
|
||||||
public Category(CategoryName name, CategoryId id) {
|
public Category(final CategoryName name, final CategoryId id) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import exeptions.IllegalValueObjectArgument;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class CategoryName {
|
public class CategoryName {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -21,7 +22,7 @@ public class CategoryName {
|
||||||
throw new IllegalValueObjectArgument("A Category name can not be null.");
|
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.");
|
throw new IllegalValueObjectArgument("A Category name must be a valid string of at least 3 characters.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue