001/*
002 *   Licensed to the Apache Software Foundation (ASF) under one
003 *   or more contributor license agreements.  See the NOTICE file
004 *   distributed with this work for additional information
005 *   regarding copyright ownership.  The ASF licenses this file
006 *   to you under the Apache License, Version 2.0 (the
007 *   "License"); you may not use this file except in compliance
008 *   with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *   Unless required by applicable law or agreed to in writing,
013 *   software distributed under the License is distributed on an
014 *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *   KIND, either express or implied.  See the License for the
016 *   specific language governing permissions and limitations
017 *   under the License.
018 *
019 */
020
021package org.apache.directory.api.ldap.extras.controls;
022
023import org.apache.directory.api.i18n.I18n;
024
025/**
026 * The type of MODDN modification. One of MOVE, RENAME or MOVE_AND_RENAME
027 *
028 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
029 */
030public enum SyncModifyDnType
031{
032    /** A Move operation */
033    MOVE(0),
034    
035    /** A Rename operation */
036    RENAME(1),
037    
038    /** A Move and Rename operation */
039    MOVE_AND_RENAME(2);
040
041    /** Internal value for each tag */
042    private int value;
043
044
045    /**
046     * Creates the value
047     * 
048     * @param value The MOD DN type
049     */
050    SyncModifyDnType( int value )
051    {
052        this.value = value;
053    }
054
055
056    /**
057     * @return The value associated with the current element.
058     */
059    public int getValue()
060    {
061        return value;
062    }
063
064
065    /**
066     * Get the instance from it's interger value
067     * @param value The value we are looking for 
068     * @return The associated value
069     */
070    public static SyncModifyDnType getModifyDnType( int value )
071    {
072        switch ( value )
073        {
074            case 0:
075                return MOVE;
076
077            case 1:
078                return RENAME;
079
080            case 2:
081                return MOVE_AND_RENAME;
082
083            default:
084                throw new IllegalArgumentException( I18n.err( I18n.ERR_9101_UNKNOWN_MODIFY_DN_OP_TYPE, value ) );
085        }
086    }
087}