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

public enum ReferenceType {

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. Commented Feb 9, 2014 at 23:47

3 Answers 3


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.


Think in terms of code polution

  • 10-liner


  • 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
    Commented Feb 10, 2014 at 0:15

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
    Commented Feb 10, 2014 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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