EnumConstantNotPresentException.java 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* EnumConstantNotPresentException.java -- thrown when enum constant
  2. not available
  3. Copyright (C) 2005 Free Software Foundation, Inc.
  4. This file is part of GNU Classpath.
  5. GNU Classpath is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9. GNU Classpath is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GNU Classpath; see the file COPYING. If not, write to the
  15. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA.
  17. Linking this library statically or dynamically with other modules is
  18. making a combined work based on this library. Thus, the terms and
  19. conditions of the GNU General Public License cover the whole
  20. combination.
  21. As a special exception, the copyright holders of this library give you
  22. permission to link this library with independent modules to produce an
  23. executable, regardless of the license terms of these independent
  24. modules, and to copy and distribute the resulting executable under
  25. terms of your choice, provided that you also meet, for each linked
  26. independent module, the terms and conditions of the license of that
  27. module. An independent module is a module which is not derived from
  28. or based on this library. If you modify this library, you may extend
  29. this exception to your version of the library, but you are not
  30. obligated to do so. If you do not wish to do so, delete this
  31. exception statement from your version. */
  32. package java.lang;
  33. /**
  34. * An exception of this type is thrown when a symbolic reference is
  35. * made to an enum constant which does not exist.
  36. *
  37. * @author Tom Tromey (tromey@redhat.com)
  38. * @since 1.5
  39. */
  40. public class EnumConstantNotPresentException extends RuntimeException
  41. {
  42. private static final long serialVersionUID = -6046998521960521108L;
  43. /**
  44. * The enum's type. Note that the name is fixed by the
  45. * serialization spec.
  46. */
  47. private Class<? extends Enum> enumType;
  48. /**
  49. * The name of the missing enum constant. Note that the name is
  50. * fixed by the serialization spec.
  51. */
  52. private String constantName;
  53. /**
  54. * Create a new EnumConstantNotPresentException with the indicated
  55. * enum type and enum constant name.
  56. * @param theEnum the enum's class
  57. * @param name the name of the missing enum constant
  58. */
  59. public EnumConstantNotPresentException(Class<? extends Enum> theEnum,
  60. String name)
  61. {
  62. super("enum " + theEnum + " is missing the constant " + name);
  63. enumType = theEnum;
  64. constantName = name;
  65. }
  66. /**
  67. * Return the name of the missing constant.
  68. * @return the name of the missing constant
  69. */
  70. public String constantName()
  71. {
  72. return constantName;
  73. }
  74. /**
  75. * Return the enum type which is missing a constant.
  76. * @return the enum type which is missing a constant
  77. */
  78. public Class<? extends Enum> enumType()
  79. {
  80. return enumType;
  81. }
  82. }