Enums in Java API -


I am creating Java API for Adobebook. Is this a good practice to use anomes in my APIs?

I am using it as follows:

  Public Emmute address type {WORK, HOME} Public address address book implementation {map & lt; String, Details & gt; ByName = New TreeMap & lt; String, Details & gt; (); Public Zero addNewContact (string name, string address, address address type) {byName.put (name, new details (name, new address (address, address type))); // Address Type is my ANIM address type  

Please advise what is a better way to do this?

In addition to this, can you also give instructions on what I can determine, should I declare it safe and private? I want this API to be accessible to the public so that my understanding was that all the methods, classes, which I have made should be public.

Please thank

Enums as a general rule is a good idea Also for data which can be presented as a small number of irreversible strings, it is a very useful datatype for the surrounding. (It is particularly good that you can add metadata and behavior if desired).

He said, you have a hesitation in using it for contact types like work and home It makes it possible for the user to have their own custom contact type. For example, if I have two part-time jobs and on which job do they want to classify people?

If you are right on that border, then I would say go for it.

If you want additional flexibility, then I suggest that the contact type is being stored in a string or database solution for something like this, to store your data in the database. You can make sense because you can easily create a relational model.


Comments