I want to say yes, but I'm afraid that request.getAction() is returning a string. Is this true? What would you expect your factory to look like?
If they're strings you might have to resort to something like this:
interface ActionFactory {
public Action.ADD newAdd();
public Action.UPDATE newUpdate();
public Action.DELETE newDelete();
}
// ...
public static Action parse(String action, ActionFactory factory) {
switch(action) {
case "ADD":
return factory.newAdd();
...
}
}
}
It's not too bad. If getAction() returns something that is typesafe then you can have multiple overloaded "create" methods in your factory and do without the Action.parse method. It also might make sense to use this pattern in addition to having an enum, and then parse the enum and pass the enum into Action.parse instead of the String.