001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2008 Sun Microsystems, Inc. 025 * Portions Copyright 2013 ForgeRock AS 026 */ 027package org.opends.server.authorization.dseecompat; 028 029/** 030 * This class provides an enumeration of the allowed bind rule types. 031 */ 032public enum EnumBindRuleType { 033 034 /** 035 * The enumeration type when the bind rule has specified type of 036 * "=". 037 */ 038 EQUAL_BINDRULE_TYPE ("="), 039 /** 040 * The enumeration type when the bind rule has specified type of 041 * "!=". 042 */ 043 NOT_EQUAL_BINDRULE_TYPE ("!="), 044 /** 045 * The enumeration type when the bind rule has specified type of 046 * "<". 047 */ 048 LESS_BINDRULE_TYPE ("<"), 049 /** 050 * The enumeration type when the bind rule has specified type of 051 * "<=". 052 */ 053 LESS_OR_EQUAL_BINDRULE_TYPE ("<="), 054 /** 055 * The enumeration type when the bind rule has specified type of 056 * >". 057 */ 058 GREATER_BINDRULE_TYPE (">"), 059 /** 060 * The enumeration type when the bind rule has specified type of 061 * ">=". 062 */ 063 GREATER_OR_EQUAL_BINDRULE_TYPE (">="); 064 065 /** The bind rule type name. */ 066 private final String type; 067 068 /** 069 * Creates a new enumeration type for the specified bind rule type. 070 * @param type The bind rule type name. 071 */ 072 EnumBindRuleType(String type){ 073 this.type = type; 074 } 075 076 /** 077 * Returns the comparison operator corresponding to this EnumBindRuleType. 078 * 079 * @return the string representing the comparison operator 080 */ 081 public String getType() 082 { 083 return type; 084 } 085 086 /** 087 * Checks to see if the type string is equal to the enumeration type 088 * name. 089 * @param type The type name to check equality for. 090 * @return True if the keyword is equal to the specified name. 091 */ 092 public boolean isBindRuleType(String type){ 093 return type.equals(this.type); 094 } 095 096 /** 097 * Create a new enumeration type for the specified type name. 098 * @param type The name of the enumeration to create. 099 * @return A new enumeration type for the name or null if the name is 100 * not valid. 101 */ 102 public static EnumBindRuleType createBindruleOperand(String type){ 103 if (type != null){ 104 for (EnumBindRuleType t : EnumBindRuleType.values()){ 105 if (t.isBindRuleType(type)){ 106 return t; 107 } 108 } 109 } 110 return null; 111 } 112}