Skip to content

Commit 6e32f7f

Browse files
committed
code review fixes
1 parent 54829a2 commit 6e32f7f

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,10 @@ The name of the directive will be taken from the ``@GraphQLName`` annotation (if
343343
The description of the directive will be taken from the ``@GraphQLDescription`` annotation's value.
344344
The valid locations of the directive (locations which the directive can be applied on) will be taken from ``@DirectiveLocations``.
345345
The arguments of the directive will be taken from the fields defined in the class - notice that you can only use primitive types as arguments of a directive.
346-
For example, we defined an ``isActive`` field - which is boolean, and it's default value is true. That's how the argument of the directive will be defined.
346+
For example, we defined an ``isActive`` field - which is boolean, and its default value is true. That's how the argument of the directive will be defined.
347347
You can also use ``@GraphQLName`` and ``@GraphQLDescription`` annotations on the field.
348348

349-
After you created the class, you will be able to create the ``GraphQLDirective`` object with the following code:
349+
After you created the class, you will be able to create the ``GraphQLDirective`` object using the following code:
350350
```java
351351
GraphQLAnnotations.directive(UpperDirective.class);
352352
```
@@ -371,7 +371,7 @@ public class UpperWiring implements AnnotationsDirectiveWiring {
371371
}
372372
}
373373
```
374-
This class turns you string field to upper case if the directive argument "isActive" is set to true.
374+
This class turns your string field to upper case if the directive argument "isActive" is set to true.
375375
Now, you have to wire the field itself:
376376
```java
377377
@GraphQLField

src/main/java/graphql/annotations/processor/directives/CommonPropertiesCreator.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* Copyright 2016 Yurii Rashkovskii
3-
*
3+
* <p>
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,11 +33,9 @@ public String getName(AnnotatedElement annotatedElement) {
3333
GraphQLName graphQLNameAnnotation = annotatedElement.getAnnotation(GraphQLName.class);
3434
if (graphQLNameAnnotation != null) {
3535
return graphQLNameAnnotation.value();
36-
}
37-
if (annotatedElement instanceof Class<?>) {
36+
} else if (annotatedElement instanceof Class<?>) {
3837
return ((Class<?>) annotatedElement).getSimpleName();
39-
}
40-
else if (annotatedElement instanceof Field){
38+
} else if (annotatedElement instanceof Field) {
4139
return ((Field) annotatedElement).getName();
4240
}
4341
return null;

src/main/java/graphql/annotations/processor/directives/DirectiveArgumentCreator.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* Copyright 2016 Yurii Rashkovskii
3-
*
3+
* <p>
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,10 +37,10 @@ public DirectiveArgumentCreator(CommonPropertiesCreator commonPropertiesCreator,
3737

3838

3939
public GraphQLArgument getArgument(Field field, Class<?> containingClass) {
40-
GraphQLArgument.Builder builder = newArgument();
41-
builder.name(commonPropertiesCreator.getName(field));
42-
builder.description(commonPropertiesCreator.getDescription(field));
43-
builder.type(getType(field));
40+
GraphQLArgument.Builder builder = newArgument()
41+
.name(commonPropertiesCreator.getName(field))
42+
.description(commonPropertiesCreator.getDescription(field))
43+
.type(getType(field));
4444
try {
4545
builder.defaultValue(getDefaultValue(field, containingClass));
4646
} catch (IllegalAccessException | InstantiationException e) {

src/main/java/graphql/annotations/processor/directives/DirectiveCreator.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public DirectiveCreator(DirectiveArgumentCreator directiveArgumentCreator, Commo
3535
}
3636

3737
public GraphQLDirective getDirective(Class<?> annotatedClass) {
38-
GraphQLDirective.Builder builder = newDirective();
39-
builder.name(commonPropertiesCreator.getName(annotatedClass));
40-
builder.description(commonPropertiesCreator.getDescription(annotatedClass));
38+
GraphQLDirective.Builder builder = newDirective()
39+
.name(commonPropertiesCreator.getName(annotatedClass))
40+
.description(commonPropertiesCreator.getDescription(annotatedClass));
4141
Introspection.DirectiveLocation[] validLocations = getValidLocations(annotatedClass);
4242
if (validLocations == null || validLocations.length == 0) {
4343
throw new GraphQLAnnotationsException("No valid locations defined on directive", null);

0 commit comments

Comments
 (0)