001/**
002 * Get more info at : www.jrebirth.org .
003 * Copyright JRebirth.org © 2011-2016
004 * Contact : sebastien.bordes@jrebirth.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.jrebirth.af.api.annotation;
019
020/**
021 * The class <strong>PriorityLevel</strong>.
022 *
023 * @author Sébastien Bordes
024 */
025public enum PriorityLevel {
026
027    /** The None priority when none has been defined. */
028    None(0),
029
030    /** The lowest priority, after lower, is the less important priority level. */
031    Lowest(1),
032
033    /** The lower priority, after Low but before Lowest. */
034    Lower(2),
035
036    /** The low priority, after Normal but before Lower. */
037    Low(3),
038
039    /** The normal priority, after high but before Low. */
040    Normal(4),
041
042    /** The High priority, after higher but before Normal. */
043    High(5),
044
045    /** The Higher priority, after highest but before high. */
046    Higher(6),
047
048    /** The highest priority, after ultimate but before higher. */
049    Highest(7),
050
051    /** The Ultimate is the most important priority level. */
052    Ultimate(8);
053
054    /** The level. */
055    private final int level;
056
057    /**
058     * Instantiates a new priority level.
059     *
060     * @param level the level
061     */
062    private PriorityLevel(final int level) {
063        this.level = level;
064    }
065
066    /**
067     * Gets the level.
068     *
069     * @return the level
070     */
071    public int level() {
072        return this.level * 1000;
073    }
074
075    /**
076     * Gets the level be adding an extra weight.
077     *
078     * @param weight the weight value shall be strictly lower than 1000
079     *
080     * @return the level
081     */
082    public int level(final int weight) {
083        if (weight < 1000) {
084            return this.level * 1000 + weight;
085        }
086        // Silently ignore weight
087        return level();
088    }
089
090}