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 2015 ForgeRock AS. 026 */ 027 028package org.opends.server.authorization.dseecompat; 029 030/** 031 * This class provides an enumeration of the valid ACI target operators. 032 */ 033public enum EnumTargetOperator { 034 035 /** 036 * This enumeration is returned when the target operator is "=". 037 */ 038 EQUALITY ("="), 039 /** 040 * This enumeration is returned when the target operator is "!=". 041 */ 042 NOT_EQUALITY ("!="); 043 044 /** The target operator name. */ 045 private final String operator; 046 047 /** 048 * Create an enumeration of the provided operator name. 049 * @param operator The operator name to create. 050 */ 051 EnumTargetOperator(String operator){ 052 this.operator = operator; 053 } 054 055 /** 056 * Checks if the provided operator name is equal to the enumeration. 057 * @param op The operator name to check for. 058 * @return True if the operator name is equal to the enumeration. 059 */ 060 public boolean isOperator(String op){ 061 return op.equalsIgnoreCase(operator); 062 } 063 064 /** 065 * Creates an enumeration of the specified operator type name. 066 * @param op The operator type name to create. 067 * @return Return an enumeration of the operator type name or null if the 068 * name is invalid. 069 */ 070 public static EnumTargetOperator createOperator(String op){ 071 if (op != null){ 072 for (EnumTargetOperator t : EnumTargetOperator.values()){ 073 if (t.isOperator(op)){ 074 return t; 075 } 076 } 077 } 078 return null; 079 } 080}