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