0

I need a simple enum declaring the Java reference types, as:

public enum ReferenceType {
    STRONG, SOFT, WEAK, PHANTOM;
}

Does such enum exist somewhere in the Java API or a general utility library such as Guava ? I have not been able to find it in either place, although I found third party projects that declare it (e.g. google-guice: RefrenceType).

I just try to avoid polluting my project with silly classes/enums that may exist somewhere else.

Since asking this question, I found that Guava in fact used to have this, but they dropped it: Issue 1662: Feature request for enum of reference types

  • 5
    The fact that it's declared there probably means that it's not in other semi-standard libraries. – jozefg Feb 9 '14 at 23:47
2

You can find one in hibernate ReferenceType though it only contains STRONG, SOFT and WEAK but not PHANTOM.

There are few others ReferenceType in eclipse net4j and Link.Type in true commons. But I think you will be better without them in case you want some modification later.

-3

Think in terms of code polution

  • 10-liner

vs

  • project just included to use a 10-liner.
  • 1
    I know, the question is more about if something like that exist on the Java API or somewhere in Guava (I already have Guava as dependency) – Sergio Feb 10 '14 at 0:15
-4

No it wont exist mostly because enums are itself available in their most simplified form in java.lang package and can be used as per the user's wishes. So even if there will be an API for enum, it won't be of much help

For further reading on enums go to http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html

  • 2
    sorry, I do not understand your answer. – Sergio Feb 10 '14 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.