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.exceptions.FxNotFoundException;
036:
037: /**
038: * Modes for uniqueness of properties
039: *
040: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
041: */
042: public enum UniqueMode {
043: /**
044: * No uniqueness
045: */
046: None(0),
047:
048: /**
049: * Globally unique across all usages of a property (check on property id)
050: */
051: Global(1),
052:
053: /**
054: * Unique within a type (check on property id for current type)
055: */
056: Type(2),
057:
058: /**
059: * Unique for this type and all parent or derived types (check on property id for all affected types)
060: */
061: DerivedTypes(3),
062:
063: /**
064: * Unique within an instance (check on property id within instance)
065: */
066: Instance(4);
067:
068: private int id;
069:
070: /**
071: * Ctor
072: *
073: * @param id internal DB id
074: */
075: UniqueMode(int id) {
076: this .id = id;
077: }
078:
079: /**
080: * Getter for the id
081: *
082: * @return id
083: */
084: public int getId() {
085: return id;
086: }
087:
088: /**
089: * Get a UniqueMode by its id
090: *
091: * @param id internal id
092: * @return UniqueMode
093: * @throws FxNotFoundException on errors
094: */
095: public static UniqueMode getById(int id) throws FxNotFoundException {
096: for (UniqueMode um : UniqueMode.values())
097: if (um.id == id)
098: return um;
099: throw new FxNotFoundException(
100: "ex.structure.uniqueMode.notFound.id", id);
101: }
102: }
|