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 package org.apache.directory.shared.ldap.message.control.replication;
021
022
023 /**
024 *
025 * This class describes the four types of states part of the syncStateValue as described in rfc4533.
026 *
027 * state ENUMERATED {
028 * present (0),
029 * add (1),
030 * modify (2),
031 * delete (3)
032 * }
033 *
034 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
035 * @version $Rev$, $Date$
036 */
037 public enum SyncStateTypeEnum
038 {
039 PRESENT(0), ADD(1), MODIFY(2), DELETE(3);
040
041 /** the internal value */
042 private int value;
043
044
045 /**
046 * Private constructor so no other instances can be created other than the
047 * public static constants in this class.
048 *
049 * @param value the integer value of the enumeration.
050 */
051 private SyncStateTypeEnum( int value )
052 {
053 this.value = value;
054 }
055
056
057 /**
058 * @return The value associated with the current element.
059 */
060 public int getValue()
061 {
062 return value;
063 }
064
065
066 /**
067 * Get the {@link SyncStateTypeEnum} instance from an integer value.
068 *
069 * @param value The value we want the enum element from
070 * @return The enum element associated with this integer
071 */
072 public static SyncStateTypeEnum getSyncStateType( int value )
073 {
074 if ( value == PRESENT.value )
075 {
076 return PRESENT;
077 }
078 else if ( value == ADD.value )
079 {
080 return ADD;
081 }
082 else if ( value == MODIFY.value )
083 {
084 return MODIFY;
085 }
086 else if ( value == DELETE.value )
087 {
088 return DELETE;
089 }
090
091 throw new IllegalArgumentException( "Unknown SyncStateTypeEnum value " + value );
092 }
093
094 }