1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.api.ldap.extras.controls.syncrepl.syncState; 21 22 23 import org.apache.directory.api.i18n.I18n; 24 25 26 /** 27 * 28 * This class describes the four types of states part of the syncStateValue as described in rfc4533. 29 * 30 * state ENUMERATED { 31 * present (0), 32 * add (1), 33 * modify (2), 34 * delete (3), 35 * 36 * #includes the below ApacheDS specific values 37 * moddn(4), 38 * } 39 * 40 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 41 */ 42 public enum SyncStateTypeEnum 43 { 44 /** The entry is present */ 45 PRESENT(0), 46 47 /** The entry has been added */ 48 ADD(1), 49 50 /** The entry has been modified */ 51 MODIFY(2), 52 53 /** The entry has been deleted */ 54 DELETE(3), 55 56 /** The entry has been renamed */ 57 MODDN(4); 58 59 /** the internal value */ 60 private int value; 61 62 63 /** 64 * Private constructor so no other instances can be created other than the 65 * public static constants in this class. 66 * 67 * @param value the integer value of the enumeration. 68 */ 69 SyncStateTypeEnum( int value ) 70 { 71 this.value = value; 72 } 73 74 75 /** 76 * @return The value associated with the current element. 77 */ 78 public int getValue() 79 { 80 return value; 81 } 82 83 84 /** 85 * Get the {@link SyncStateTypeEnum} instance from an integer value. 86 * 87 * @param value The value we want the enum element from 88 * @return The enum element associated with this integer 89 */ 90 public static SyncStateTypeEnum getSyncStateType( int value ) 91 { 92 if ( value == PRESENT.value ) 93 { 94 return PRESENT; 95 } 96 else if ( value == ADD.value ) 97 { 98 return ADD; 99 } 100 else if ( value == MODIFY.value ) 101 { 102 return MODIFY; 103 } 104 else if ( value == DELETE.value ) 105 { 106 return DELETE; 107 } 108 else if ( value == MODDN.value ) 109 { 110 return MODDN; 111 } 112 113 throw new IllegalArgumentException( I18n.err( I18n.ERR_04163, value ) ); 114 } 115 116 }