001/*
002 * Copyright 2007-2022 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2007-2022 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) 2007-2022 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.NotNull;
041import com.unboundid.util.Nullable;
042import com.unboundid.util.StaticUtils;
043import com.unboundid.util.ThreadSafety;
044import com.unboundid.util.ThreadSafetyLevel;
045
046
047
048/**
049 * This enum defines the set of object class types that are defined in the LDAP
050 * protocol.
051 */
052@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
053public enum ObjectClassType
054{
055  /**
056   * The object class type for abstract object classes.  An abstract object
057   * class may only serve as the superclass for another object class, and may
058   * not appear in an entry unless at least one of its non-abstract subclasses
059   * is also included.
060   */
061  ABSTRACT("ABSTRACT"),
062
063
064
065  /**
066   * The object class type for structural object classes.  An entry must have
067   * exactly one structural object class.
068   */
069  STRUCTURAL("STRUCTURAL"),
070
071
072
073  /**
074   * The object class type for auxiliary object classes.  An entry may have any
075   * number of auxiliary classes (although that may potentially be restricted by
076   * DIT content rule definitions in the server).
077   */
078  AUXILIARY("AUXILIARY");
079
080
081
082  // The name for this object class type.
083  @NotNull private final String name;
084
085
086
087  /**
088   * Creates a new object class type with the specified name.
089   *
090   * @param  name  The name for this object class type.
091   */
092  ObjectClassType(@NotNull final String name)
093  {
094    this.name = name;
095  }
096
097
098
099  /**
100   * Retrieves the name of this object class type.
101   *
102   * @return  The name of this object class type.
103   */
104  @NotNull()
105  public String getName()
106  {
107    return name;
108  }
109
110
111
112  /**
113   * Retrieves the object class type value with the specified name.
114   *
115   * @param  name  The name of the object class type to retrieve.  It must not
116   *               be {@code null}.
117   *
118   * @return  The object class type with the specified name, or {@code null} if
119   *          there is no type with the given name.
120   */
121  @Nullable()
122  public static ObjectClassType forName(@NotNull final String name)
123  {
124    switch (StaticUtils.toLowerCase(name))
125    {
126      case "abstract":
127        return ABSTRACT;
128      case "structural":
129        return STRUCTURAL;
130      case "auxiliary":
131        return AUXILIARY;
132      default:
133        return null;
134    }
135  }
136
137
138
139  /**
140   * Retrieves a string representation of this object class type.
141   *
142   * @return  A string representation of this object class type.
143   */
144  @Override()
145  @NotNull()
146  public String toString()
147  {
148    return name;
149  }
150}