001: /**
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016:
017: $Header:$
018: */package org.apache.beehive.netui.util.config.bean;
019:
020: /**
021: *
022: */
023: public final class IdJavascript implements java.io.Serializable {
024:
025: public static final int INT_DEFAULT = 0;
026: public static final int INT_LEGACY = 1;
027: public static final int INT_LEGACY_ONLY = 2;
028:
029: /**
030: */
031: public static final IdJavascript DEFAULT = new IdJavascript(
032: INT_DEFAULT);
033:
034: /**
035: */
036: public static final IdJavascript LEGACY = new IdJavascript(
037: INT_LEGACY);
038:
039: /**
040: */
041: public static final IdJavascript LEGACY_ONLY = new IdJavascript(
042: INT_LEGACY_ONLY);
043:
044: private int _val;
045:
046: private IdJavascript(int val) {
047: _val = val;
048: }
049:
050: /**
051: * Convert this id javascript to a readable String.
052: * @return the readable id javascript name
053: */
054: public String toString() {
055: switch (_val) {
056: case INT_DEFAULT:
057: return "default";
058: case INT_LEGACY:
059: return "legacy";
060: case INT_LEGACY_ONLY:
061: return "legacyOnly";
062: }
063:
064: String message = "Encountered an unknown id javascript with value \""
065: + _val + "\"";
066: assert false : message;
067: throw new IllegalStateException(message);
068: }
069:
070: /**
071: * Equals method.
072: * @param value value to check
073: * @return <code>true</code> if this id javascript matches the <code>value</code>; <code>false</code> otherwise.
074: */
075: public boolean equals(Object value) {
076: if (value == this )
077: return true;
078: if (value == null || !(value instanceof IdJavascript))
079: return false;
080:
081: return ((IdJavascript) value)._val == _val;
082: }
083:
084: /**
085: * Hash code.
086: * @return the hash code
087: */
088: public int hashCode() {
089: return _val;
090: }
091:
092: /**
093: * The id javascript's int value.
094: *
095: * @return the id javascript's value
096: */
097: public int getValue() {
098: return _val;
099: }
100: }
|