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.mitosis.operation;
21
22
23 /**
24 *
25 * An enum used to determinate the operation type when deserializing
26 *
27 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
28 * @version $Rev$, $Date$
29 */
30 public enum OperationType
31 {
32 /** The Add Entry operation */
33 ADD_ENTRY(0),
34
35 /** The Add Attribute operation */
36 ADD_ATTRIBUTE(1),
37
38 /** The Delete Attribute operation */
39 DELETE_ATTRIBUTE(2),
40
41 /** The Replace Attribute operation */
42 REPLACE_ATTRIBUTE(3),
43
44 /** The composite operation */
45 COMPOSITE_OPERATION(4);
46
47 /** The associated integer values */
48 private static final int ADD_ENTRY_VALUE = 0;
49 private static final int ADD_ATTRIBUTE_VALUE = 1;
50 private static final int DELETE_ATTRIBUTE_VALUE = 2;
51 private static final int REPLACE_ATTRIBUTE_VALUE = 3;
52 private static final int COMPOSITE_OPERATION_VALUE = 4;
53
54
55 /** The inner value */
56 private int value;
57
58
59 /**
60 * Creates a new instance of OperationType.
61 *
62 * @param value the inner value
63 */
64 private OperationType( int value )
65 {
66 this.value = value;
67 }
68
69
70 /**
71 * @return the associated integer value
72 */
73 public int getValue()
74 {
75 return value;
76 }
77
78
79 /**
80 * Get the associated OperationType from an integer value
81 *
82 * @param value The integer value of an operation type
83 * @return the associated operation type
84 */
85 public static OperationType get( int value )
86 {
87 switch ( value )
88 {
89 case ADD_ENTRY_VALUE :
90 return ADD_ENTRY;
91
92 case ADD_ATTRIBUTE_VALUE :
93 return ADD_ATTRIBUTE;
94
95 case DELETE_ATTRIBUTE_VALUE :
96 return DELETE_ATTRIBUTE;
97
98 case REPLACE_ATTRIBUTE_VALUE :
99 return REPLACE_ATTRIBUTE;
100
101 case COMPOSITE_OPERATION_VALUE :
102 default :
103 return COMPOSITE_OPERATION;
104 }
105 }
106 }