harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r396464 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/lang/EnumConstantNotPresentException.java test/java/org/apache/harmony/tests/java/lang/EnumConstantNotPresentExceptionTest.java
Date Mon, 24 Apr 2006 07:06:31 GMT
Author: smishura
Date: Mon Apr 24 00:06:30 2006
New Revision: 396464

URL: http://svn.apache.org/viewcvs?rev=396464&view=rev
Log:
Apply patch HARMONY-393 ([classlib][luni] Add java.lang.EnumConstantNotPresentException and
test case)

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/EnumConstantNotPresentException.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/EnumConstantNotPresentExceptionTest.java

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/EnumConstantNotPresentException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/EnumConstantNotPresentException.java?rev=396464&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/EnumConstantNotPresentException.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/EnumConstantNotPresentException.java
Mon Apr 24 00:06:30 2006
@@ -0,0 +1,72 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang;
+
+/**
+ * <p>
+ * Indicates that an <code>enum</code> constant does not exist for a
+ * particular name.
+ * </p>
+ * 
+ * @since 1.5
+ * @author Nathan Beyer (Harmony)
+ */
+public class EnumConstantNotPresentException extends RuntimeException {
+
+    private static final long serialVersionUID = -6046998521960521108L;
+
+    private final Class<? extends Enum> enumType;
+
+    private final String constantName;
+
+    /**
+     * <p>
+     * Constructs an instance for the passed enum and constant name.
+     * </p>
+     * 
+     * @param enumType The enum type.
+     * @param constantName The missing constant name.
+     */
+    public EnumConstantNotPresentException(Class<? extends Enum> enumType,
+            String constantName) {
+        super("The enum constant " + enumType.getName() + "." + constantName
+                + " is missing.");
+        this.enumType = enumType;
+        this.constantName = constantName;
+    }
+
+    /**
+     * <p>
+     * The enum type from which the constant name is missing.
+     * </p>
+     * 
+     * @return A <code>Class</code> instance.
+     */
+    public Class<? extends Enum> enumType() {
+        return enumType;
+    }
+
+    /**
+     * <p>
+     * The name of the constant missing.
+     * </p>
+     * 
+     * @return A <code>String</code> instance.
+     */
+    public String constantName() {
+        return constantName;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/EnumConstantNotPresentExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/EnumConstantNotPresentExceptionTest.java?rev=396464&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/EnumConstantNotPresentExceptionTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/EnumConstantNotPresentExceptionTest.java
Mon Apr 24 00:06:30 2006
@@ -0,0 +1,54 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tests.java.lang;
+
+import junit.framework.TestCase;
+
+public class EnumConstantNotPresentExceptionTest extends TestCase {
+
+    public enum Fixture {
+        ONE,TWO,THREE
+    }
+
+    /**
+     * @test java.lang.EnumConstantNotPresentException#EnumConstantNotPresentException(Class<?
+     * extends Enum>, String)
+     */
+    public void test_ConstructorLjava_lang_ClassLjava_lang_String() {
+        try {
+            new EnumConstantNotPresentException(null, "");
+            fail("No NPE");
+        } catch (NullPointerException e) {
+        }
+    }
+
+    /**
+     * @test java.lang.EnumConstantNotPresentException#enumType()
+     */
+    public void test_enumType() {
+        EnumConstantNotPresentException e = new EnumConstantNotPresentException(Fixture.class,
"FOUR");
+        assertEquals(Fixture.class, e.enumType());
+    }
+
+    /**
+     * @test java.lang.EnumConstantNotPresentException#constantName()
+     */
+    public void test_constantName() {
+        EnumConstantNotPresentException e = new EnumConstantNotPresentException(Fixture.class,
"FOUR");
+        assertEquals("FOUR", e.constantName());
+    }
+
+}



Mime
View raw message