-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor changes #880
Refactor changes #880
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1762,12 +1762,7 @@ private void populateMap(Object bean, Set<Object> objectsRecord) { | |
Method[] methods = includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods(); | ||
for (final Method method : methods) { | ||
final int modifiers = method.getModifiers(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable |
||
if (Modifier.isPublic(modifiers) | ||
&& !Modifier.isStatic(modifiers) | ||
&& method.getParameterTypes().length == 0 | ||
&& !method.isBridge() | ||
&& method.getReturnType() != Void.TYPE | ||
&& isValidMethodName(method.getName())) { | ||
if (isValidMethod(modifiers, method)) { | ||
final String key = getKeyNameFromMethod(method); | ||
if (key != null && !key.isEmpty()) { | ||
try { | ||
|
@@ -1806,6 +1801,15 @@ && isValidMethodName(method.getName())) { | |
} | ||
} | ||
|
||
private boolean isValidMethod(int modifiers,Method method) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a JavaDoc comment to this new method. |
||
return Modifier.isPublic(modifiers) | ||
&& !Modifier.isStatic(modifiers) | ||
&& method.getParameterTypes().length == 0 | ||
&& !method.isBridge() | ||
&& method.getReturnType() != Void.TYPE | ||
&& isValidMethodName(method.getName()); | ||
} | ||
|
||
private static boolean isValidMethodName(String name) { | ||
return !"getClass".equals(name) && !"getDeclaringClass".equals(name); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that the refactoring update in this method is a good idea. Although it shortens the method, it hides a more interesting potential refactoring - notice how many times
status-code
,reason-phrase
,method
,request-uri
, andhttp-version
are referenced in the conditionals. It makes the code look half-finished. Can you come up with a way to reduce the number of conditions being checked without affecting the output ordering?