I saw three things. First you should only have an interface AnimalCreator if you gonna have more than one factory, in other case this is unnecessary complexity.
As common usage. Because factory and "creational patterns" in general are the ones who has coupling. You should study the benefits of have static methods and very specific methods. Like:
public static Cat createCat(){ //code here }
public static Cat createDuck(){ //code here }
With this approach you not have to deal with invalid creational arguments (and of course, not returning any null). If you really need some "customization" you could take a look at "builder pattern" (the one you implement, not a lazy lombok way kkk).
Again, take a look, see what you can use of what I've said and give me some feedback. Good study! \o.
I saw three things. First you should only have an interface AnimalCreator if you gonna have more than one factory, in other case this is unnecessary complexity.
As common usage. Because factory and "creational patterns" in general are the ones who has coupling. You should study the benefits of have static methods and very specific methods. Like:
With this approach you not have to deal with invalid creational arguments (and of course, not returning any null). If you really need some "customization" you could take a look at "builder pattern" (the one you implement, not a lazy lombok way kkk).
Again, take a look, see what you can use of what I've said and give me some feedback. Good study! \o.