KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > core > enums > AbstractGenericLabeledEnum


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 org.springframework.core.enums;
18
19 /**
20  * Base class for labeled enum instances that aren't static.
21  *
22  * @author Keith Donald
23  * @since 1.2.6
24  */

25 public abstract class AbstractGenericLabeledEnum extends AbstractLabeledEnum {
26
27     /**
28      * A descriptive label for the enum.
29      */

30     private final String JavaDoc label;
31
32
33     /**
34      * Create a new StaticLabeledEnum instance.
35      * @param label the label; if <code>null</code>), the enum's code
36      * will be used as label
37      */

38     protected AbstractGenericLabeledEnum(String JavaDoc label) {
39         this.label = label;
40     }
41
42
43     public String JavaDoc getLabel() {
44         if (this.label != null) {
45             return label;
46         }
47         else {
48             return getCode().toString();
49         }
50     }
51
52 }
53
Popular Tags