There shouldn't generally be a need to rebuild an application when new data is introduced. If there's no need to define and implement any publisher related logic every time a new Publisher is introduced, then enum is a wrong choice.
Where exactly in your application you need to refer to a certain Publisher? Do you have some logic that's bound to the Publisher in your application? Like
if (article.getPublisher().equals(Publisher.NYPost) {
doSomethingNyPostRelated();
}
Do you have any such references? If you don't have any, then you shouldn't have a hard coded set of Publishers, as an enum or otherwise.
I like the rigidity of using enum, but when might I get tripped-up if I treat the publisher as an enum instead of a String?
How about a Publisher class that's not an enum?
public class Publisher {
private final int id;
private final String name; // perhaps?
...
}
That would give you more rigidity than a String without being limited to only some hard coded predefined publishers. First, you would be able to control the creation, the validity and the use of Publishers. Second you would have the type safety: you wouldn't be able to pass or return a random String as a Publisher. Third, you could read a predefined set of Publishers from a database or from a configuration file, whatever is preferred:
public class PublisherRepository {
public List<Publisher> getAllPublishers() {
// read publishers from db or config file
}
}
Of course you could even have your PublisherRepository return a hard coded list of Publishers at first. Changing a properly structured hard coded solution wouldn't be as difficult as replacing an enum.
getPublisher()
-- this seems like a code smell to me. What might you do with that information??