01:/*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:package org.apache.commons.lang.enum;
18:
19:import java.util.Iterator;
20:import java.util.List;
21:import java.util.Map;
22:
23:/**
24: * Broken Operator enumeration, null class.
25: *
26: * @author Stephen Colebourne
27: * @version $Id: Broken1OperationEnum.java 437554 2006-08-28 06:21:41Z bayard $
28: */
29:public abstract class Broken1OperationEnum extends Enum {
30: // This syntax works for JDK 1.3 and upwards:
31:// public static final OperationEnum PLUS = new OperationEnum("Plus") {
32:// public int eval(int a, int b) {
33:// return (a + b);
34:// }
35:// };
36:// public static final OperationEnum MINUS = new OperationEnum("Minus") {
37:// public int eval(int a, int b) {
38:// return (a - b);
39:// }
40:// };
41: // This syntax works for JDK 1.2 and upwards:
42: public static final Broken1OperationEnum PLUS = new PlusOperation();
43: private static class PlusOperation extends Broken1OperationEnum {
44: private PlusOperation() {
45: super ("Plus");
46: }
47: public int eval(int a, int b) {
48: return (a + b);
49: }
50: }
51: public static final Broken1OperationEnum MINUS = new MinusOperation();
52: private static class MinusOperation extends Broken1OperationEnum {
53: private MinusOperation() {
54: super ("Minus");
55: }
56: public int eval(int a, int b) {
57: return (a - b);
58: }
59: }
60:
61: private Broken1OperationEnum(String name) {
62: super (name);
63: }
64:
65: public final Class getEnumClass() {
66: return null;
67: }
68:
69: public abstract int eval(int a, int b);
70:
71: public static Broken1OperationEnum getEnum(String name) {
72: return (Broken1OperationEnum) getEnum(Broken1OperationEnum.class, name);
73: }
74:
75: public static Map getEnumMap() {
76: return getEnumMap(Broken1OperationEnum.class);
77: }
78:
79: public static List getEnumList() {
80: return getEnumList(Broken1OperationEnum.class);
81: }
82:
83: public static Iterator iterator() {
84: return iterator(Broken1OperationEnum.class);
85: }
86:}
|