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 *    https://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
023import org.apache.directory.api.util.Strings;
024
025
026/**
027 * Type safe enumerations for an objectClass' type. An ObjectClass type can be
028 * one of the following types:
029 * <ul>
030 * <li>ABSTRACT</li>
031 * <li>AUXILIARY</li>
032 * <li>STRUCTURAL</li>
033 * </ul>
034 * 
035 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
036 */
037public enum ObjectClassTypeEnum
038{
039    /** The enumeration constant value for the abstract objectClasses */
040    ABSTRACT(0),
041
042    /** The enumeration constant value for the auxillary objectClasses */
043    AUXILIARY(1),
044
045    /** The enumeration constant value for the structural objectClasses */
046    STRUCTURAL(2);
047
048    /** The int constant value for the abstract objectClasses */
049    public static final int ABSTRACT_VAL = 0;
050
051    /** The int constant value for the auxillary objectClasses */
052    public static final int AUXILIARY_VAL = 1;
053
054    /** The int constant value for the structural objectClasses */
055    public static final int STRUCTURAL_VAL = 2;
056
057    /** Stores the integer value of each element of the enumeration */
058    private int value;
059
060
061    /**
062     * Private constructor so no other instances can be created other than the
063     * public static constants in this class.
064     * 
065     * @param value the integer value of the enumeration.
066     */
067    ObjectClassTypeEnum( int value )
068    {
069        this.value = value;
070    }
071
072
073    /**
074     * @return The value associated with the current element.
075     */
076    public int getValue()
077    {
078        return value;
079    }
080
081
082    /**
083     * Gets the objectClass type enumeration of AUXILIARY, STRUCTURAL, or,
084     * ABSTRACT.
085     * 
086     * @param name options are AUXILIARY, STRUCTURAL, or, ABSTRACT
087     * 
088     * @return the type safe enumeration for the objectClass type
089     */
090    public static ObjectClassTypeEnum getClassType( String name )
091    {
092        return valueOf( Strings.upperCase( name.trim() ) );
093    }
094}