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