|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2018 the original author or authors. |
| 2 | + * Copyright 2002-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
41 | 41 |
|
42 | 42 | /**
|
43 | 43 | * Decorator for a standard {@link BeanInfo} object, e.g. as created by
|
44 |
| - * {@link Introspector#getBeanInfo(Class)}, designed to discover and register static |
45 |
| - * and/or non-void returning setter methods. For example: |
| 44 | + * {@link Introspector#getBeanInfo(Class)}, designed to discover and register |
| 45 | + * static and/or non-void returning setter methods. For example: |
46 | 46 | *
|
47 | 47 | * <pre class="code">
|
48 | 48 | * public class Bean {
|
@@ -145,11 +145,10 @@ private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescript
|
145 | 145 |
|
146 | 146 | public static boolean isCandidateWriteMethod(Method method) {
|
147 | 147 | String methodName = method.getName();
|
148 |
| - Class<?>[] parameterTypes = method.getParameterTypes(); |
149 |
| - int nParams = parameterTypes.length; |
| 148 | + int nParams = method.getParameterCount(); |
150 | 149 | return (methodName.length() > 3 && methodName.startsWith("set") && Modifier.isPublic(method.getModifiers()) &&
|
151 | 150 | (!void.class.isAssignableFrom(method.getReturnType()) || Modifier.isStatic(method.getModifiers())) &&
|
152 |
| - (nParams == 1 || (nParams == 2 && int.class == parameterTypes[0]))); |
| 151 | + (nParams == 1 || (nParams == 2 && int.class == method.getParameterTypes()[0]))); |
153 | 152 | }
|
154 | 153 |
|
155 | 154 | private void handleCandidateWriteMethod(Method method) throws IntrospectionException {
|
@@ -209,7 +208,7 @@ private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, C
|
209 | 208 | }
|
210 | 209 |
|
211 | 210 | private String propertyNameFor(Method method) {
|
212 |
| - return Introspector.decapitalize(method.getName().substring(3, method.getName().length())); |
| 211 | + return Introspector.decapitalize(method.getName().substring(3)); |
213 | 212 | }
|
214 | 213 |
|
215 | 214 |
|
@@ -488,7 +487,7 @@ public void setPropertyEditorClass(@Nullable Class<?> propertyEditorClass) {
|
488 | 487 | }
|
489 | 488 |
|
490 | 489 | /*
|
491 |
| - * See java.beans.IndexedPropertyDescriptor#equals(java.lang.Object) |
| 490 | + * See java.beans.IndexedPropertyDescriptor#equals |
492 | 491 | */
|
493 | 492 | @Override
|
494 | 493 | public boolean equals(Object other) {
|
@@ -535,11 +534,13 @@ static class PropertyDescriptorComparator implements Comparator<PropertyDescript
|
535 | 534 | public int compare(PropertyDescriptor desc1, PropertyDescriptor desc2) {
|
536 | 535 | String left = desc1.getName();
|
537 | 536 | String right = desc2.getName();
|
| 537 | + byte[] leftBytes = left.getBytes(); |
| 538 | + byte[] rightBytes = right.getBytes(); |
538 | 539 | for (int i = 0; i < left.length(); i++) {
|
539 | 540 | if (right.length() == i) {
|
540 | 541 | return 1;
|
541 | 542 | }
|
542 |
| - int result = left.getBytes()[i] - right.getBytes()[i]; |
| 543 | + int result = leftBytes[i] - rightBytes[i]; |
543 | 544 | if (result != 0) {
|
544 | 545 | return result;
|
545 | 546 | }
|
|
0 commit comments