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