001/* 002 * Copyright 2014-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.controls; 022 023 024 025import com.unboundid.util.StaticUtils; 026import com.unboundid.util.ThreadSafety; 027import com.unboundid.util.ThreadSafetyLevel; 028 029 030 031/** 032 * This enum defines the set of routing types that may be used in a route to 033 * backend set request control. 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 RouteToBackendSetRoutingType 047{ 048 /** 049 * The routing type that is used for a control which specifies the absolute 050 * collection of backend sets to which the request should be forwarded. 051 */ 052 ABSOLUTE_ROUTING((byte) 0xA0), 053 054 055 056 /** 057 * The routing type that is used for a control which specifies a routing 058 * hint to use as a first guess for processing the request and an optional 059 * collection of fallback sets. 060 */ 061 ROUTING_HINT((byte) 0xA1); 062 063 064 065 // The BER type that corresponds to this enum value. 066 private final byte berType; 067 068 069 070 /** 071 * Creates a new route to backend set routing type value with the provided 072 * information. 073 * 074 * @param berType The BER type that corresponds to this enum value. 075 */ 076 RouteToBackendSetRoutingType(final byte berType) 077 { 078 this.berType = berType; 079 } 080 081 082 083 /** 084 * Retrieves the BER type for this routing type value. 085 * 086 * @return The BER type for this routing type value. 087 */ 088 public byte getBERType() 089 { 090 return berType; 091 } 092 093 094 095 /** 096 * Retrieves the routing type value for the provided BER type. 097 * 098 * @param berType The BER type for the routing type value to retrieve. 099 * 100 * @return The routing type value that corresponds to the provided BER type, 101 * or {@code null} if there is no corresponding routing type value. 102 */ 103 public static RouteToBackendSetRoutingType valueOf(final byte berType) 104 { 105 for (final RouteToBackendSetRoutingType t : values()) 106 { 107 if (t.berType == berType) 108 { 109 return t; 110 } 111 } 112 113 return null; 114 } 115 116 117 118 /** 119 * Retrieves the route to backend set routing type with the specified name. 120 * 121 * @param name The name of the route to backend set routing type to 122 * retrieve. It must not be {@code null}. 123 * 124 * @return The requested route to backend set routing type, or {@code null} 125 * if no such type is defined. 126 */ 127 public static RouteToBackendSetRoutingType forName(final String name) 128 { 129 switch (StaticUtils.toLowerCase(name)) 130 { 131 case "absoluterouting": 132 case "absolute-routing": 133 case "absolute_routing": 134 return ABSOLUTE_ROUTING; 135 case "routinghint": 136 case "routing-hint": 137 case "routing_hint": 138 return ROUTING_HINT; 139 default: 140 return null; 141 } 142 } 143}