001/* 002 * Copyright 2007-2017 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2008-2017 UnboundID Corp. 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.ThreadSafety; 026import com.unboundid.util.ThreadSafetyLevel; 027 028 029 030/** 031 * This enum defines the set of attribute type usages that are defined in the 032 * LDAP protocol. 033 */ 034@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 035public enum AttributeUsage 036{ 037 /** 038 * The "userApplications" attribute usage. 039 */ 040 USER_APPLICATIONS("userApplications", false), 041 042 043 044 /** 045 * The "directoryOperation" attribute usage. 046 */ 047 DIRECTORY_OPERATION("directoryOperation", true), 048 049 050 051 /** 052 * The "distributedOperation" attribute usage. 053 */ 054 DISTRIBUTED_OPERATION("distributedOperation", true), 055 056 057 058 /** 059 * The "dSAOperation" attribute usage. 060 */ 061 DSA_OPERATION("dSAOperation", true); 062 063 064 065 // Indicates whether this is an operational attribute usage. 066 private final boolean isOperational; 067 068 // The name for this object class type. 069 private final String name; 070 071 072 073 /** 074 * Creates a new attribute usage with the specified name. 075 * 076 * @param name The name for this attribute usage. 077 * @param isOperational Indicates whether this is an operational attribute 078 * usage. 079 */ 080 private AttributeUsage(final String name, final boolean isOperational) 081 { 082 this.name = name; 083 this.isOperational = isOperational; 084 } 085 086 087 088 /** 089 * Retrieves the name of this attribute usage. 090 * 091 * @return The name of this attribute usage. 092 */ 093 public String getName() 094 { 095 return name; 096 } 097 098 099 100 /** 101 * Indicates whether this is an operational attribute usage. 102 * 103 * @return {@code true} if this is an operational attribute usage. 104 */ 105 public boolean isOperational() 106 { 107 return isOperational; 108 } 109 110 111 112 /** 113 * Retrieves the attribute usage value with the specified name. 114 * 115 * @param name The name of the attribute usage to retrieve. 116 * 117 * @return The attribute usage with the specified name, or {@code null} if 118 * there is no usage with the given name. 119 */ 120 public static AttributeUsage forName(final String name) 121 { 122 for (final AttributeUsage u : values()) 123 { 124 if (u.name.equalsIgnoreCase(name)) 125 { 126 return u; 127 } 128 } 129 130 return null; 131 } 132 133 134 135 /** 136 * Retrieves a string representation of this attribute usage. 137 * 138 * @return A string representation of this attribute usage. 139 */ 140 @Override() 141 public String toString() 142 { 143 return name; 144 } 145}