Skip to content

Commit 7fa2f7e

Browse files
committed
Better internal name and comments
Javadoc
1 parent 325d06c commit 7fa2f7e

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,20 @@ public boolean isVarArgs() {
7171

7272
private static final int ACCESS_TEST = Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE;
7373

74-
/** Array of primitive number types ordered by "promotability" */
75-
private static final Class<?>[] ORDERED_PRIMITIVE_TYPES = { Byte.TYPE, Short.TYPE,
76-
Character.TYPE, Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE };
74+
/**
75+
* Array of primitive number types ordered by "promotability" from narrow to wide.
76+
*/
77+
private static final Class<?>[] WIDENING_PRIMITIVE_TYPES = {
78+
// @formatter:off
79+
Byte.TYPE, // byte
80+
Short.TYPE, // short
81+
Character.TYPE, // char
82+
Integer.TYPE, // int
83+
Long.TYPE, // long
84+
Float.TYPE, // float
85+
Double.TYPE // double
86+
// @formatter:on
87+
};
7788

7889
/**
7990
* Compares the relative fitness of two Constructors in terms of how well they
@@ -128,10 +139,9 @@ private static int compareParameterTypes(final Executable left, final Executable
128139
}
129140

130141
/**
131-
* Gets the number of steps needed to turn the source class into
132-
* the destination class. This represents the number of steps in the object
133-
* hierarchy graph.
134-
* @param srcClass The source class
142+
* Gets the number of steps needed to turn the source class into the destination class. This represents the number of steps in the object hierarchy graph.
143+
*
144+
* @param srcClass The source class
135145
* @param destClass The destination class
136146
* @return The cost of transforming an object
137147
*/
@@ -163,9 +173,9 @@ private static float getObjectTransformationCost(Class<?> srcClass, final Class<
163173
}
164174

165175
/**
166-
* Gets the number of steps required to promote a primitive number to another
167-
* type.
168-
* @param srcClass the (primitive) source class
176+
* Gets the number of steps required to promote a primitive number to another type.
177+
*
178+
* @param srcClass the (primitive) source class
169179
* @param destClass the (primitive) destination class
170180
* @return The cost of promoting the primitive
171181
*/
@@ -180,21 +190,21 @@ private static float getPrimitivePromotionCost(final Class<?> srcClass, final Cl
180190
cost += 0.1f;
181191
cls = ClassUtils.wrapperToPrimitive(cls);
182192
}
183-
for (int i = 0; cls != destClass && i < ORDERED_PRIMITIVE_TYPES.length; i++) {
184-
if (cls == ORDERED_PRIMITIVE_TYPES[i]) {
193+
for (int i = 0; cls != destClass && i < WIDENING_PRIMITIVE_TYPES.length; i++) {
194+
if (cls == WIDENING_PRIMITIVE_TYPES[i]) {
185195
cost += 0.1f;
186-
if (i < ORDERED_PRIMITIVE_TYPES.length - 1) {
187-
cls = ORDERED_PRIMITIVE_TYPES[i + 1];
196+
if (i < WIDENING_PRIMITIVE_TYPES.length - 1) {
197+
cls = WIDENING_PRIMITIVE_TYPES[i + 1];
188198
}
189199
}
190200
}
191201
return cost;
192202
}
193203

194204
/**
195-
* Gets the sum of the object transformation cost for each class in the
196-
* source argument list.
197-
* @param srcArgs The source arguments
205+
* Gets the sum of the object transformation cost for each class in the source argument list.
206+
*
207+
* @param srcArgs The source arguments
198208
* @param executable The executable to calculate transformation costs for
199209
* @return The total transformation cost
200210
*/

0 commit comments

Comments
 (0)