001    /*
002     * Copyright 2014-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.controls;
022    
023    
024    
025    import com.unboundid.util.ThreadSafety;
026    import com.unboundid.util.ThreadSafetyLevel;
027    
028    
029    
030    /**
031     * <BLOCKQUOTE>
032     *   <B>NOTE:</B>  This class is part of the Commercial Edition of the UnboundID
033     *   LDAP SDK for Java.  It is not available for use in applications that
034     *   include only the Standard Edition of the LDAP SDK, and is not supported for
035     *   use in conjunction with non-UnboundID products.
036     * </BLOCKQUOTE>
037     * This enum defines the set of routing types that may be used in a route to
038     * backend set request control.
039     */
040    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
041    public enum RouteToBackendSetRoutingType
042    {
043      /**
044       * The routing type that is used for a control which specifies the absolute
045       * collection of backend sets to which the request should be forwarded.
046       */
047      ABSOLUTE_ROUTING((byte) 0xA0),
048    
049    
050    
051      /**
052       * The routing type that is used for a control which specifies a routing
053       * hint to use as a first guess for processing the request and an optional
054       * collection of fallback sets.
055       */
056      ROUTING_HINT((byte) 0xA1);
057    
058    
059    
060      // The BER type that corresponds to this enum value.
061      private final byte berType;
062    
063    
064    
065      /**
066       * Creates a new route to backend set routing type value with the provided
067       * information.
068       *
069       * @param  berType  The BER type that corresponds to this enum value.
070       */
071      RouteToBackendSetRoutingType(final byte berType)
072      {
073        this.berType = berType;
074      }
075    
076    
077    
078      /**
079       * Retrieves the BER type for this routing type value.
080       *
081       * @return  The BER type for this routing type value.
082       */
083      public byte getBERType()
084      {
085        return berType;
086      }
087    
088    
089    
090      /**
091       * Retrieves the routing type value for the provided BER type.
092       *
093       * @param  berType  The BER type for the routing type value to retrieve.
094       *
095       * @return  The routing type value that corresponds to the provided BER type,
096       *          or {@code null} if there is no corresponding routing type value.
097       */
098      public static RouteToBackendSetRoutingType valueOf(final byte berType)
099      {
100        for (final RouteToBackendSetRoutingType t : values())
101        {
102          if (t.berType == berType)
103          {
104            return t;
105          }
106        }
107    
108        return null;
109      }
110    }