001    /*
002     * CDDL HEADER START
003     *
004     * The contents of this file are subject to the terms of the
005     * Common Development and Distribution License, Version 1.0 only
006     * (the "License").  You may not use this file except in compliance
007     * with the License.
008     *
009     * You can obtain a copy of the license at
010     * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011     * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2008 Sun Microsystems, Inc.
026     */
027    
028    package org.opends.server.authorization.dseecompat;
029    
030    /**
031     * This class provides an enumeration of the allowed bind rule types.
032     */
033    public enum EnumBindRuleType {
034    
035        /**
036         * The enumeration type when the bind rule has specified type of
037         * "=".
038         */
039        EQUAL_BINDRULE_TYPE             ("="),
040        /**
041         * The enumeration type when the bind rule has specified type of
042         * "!=".
043         */
044        NOT_EQUAL_BINDRULE_TYPE         ("!="),
045        /**
046         * The enumeration type when the bind rule has specified type of
047         * "<".
048         */
049        LESS_BINDRULE_TYPE              ("<"),
050        /**
051         * The enumeration type when the bind rule has specified type of
052         * "<=".
053         */
054        LESS_OR_EQUAL_BINDRULE_TYPE     ("<="),
055        /**
056         * The enumeration type when the bind rule has specified type of
057         * >".
058         */
059        GREATER_BINDRULE_TYPE           (">"),
060        /**
061         * The enumeration type when the bind rule has specified type of
062         * ">=".
063         */
064        GREATER_OR_EQUAL_BINDRULE_TYPE  (">=");
065    
066        /*
067         * The bind rule type name.
068         */
069        private final String type;
070    
071        /**
072         * Creates a new enumeration type for the specified bind rule type.
073         * @param type The bind rule type name.
074         */
075        EnumBindRuleType(String type){
076            this.type = type;
077        }
078    
079        /**
080         * Checks to see if the type string is equal to the enumeration type
081         * name.
082         * @param type  The type name to check equality for.
083         * @return  True if the keyword is equal to the specified name.
084         */
085        public boolean isBindRuleType(String type){
086            return type.equals(this.type);
087        }
088    
089        /**
090         * Create a new enumeration type for the specified type name.
091         * @param type  The name of the enumeration to create.
092         * @return A new enumeration type for the name or null if the name is
093         * not valid.
094         */
095        public static EnumBindRuleType createBindruleOperand(String type){
096            if (type != null){
097                for (EnumBindRuleType t : EnumBindRuleType.values()){
098                    if (t.isBindRuleType(type)){
099                        return t;
100                    }
101                }
102            }
103            return null;
104        }
105    }