Skip to content

reorder REST services parameter converter#1358

Merged
rfecher merged 5 commits intolocationtech:masterfrom
cjw5db:pr-branch
Jul 24, 2018
Merged

reorder REST services parameter converter#1358
rfecher merged 5 commits intolocationtech:masterfrom
cjw5db:pr-branch

Conversation

@cjw5db
Copy link
Copy Markdown
Contributor

@cjw5db cjw5db commented Jul 19, 2018

No description provided.

final String strValue = (String) requestParameters.getString(f.getName());

if (field.isAnnotationPresent(Parameter.class)) {
Class<? extends IStringConverter<?>> converter = field.getAnnotation(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So right here, the code gets the Class object and tries to see if it is one of the converters, or if it's "NoConverter." It does this for every single field, even though only a few have converters, which seems inefficient to me. However, it is important to do this before some of the other checks, because there are certain cases where the other checks would catch the type. I.E. passwordCoverter converts a string to another string, so that would get caught in the String check

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems reasonable enough, I'd check for converter == null at the front of the if statement even though apparently it must always get set to "NoConverter" in practice just to add a little more protection from NPEs

}

public Field getField() {
return super.getField();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why bother to override the method if its just going to delegate with super?

',');
}

public Field getField() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why bother to override the method if its just going to delegate with super?

@coveralls
Copy link
Copy Markdown

coveralls commented Jul 19, 2018

Coverage Status

Coverage increased (+0.3%) to 48.587% when pulling 7e2b6bb on cjw5db:pr-branch into 19b0d3f on locationtech:master.

Copy link
Copy Markdown
Contributor Author

@cjw5db cjw5db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beginner mistake with the super methods. removed these and also added the null check in my last commit

@rfecher rfecher merged commit 46cdb31 into locationtech:master Jul 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants