001/*
002 * Copyright 2008-2018 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2018 Ping Identity Corporation
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.unboundidds.tasks;
022
023
024
025import com.unboundid.util.ThreadSafety;
026import com.unboundid.util.ThreadSafetyLevel;
027
028import static com.unboundid.util.StaticUtils.*;
029
030
031
032/**
033 * This class defines a failed dependency action, which controls how a task
034 * should behave if any of its dependencies fails.
035 * <BR>
036 * <BLOCKQUOTE>
037 *   <B>NOTE:</B>  This class, and other classes within the
038 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
039 *   supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661
040 *   server products.  These classes provide support for proprietary
041 *   functionality or for external specifications that are not considered stable
042 *   or mature enough to be guaranteed to work in an interoperable way with
043 *   other types of LDAP servers.
044 * </BLOCKQUOTE>
045 */
046@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
047public enum FailedDependencyAction
048{
049  /**
050   * The failed dependency action that indicates the dependent task should go
051   * ahead and continue processing as if none of its dependencies had failed.
052   */
053  PROCESS("process"),
054
055
056
057  /**
058   * The failed dependency action that indicates the dependent task should be
059   * canceled if any of its dependencies had failed.
060   */
061  CANCEL("cancel"),
062
063
064
065  /**
066   * The failed dependency action that indicates the dependent task should be
067   * disabled if any of its dependencies had failed.
068   */
069  DISABLE("disable");
070
071
072
073  // The name of this failed dependency action.
074  private final String name;
075
076
077
078  /**
079   * Creates a new failed dependency action with the specified name.
080   *
081   * @param  name  The name of the failed dependency action to create.
082   */
083  FailedDependencyAction(final String name)
084  {
085    this.name = name;
086  }
087
088
089
090  /**
091   * Retrieves the name of this failed dependency action.
092   *
093   * @return  The name of this failed dependency action.
094   */
095  public String getName()
096  {
097    return name;
098  }
099
100
101
102  /**
103   * Retrieves the failed dependency action with the specified name.
104   *
105   * @param  name  The name of the failed dependency action to retrieve.  It
106   *               must not be {@code null}.
107   *
108   * @return  The requested failed dependency action, or {@code null} if there
109   *          is no action with the given name.
110   */
111  public static FailedDependencyAction forName(final String name)
112  {
113    switch (toLowerCase(name))
114    {
115      case "process":
116        return PROCESS;
117      case "cancel":
118        return CANCEL;
119      case "disable":
120        return DISABLE;
121      default:
122        return null;
123    }
124  }
125
126
127
128  /**
129   * Retrieves a string representation of this failed dependency action.
130   *
131   * @return  A string representation of this failed dependency action.
132   */
133  @Override()
134  public String toString()
135  {
136    return name;
137  }
138}