001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2008
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.shared.structure;
034:
035: import com.flexive.shared.FxSharedUtils;
036: import com.flexive.shared.ObjectWithLabel;
037: import com.flexive.shared.exceptions.FxNotFoundException;
038: import com.flexive.shared.value.FxString;
039:
040: import java.io.Serializable;
041:
042: /**
043: * State of a FxType
044: *
045: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
046: */
047: public enum TypeState implements Serializable, ObjectWithLabel {
048:
049: /**
050: * Type is available
051: */
052: Available(0),
053:
054: /**
055: * Type is locked by the system for possible changes,
056: * will be available soon
057: */
058: Locked(1),
059:
060: /**
061: * Type is permanently unavailable
062: */
063: Unavailable(2);
064:
065: private int id;
066:
067: /**
068: * Ctor
069: *
070: * @param id
071: */
072: TypeState(int id) {
073: this .id = id;
074: }
075:
076: /**
077: * Getter for the internal id
078: *
079: * @return internal id
080: */
081: public int getId() {
082: return id;
083: }
084:
085: /**
086: * Get a TypeState by its id
087: *
088: * @param id
089: * @return TypeState
090: * @throws com.flexive.shared.exceptions.FxNotFoundException
091: *
092: */
093: public static TypeState getById(int id) throws FxNotFoundException {
094: for (TypeState state : TypeState.values())
095: if (state.id == id)
096: return state;
097: throw new FxNotFoundException(
098: "ex.structure.typeState.notFound.id", id);
099: }
100:
101: /**
102: * {@inheritDoc}
103: */
104: public FxString getLabel() {
105: return FxSharedUtils.getEnumLabel(this);
106: }
107: }
|