001/*
002 * Copyright 2007-2020 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2007-2020 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2008-2020 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.schema;
037
038
039
040import com.unboundid.util.StaticUtils;
041import com.unboundid.util.ThreadSafety;
042import com.unboundid.util.ThreadSafetyLevel;
043
044
045
046/**
047 * This enum defines the set of object class types that are defined in the LDAP
048 * protocol.
049 */
050@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
051public enum ObjectClassType
052{
053  /**
054   * The object class type for abstract object classes.  An abstract object
055   * class may only serve as the superclass for another object class, and may
056   * not appear in an entry unless at least one of its non-abstract subclasses
057   * is also included.
058   */
059  ABSTRACT("ABSTRACT"),
060
061
062
063  /**
064   * The object class type for structural object classes.  An entry must have
065   * exactly one structural object class.
066   */
067  STRUCTURAL("STRUCTURAL"),
068
069
070
071  /**
072   * The object class type for auxiliary object classes.  An entry may have any
073   * number of auxiliary classes (although that may potentially be restricted by
074   * DIT content rule definitions in the server).
075   */
076  AUXILIARY("AUXILIARY");
077
078
079
080  // The name for this object class type.
081  private final String name;
082
083
084
085  /**
086   * Creates a new object class type with the specified name.
087   *
088   * @param  name  The name for this object class type.
089   */
090  ObjectClassType(final String name)
091  {
092    this.name = name;
093  }
094
095
096
097  /**
098   * Retrieves the name of this object class type.
099   *
100   * @return  The name of this object class type.
101   */
102  public String getName()
103  {
104    return name;
105  }
106
107
108
109  /**
110   * Retrieves the object class type value with the specified name.
111   *
112   * @param  name  The name of the object class type to retrieve.  It must not
113   *               be {@code null}.
114   *
115   * @return  The object class type with the specified name, or {@code null} if
116   *          there is no type with the given name.
117   */
118  public static ObjectClassType forName(final String name)
119  {
120    switch (StaticUtils.toLowerCase(name))
121    {
122      case "abstract":
123        return ABSTRACT;
124      case "structural":
125        return STRUCTURAL;
126      case "auxiliary":
127        return AUXILIARY;
128      default:
129        return null;
130    }
131  }
132
133
134
135  /**
136   * Retrieves a string representation of this object class type.
137   *
138   * @return  A string representation of this object class type.
139   */
140  @Override()
141  public String toString()
142  {
143    return name;
144  }
145}