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 PRESENT(0), ADD(1), MODIFY(2), DELETE(3), MODDN(4); 45 46 /** the internal value */ 47 private int value; 48 49 50 /** 51 * Private constructor so no other instances can be created other than the 52 * public static constants in this class. 53 * 54 * @param value the integer value of the enumeration. 55 */ 56 private SyncStateTypeEnum( int value ) 57 { 58 this.value = value; 59 } 60 61 62 /** 63 * @return The value associated with the current element. 64 */ 65 public int getValue() 66 { 67 return value; 68 } 69 70 71 /** 72 * Get the {@link SyncStateTypeEnum} instance from an integer value. 73 * 74 * @param value The value we want the enum element from 75 * @return The enum element associated with this integer 76 */ 77 public static SyncStateTypeEnum getSyncStateType( int value ) 78 { 79 if ( value == PRESENT.value ) 80 { 81 return PRESENT; 82 } 83 else if ( value == ADD.value ) 84 { 85 return ADD; 86 } 87 else if ( value == MODIFY.value ) 88 { 89 return MODIFY; 90 } 91 else if ( value == DELETE.value ) 92 { 93 return DELETE; 94 } 95 else if ( value == MODDN.value ) 96 { 97 return MODDN; 98 } 99 100 throw new IllegalArgumentException( I18n.err( I18n.ERR_04163, value ) ); 101 } 102 103 }