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 2006-2008 Sun Microsystems, Inc.
026     */
027    package org.opends.server.types;
028    
029    
030    
031    /**
032     * This enumeration defines a result that could be returned from a
033     * boolean operation that may evaluate to true or false, but may also
034     * be undefined (i.e., "maybe").  A result of undefined indicates that
035     * further investigation may be required.
036     */
037    @org.opends.server.types.PublicAPI(
038         stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
039         mayInstantiate=false,
040         mayExtend=false,
041         mayInvoke=true)
042    public enum ConditionResult
043    {
044      /**
045       * Indicates that the result of the associated check returned
046       * "true".
047       */
048      TRUE("true"),
049    
050    
051    
052      /**
053       * Indicates that the result of the associated check returned
054       * "false".
055       */
056      FALSE("false"),
057    
058    
059    
060      /**
061       * Indicates that the associated check did not yield a definitive
062       * result and that additional checking might be required.
063       */
064      UNDEFINED("undefined");
065    
066    
067    
068      // The human-readable name for this result.
069      private String resultName;
070    
071    
072    
073      /**
074       * Creates a new condition result with the provided name.
075       *
076       * @param  resultName  The human-readable name for this condition
077       *                     result.
078       */
079      private ConditionResult(String resultName)
080      {
081        this.resultName = resultName;
082      }
083    
084      /**
085       Returns the logical inverse of a ConditionResult value. The inverse
086       of the UNDEFINED value is UNDEFINED.
087    
088       @param value The value to invert.
089       @return The logical inverse of the supplied value.
090       */
091      public static ConditionResult inverseOf(ConditionResult value) {
092        switch (value) {
093          case TRUE:
094            return FALSE;
095          case FALSE:
096            return TRUE;
097          case UNDEFINED:
098            return UNDEFINED;
099        }
100        assert false : "internal error: missing switch case" ;
101        return UNDEFINED;
102      }
103    
104    
105      /**
106       * Retrieves the human-readable name for this condition result.
107       *
108       * @return  The human-readable name for this condition result.
109       */
110      public String toString()
111      {
112        return resultName;
113      }
114    }
115