Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 4de9199

Browse files
committed
chore: apply google code format
1 parent 83760d8 commit 4de9199

File tree

6 files changed

+92
-63
lines changed

6 files changed

+92
-63
lines changed

voyager-spring-boot-autoconfigure/src/main/java/graphql/kickstart/voyager/boot/ReactiveVoyagerAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public RouterFunction<ServerResponse> voyagerStaticFilesRouter() {
2929
}
3030

3131
@Bean
32-
VoyagerIndexHtmlTemplate voyagerIndexHtmlTemplate(final VoyagerPropertiesConfiguration voyagerPropertiesConfiguration) {
32+
VoyagerIndexHtmlTemplate voyagerIndexHtmlTemplate(
33+
final VoyagerPropertiesConfiguration voyagerPropertiesConfiguration) {
3334
return new VoyagerIndexHtmlTemplate(voyagerPropertiesConfiguration);
3435
}
3536
}

voyager-spring-boot-autoconfigure/src/main/java/graphql/kickstart/voyager/boot/VoyagerAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ VoyagerController voyagerController() {
1919
}
2020

2121
@Bean
22-
VoyagerIndexHtmlTemplate voyagerIndexHtmlTemplate(final VoyagerPropertiesConfiguration voyagerPropertiesConfiguration) {
22+
VoyagerIndexHtmlTemplate voyagerIndexHtmlTemplate(
23+
final VoyagerPropertiesConfiguration voyagerPropertiesConfiguration) {
2324
return new VoyagerIndexHtmlTemplate(voyagerPropertiesConfiguration);
2425
}
2526
}

voyager-spring-boot-autoconfigure/src/main/java/graphql/kickstart/voyager/boot/VoyagerIndexHtmlTemplate.java

Lines changed: 71 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,65 +11,95 @@
1111
import org.springframework.util.StreamUtils;
1212
import org.springframework.web.bind.annotation.RequestParam;
1313

14-
/**
15-
* @author Guilherme Blanco
16-
*/
14+
/** @author Guilherme Blanco */
1715
@RequiredArgsConstructor
1816
public class VoyagerIndexHtmlTemplate {
1917

2018
private static final String CDNJS_CLOUDFLARE_COM_AJAX_LIBS = "//cdnjs.cloudflare.com/ajax/libs/";
2119
private static final String CDN_JSDELIVR_NET_NPM = "//cdn.jsdelivr.net/npm/";
2220
private static final String VOYAGER = "graphql-voyager";
23-
private static final String FAVICON_APIS_GURU = "//apis.guru/graphql-voyager/icons/favicon-16x16.png";
21+
private static final String FAVICON_APIS_GURU =
22+
"//apis.guru/graphql-voyager/icons/favicon-16x16.png";
2423

2524
private final VoyagerPropertiesConfiguration voyagerConfiguration;
2625

2726
public String fillIndexTemplate(String contextPath, Map<String, String> params)
2827
throws IOException {
29-
String template = StreamUtils
30-
.copyToString(new ClassPathResource("voyager.html").getInputStream(),
31-
Charset.defaultCharset());
28+
String template =
29+
StreamUtils.copyToString(
30+
new ClassPathResource("voyager.html").getInputStream(), Charset.defaultCharset());
3231

3332
String basePath = voyagerConfiguration.getBasePath();
3433
String voyagerCdnVersion = voyagerConfiguration.getCdn().getVersion();
3534

3635
Map<String, String> replacements = new HashMap<>();
3736
replacements.put("graphqlEndpoint", constructGraphQlEndpoint(contextPath, params));
3837
replacements.put("pageTitle", voyagerConfiguration.getPageTitle());
39-
replacements
40-
.put("pageFavicon", getResourceUrl(basePath, "favicon.ico", FAVICON_APIS_GURU));
41-
replacements.put("es6PromiseJsUrl", getResourceUrl(basePath, "es6-promise.auto.min.js",
42-
joinCdnjsPath("es6-promise", "4.1.1", "es6-promise.auto.min.js")));
43-
replacements.put("fetchJsUrl", getResourceUrl(basePath, "fetch.min.js",
44-
joinCdnjsPath("fetch", "2.0.4", "fetch.min.js")));
45-
replacements.put("reactJsUrl", getResourceUrl(basePath, "react.min.js",
46-
joinCdnjsPath("react", "16.8.3", "umd/react.production.min.js")));
47-
replacements.put("reactDomJsUrl", getResourceUrl(basePath, "react-dom.min.js",
48-
joinCdnjsPath("react-dom", "16.8.3", "umd/react-dom.production.min.js")));
49-
replacements.put("voyagerCssUrl", getResourceUrl(basePath, "voyager.css",
50-
joinJsDelivrPath(voyagerCdnVersion, "dist/voyager.css")));
51-
replacements.put("voyagerJsUrl", getResourceUrl(basePath, "voyager.min.js",
52-
joinJsDelivrPath(voyagerCdnVersion, "dist/voyager.min.js")));
53-
replacements.put("voyagerWorkerJsUrl", getResourceUrl(basePath, "voyager.worker.js",
54-
joinJsDelivrPath(voyagerCdnVersion, "dist/voyager.worker.min.js")));
38+
replacements.put("pageFavicon", getResourceUrl(basePath, "favicon.ico", FAVICON_APIS_GURU));
39+
replacements.put(
40+
"es6PromiseJsUrl",
41+
getResourceUrl(
42+
basePath,
43+
"es6-promise.auto.min.js",
44+
joinCdnjsPath("es6-promise", "4.1.1", "es6-promise.auto.min.js")));
45+
replacements.put(
46+
"fetchJsUrl",
47+
getResourceUrl(basePath, "fetch.min.js", joinCdnjsPath("fetch", "2.0.4", "fetch.min.js")));
48+
replacements.put(
49+
"reactJsUrl",
50+
getResourceUrl(
51+
basePath,
52+
"react.min.js",
53+
joinCdnjsPath("react", "16.8.3", "umd/react.production.min.js")));
54+
replacements.put(
55+
"reactDomJsUrl",
56+
getResourceUrl(
57+
basePath,
58+
"react-dom.min.js",
59+
joinCdnjsPath("react-dom", "16.8.3", "umd/react-dom.production.min.js")));
60+
replacements.put(
61+
"voyagerCssUrl",
62+
getResourceUrl(
63+
basePath, "voyager.css", joinJsDelivrPath(voyagerCdnVersion, "dist/voyager.css")));
64+
replacements.put(
65+
"voyagerJsUrl",
66+
getResourceUrl(
67+
basePath,
68+
"voyager.min.js",
69+
joinJsDelivrPath(voyagerCdnVersion, "dist/voyager.min.js")));
70+
replacements.put(
71+
"voyagerWorkerJsUrl",
72+
getResourceUrl(
73+
basePath,
74+
"voyager.worker.js",
75+
joinJsDelivrPath(voyagerCdnVersion, "dist/voyager.worker.min.js")));
5576
replacements.put("contextPath", contextPath);
56-
replacements.put("voyagerDisplayOptionsSkipRelay", Boolean.toString(voyagerConfiguration.getDisplayOptions().isSkipRelay()));
57-
replacements.put("voyagerDisplayOptionsSkipDeprecated", Boolean.toString(voyagerConfiguration.getDisplayOptions().isSkipDeprecated()));
58-
replacements.put("voyagerDisplayOptionsRootType", voyagerConfiguration.getDisplayOptions().getRootType());
59-
replacements.put("voyagerDisplayOptionsSortByAlphabet", Boolean.toString(
60-
voyagerConfiguration.getDisplayOptions().isSortByAlphabet()));
61-
replacements.put("voyagerDisplayOptionsShowLeafFields", Boolean.toString(voyagerConfiguration.getDisplayOptions().isShowLeafFields()));
62-
replacements.put("voyagerDisplayOptionsHideRoot", Boolean.toString(voyagerConfiguration.getDisplayOptions().isHideRoot()));
77+
replacements.put(
78+
"voyagerDisplayOptionsSkipRelay",
79+
Boolean.toString(voyagerConfiguration.getDisplayOptions().isSkipRelay()));
80+
replacements.put(
81+
"voyagerDisplayOptionsSkipDeprecated",
82+
Boolean.toString(voyagerConfiguration.getDisplayOptions().isSkipDeprecated()));
83+
replacements.put(
84+
"voyagerDisplayOptionsRootType", voyagerConfiguration.getDisplayOptions().getRootType());
85+
replacements.put(
86+
"voyagerDisplayOptionsSortByAlphabet",
87+
Boolean.toString(voyagerConfiguration.getDisplayOptions().isSortByAlphabet()));
88+
replacements.put(
89+
"voyagerDisplayOptionsShowLeafFields",
90+
Boolean.toString(voyagerConfiguration.getDisplayOptions().isShowLeafFields()));
91+
replacements.put(
92+
"voyagerDisplayOptionsHideRoot",
93+
Boolean.toString(voyagerConfiguration.getDisplayOptions().isHideRoot()));
6394
replacements.put("voyagerHideDocs", Boolean.toString(voyagerConfiguration.isHideDocs()));
64-
replacements.put("voyagerHideSettings", Boolean.toString(voyagerConfiguration.isHideSettings()));
65-
66-
95+
replacements.put(
96+
"voyagerHideSettings", Boolean.toString(voyagerConfiguration.isHideSettings()));
6797

6898
return StringSubstitutor.replace(template, replacements);
6999
}
70100

71-
private String constructGraphQlEndpoint(String contextPath,
72-
@RequestParam Map<String, String> params) {
101+
private String constructGraphQlEndpoint(
102+
String contextPath, @RequestParam Map<String, String> params) {
73103
String endpoint = voyagerConfiguration.getEndpoint();
74104
for (Map.Entry<String, String> param : params.entrySet()) {
75105
endpoint = endpoint.replaceAll("\\{" + param.getKey() + "}", param.getValue());
@@ -96,6 +126,11 @@ private String joinCdnjsPath(String library, String cdnVersion, String cdnFileNa
96126
}
97127

98128
private String joinJsDelivrPath(String cdnVersion, String cdnFileName) {
99-
return CDN_JSDELIVR_NET_NPM + VoyagerIndexHtmlTemplate.VOYAGER + "@" + cdnVersion + "/" + cdnFileName;
129+
return CDN_JSDELIVR_NET_NPM
130+
+ VoyagerIndexHtmlTemplate.VOYAGER
131+
+ "@"
132+
+ cdnVersion
133+
+ "/"
134+
+ cdnFileName;
100135
}
101136
}

voyager-spring-boot-autoconfigure/src/main/java/graphql/kickstart/voyager/boot/VoyagerPropertiesConfiguration.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,23 @@
88
import org.springframework.boot.context.properties.NestedConfigurationProperty;
99
import org.springframework.validation.annotation.Validated;
1010

11-
1211
@Data
1312
@ConfigurationProperties(prefix = "voyager")
1413
@Validated
1514
public class VoyagerPropertiesConfiguration {
1615

17-
private String endpoint = "/graphql";
18-
19-
private String pageTitle = "Voyager";
16+
private String endpoint = "/graphql";
2017

21-
private String basePath = "/";
18+
private String pageTitle = "Voyager";
2219

23-
@NestedConfigurationProperty
24-
@JsonIgnore
25-
private VoyagerCdn cdn = new VoyagerCdn();
20+
private String basePath = "/";
2621

27-
@NestedConfigurationProperty
28-
@JsonIgnore
29-
private VoyagerDisplayOptions displayOptions = new VoyagerDisplayOptions();
22+
@NestedConfigurationProperty @JsonIgnore private VoyagerCdn cdn = new VoyagerCdn();
3023

31-
@JsonIgnore
32-
private boolean hideDocs;
24+
@NestedConfigurationProperty @JsonIgnore
25+
private VoyagerDisplayOptions displayOptions = new VoyagerDisplayOptions();
3326

34-
@JsonIgnore
35-
private boolean hideSettings;
27+
@JsonIgnore private boolean hideDocs;
3628

37-
}
29+
@JsonIgnore private boolean hideSettings;
30+
}

voyager-spring-boot-autoconfigure/src/main/java/graphql/kickstart/voyager/boot/properties/VoyagerCdn.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
@Data
66
public class VoyagerCdn {
77

8-
private boolean enabled;
9-
private String version = "latest";
8+
private boolean enabled;
9+
private String version = "latest";
1010
}

voyager-spring-boot-autoconfigure/src/main/java/graphql/kickstart/voyager/boot/properties/VoyagerDisplayOptions.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
@JsonInclude(JsonInclude.Include.NON_NULL)
88
public class VoyagerDisplayOptions {
99

10-
private boolean skipRelay = true;
11-
private boolean skipDeprecated = true;
12-
private String rootType = "Query";
13-
private boolean sortByAlphabet = false;
14-
private boolean showLeafFields = true;
15-
private boolean hideRoot = false;
16-
10+
private boolean skipRelay = true;
11+
private boolean skipDeprecated = true;
12+
private String rootType = "Query";
13+
private boolean sortByAlphabet = false;
14+
private boolean showLeafFields = true;
15+
private boolean hideRoot = false;
1716
}

0 commit comments

Comments
 (0)