01: /* Licensed to the Apache Software Foundation (ASF) under one or more
02: * contributor license agreements. See the NOTICE file distributed with
03: * this work for additional information regarding copyright ownership.
04: * The ASF licenses this file to You under the Apache License, Version 2.0
05: * (the "License"); you may not use this file except in compliance with
06: * the License. You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package java.lang;
18:
19: import org.apache.harmony.luni.util.Msg;
20:
21: /**
22: * <p>
23: * Indicates that an <code>enum</code> constant does not exist for a
24: * particular name.
25: * </p>
26: *
27: * @since 1.5
28: * @author Nathan Beyer (Harmony)
29: */
30: public class EnumConstantNotPresentException extends RuntimeException {
31:
32: private static final long serialVersionUID = -6046998521960521108L;
33:
34: @SuppressWarnings("unchecked")
35: private final Class<? extends Enum> enumType;
36:
37: private final String constantName;
38:
39: /**
40: * <p>
41: * Constructs an instance for the passed enum and constant name.
42: * </p>
43: *
44: * @param enumType The enum type.
45: * @param constantName The missing constant name.
46: */
47: @SuppressWarnings("unchecked")
48: public EnumConstantNotPresentException(
49: Class<? extends Enum> enumType, String constantName) {
50: // luni.03=The enum constant {0}.{1} is missing
51: super (Msg
52: .getString("luni.03", enumType.getName(), constantName)); //$NON-NLS-1$
53: this .enumType = enumType;
54: this .constantName = constantName;
55: }
56:
57: /**
58: * <p>
59: * The enum type from which the constant name is missing.
60: * </p>
61: *
62: * @return A <code>Class</code> instance.
63: */
64: @SuppressWarnings("unchecked")
65: public Class<? extends Enum> enumType() {
66: return enumType;
67: }
68:
69: /**
70: * <p>
71: * The name of the constant missing.
72: * </p>
73: *
74: * @return A <code>String</code> instance.
75: */
76: public String constantName() {
77: return constantName;
78: }
79: }
|