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 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.admin.condition; 028 029 030 031 import org.opends.server.admin.AbstractManagedObjectDefinition; 032 import org.opends.server.admin.client.AuthorizationException; 033 import org.opends.server.admin.client.CommunicationException; 034 import org.opends.server.admin.client.ManagedObject; 035 import org.opends.server.admin.client.ManagementContext; 036 import org.opends.server.admin.server.ServerManagedObject; 037 import org.opends.server.config.ConfigException; 038 import org.opends.server.util.Validator; 039 040 041 042 /** 043 * A condition which evaluates to <code>true</code> if the 044 * sub-condition is <code>false</code>, or <code>false</code> if 045 * the sub-condition is <code>true</code>. 046 */ 047 public final class NOTCondition implements Condition { 048 049 // The single sub-condition. 050 private final Condition condition; 051 052 053 054 /** 055 * Creates a new logical NOT condition with the provided 056 * sub-condition. 057 * 058 * @param condition 059 * The sub-condition which will be inverted. 060 */ 061 public NOTCondition(Condition condition) { 062 Validator.ensureNotNull(condition); 063 this.condition = condition; 064 } 065 066 067 068 /** 069 * {@inheritDoc} 070 */ 071 public boolean evaluate(ManagementContext context, 072 ManagedObject<?> managedObject) throws AuthorizationException, 073 CommunicationException { 074 return !condition.evaluate(context, managedObject); 075 } 076 077 078 079 /** 080 * {@inheritDoc} 081 */ 082 public boolean evaluate(ServerManagedObject<?> managedObject) 083 throws ConfigException { 084 return !condition.evaluate(managedObject); 085 } 086 087 088 089 /** 090 * {@inheritDoc} 091 */ 092 public void initialize(AbstractManagedObjectDefinition<?, ?> d) 093 throws Exception { 094 condition.initialize(d); 095 } 096 097 }