public int compare(JMethod a, JMethod b) { if (a.isPublic() != b.isPublic()) { return a.isPublic() ? -1 : 1; } if (a.isDefaultAccess() != b.isDefaultAccess()) { return a.isDefaultAccess() ? -1 : 1; } if (a.isProtected() != b.isProtected()) { return a.isProtected() ? -1 : 1; } int c = a.getName().compareTo(b.getName()); if (c != 0) { return c; } JParameter[] aParams = a.getParameters(); JParameter[] bParams = b.getParameters(); c = aParams.length - bParams.length; if (c != 0) { return c; } for (int i = 0; i < aParams.length; ++i) { c = aParams[i].getName().compareTo(bParams[i].getName()); if (c != 0) { return c; } } return 0; } }
public int compare(JMethod a, JMethod b) { if (a.isPublic() != b.isPublic()) { return a.isPublic() ? -1 : 1; } if (a.isDefaultAccess() != b.isDefaultAccess()) { return a.isDefaultAccess() ? -1 : 1; } if (a.isProtected() != b.isProtected()) { return a.isProtected() ? -1 : 1; } int c = a.getName().compareTo(b.getName()); if (c != 0) { return c; } JParameter[] aParams = a.getParameters(); JParameter[] bParams = b.getParameters(); c = aParams.length - bParams.length; if (c != 0) { return c; } for (int i = 0; i < aParams.length; ++i) { c = aParams[i].getName().compareTo(bParams[i].getName()); if (c != 0) { return c; } } return 0; } }
private static boolean isSetterAutoDetected( RebindConfiguration configuration, PropertyAccessors propertyAccessors, BeanInfo info ) { if ( !propertyAccessors.getSetter().isPresent() ) { return false; } for ( Class<? extends Annotation> annotation : AUTO_DISCOVERY_ANNOTATIONS ) { if ( propertyAccessors.isAnnotationPresentOnSetter( annotation ) ) { return true; } } JMethod setter = propertyAccessors.getSetter().get(); String methodName = setter.getName(); if ( !methodName.startsWith( "set" ) || methodName.length() <= 3 ) { // no annotation on method and the method does not follow naming convention return false; } JsonAutoDetect.Visibility visibility = info.getSetterVisibility(); if ( Visibility.DEFAULT == visibility ) { visibility = configuration.getDefaultSetterVisibility(); } return isAutoDetected( visibility, setter.isPrivate(), setter.isProtected(), setter.isPublic(), setter .isDefaultAccess() ); }
private static boolean isGetterAutoDetected( RebindConfiguration configuration, PropertyAccessors propertyAccessors, BeanInfo info ) { if ( !propertyAccessors.getGetter().isPresent() ) { return false; } for ( Class<? extends Annotation> annotation : AUTO_DISCOVERY_ANNOTATIONS ) { if ( propertyAccessors.isAnnotationPresentOnGetter( annotation ) ) { return true; } } JMethod getter = propertyAccessors.getGetter().get(); String methodName = getter.getName(); JsonAutoDetect.Visibility visibility; if ( methodName.startsWith( "is" ) && methodName.length() > 2 && JPrimitiveType.BOOLEAN.equals( getter.getReturnType() .isPrimitive() ) ) { // getter method for a boolean visibility = info.getIsGetterVisibility(); if ( Visibility.DEFAULT == visibility ) { visibility = configuration.getDefaultIsGetterVisibility(); } } else if ( methodName.startsWith( "get" ) && methodName.length() > 3 ) { visibility = info.getGetterVisibility(); if ( Visibility.DEFAULT == visibility ) { visibility = configuration.getDefaultGetterVisibility(); } } else { // no annotation on method and the method does not follow naming convention return false; } return isAutoDetected( visibility, getter.isPrivate(), getter.isProtected(), getter.isPublic(), getter.isDefaultAccess() ); }
break; case DEFAULT: accessible = method.isDefaultAccess(); break; case PROTECTED: