I have a question regarding best practices when dealing with enums in Java. Let's say I have a java class and an enum class like so:
public class Foo {
private final FooEnum fooEnum;
public Foo(FooEnum fooEnum) {
this.fooEnum = fooEnum;
}
public Foo(String fooEnum) {
this.fooEnum = FooEnum.valueOf(fooEnum);
}
}
public enum FooEnum {
FOO1,
FOO2,
FOO3
}
My question is this: Is it considered good practice to offer a 2nd constructor that takes in a string to initialize the enum so the user can choose either to pass an enum or it's string equivalent? If not, what is the alternative? Should the user be responsible for converting the string into an enum?