001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  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,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License. 
018 *  
019 */
020package org.apache.directory.api.ldap.model.schema;
021
022
023/**
024 * Type safe enum for a matching rule's comparator and normalizer component
025 * usage string. This can be take one of the following three values:
026 * <ul>
027 * <li>ORDERING</li>
028 * <li>EQUALITY</li>
029 * <li>SUBSTRING</li>
030 * </ul>
031 * 
032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
033 */
034public enum MatchingRuleEnum
035{
036    /** value for ordering usage */
037    ORDERING(0),
038
039    /** value for equality usage */
040    EQUALITY(1),
041
042    /** value for substring usage */
043    SUBSTRING(2);
044
045    /** Stores the integer value of each element of the enumeration */
046    private int value;
047
048
049    /**
050     * Private constructor so no other instances can be created other than the
051     * public static constants in this class.
052     * 
053     * @param value
054     *            the integer value of the enumeration.
055     */
056    MatchingRuleEnum( int value )
057    {
058        this.value = value;
059    }
060
061
062    /**
063     * @return The value associated with the current element.
064     */
065    public int getValue()
066    {
067        return value;
068    }
069
070
071    /**
072     * Gets the enumeration type for the usage string regardless of case.
073     * 
074     * @param matchingRule the usage string
075     * @return the matchingRule enumeration type
076     */
077    public static MatchingRuleEnum getUsage( String matchingRule )
078    {
079        return valueOf( matchingRule );
080    }
081}