Skip to content

Commit 62b1348

Browse files
committed
Use consistent equality check for TemplateFormats constants
1 parent 5f10e01 commit 62b1348

11 files changed

+14
-14
lines changed

spring-restdocs-core/src/main/java/org/springframework/restdocs/config/RestDocumentationConfigurer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ public void apply(Map<String, Object> configuration,
119119
SnippetConfiguration snippetConfiguration = (SnippetConfiguration) configuration
120120
.get(SnippetConfiguration.class.getName());
121121
Map<String, Object> templateContext = new HashMap<>();
122-
if (snippetConfiguration.getTemplateFormat().getId()
123-
.equals(TemplateFormats.asciidoctor().getId())) {
122+
if (snippetConfiguration.getTemplateFormat() == TemplateFormats.asciidoctor()) {
124123
templateContext.put("tableCellContent",
125124
new AsciidoctorTableCellContentLambda());
126125
}

spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormats.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.springframework.restdocs.templates;
1818

1919
/**
20-
* An enumeration of the built-in formats for which templates are provuded.
20+
* An enumeration of the built-in formats for which templates are provided.
2121
*
2222
* @author Andy Wilkinson
2323
* @since 1.1.0

spring-restdocs-core/src/test/java/org/springframework/restdocs/config/RestDocumentationConfigurerTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import static org.hamcrest.CoreMatchers.instanceOf;
5959
import static org.hamcrest.CoreMatchers.is;
6060
import static org.hamcrest.CoreMatchers.nullValue;
61+
import static org.hamcrest.CoreMatchers.sameInstance;
6162
import static org.hamcrest.Matchers.contains;
6263
import static org.hamcrest.Matchers.hasEntry;
6364
import static org.junit.Assert.assertThat;
@@ -101,7 +102,7 @@ public void defaultConfiguration() {
101102
.get(SnippetConfiguration.class.getName());
102103
assertThat(snippetConfiguration.getEncoding(), is(equalTo("UTF-8")));
103104
assertThat(snippetConfiguration.getTemplateFormat(),
104-
is(equalTo(TemplateFormats.asciidoctor())));
105+
is(sameInstance(TemplateFormats.asciidoctor())));
105106

106107
OperationRequestPreprocessor defaultOperationRequestPreprocessor = (OperationRequestPreprocessor) configuration
107108
.get(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_OPERATION_REQUEST_PREPROCESSOR);
@@ -191,7 +192,7 @@ public void customTemplateFormat() {
191192
SnippetConfiguration snippetConfiguration = (SnippetConfiguration) configuration
192193
.get(SnippetConfiguration.class.getName());
193194
assertThat(snippetConfiguration.getTemplateFormat(),
194-
is(equalTo(TemplateFormats.markdown())));
195+
is(sameInstance(TemplateFormats.markdown())));
195196
}
196197

197198
@SuppressWarnings("unchecked")

spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public void tableCellContentIsEscapedWhenNecessary() throws IOException {
173173
}
174174

175175
private String escapeIfNecessary(String input) {
176-
if (this.templateFormat.equals(TemplateFormats.markdown())) {
176+
if (this.templateFormat == TemplateFormats.markdown()) {
177177
return input;
178178
}
179179
return input.replace("|", "\\|");

spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public void tableCellContentIsEscapedWhenNecessary() throws IOException {
164164
}
165165

166166
private String escapeIfNecessary(String input) {
167-
if (this.templateFormat.equals(TemplateFormats.markdown())) {
167+
if (this.templateFormat == TemplateFormats.markdown()) {
168168
return input;
169169
}
170170
return input.replace("|", "\\|");

spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public void tableCellContentIsEscapedWhenNecessary() throws IOException {
178178
}
179179

180180
private String escapeIfNecessary(String input) {
181-
if (this.templateFormat.equals(TemplateFormats.markdown())) {
181+
if (this.templateFormat == TemplateFormats.markdown()) {
182182
return input;
183183
}
184184
return input.replace("|", "\\|");

spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ public void typeDeterminationDoesNotSetTypeOnDescriptor() throws IOException {
461461
}
462462

463463
private String escapeIfNecessary(String input) {
464-
if (this.templateFormat.equals(TemplateFormats.markdown())) {
464+
if (this.templateFormat == TemplateFormats.markdown()) {
465465
return input;
466466
}
467467
return input.replace("|", "\\|");

spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ public void typeDeterminationDoesNotSetTypeOnDescriptor() throws IOException {
472472
}
473473

474474
private String escapeIfNecessary(String input) {
475-
if (this.templateFormat.equals(TemplateFormats.markdown())) {
475+
if (this.templateFormat == TemplateFormats.markdown()) {
476476
return input;
477477
}
478478
return input.replace("|", "\\|");

spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public void pathParametersWithEscapedContent() throws IOException {
208208
}
209209

210210
private String escapeIfNecessary(String input) {
211-
if (this.templateFormat.equals(TemplateFormats.markdown())) {
211+
if (this.templateFormat == TemplateFormats.markdown()) {
212212
return input;
213213
}
214214
return input.replace("|", "\\|");
@@ -219,7 +219,7 @@ private String getTitle() {
219219
}
220220

221221
private String getTitle(String title) {
222-
if (this.templateFormat.equals(TemplateFormats.asciidoctor())) {
222+
if (this.templateFormat == TemplateFormats.asciidoctor()) {
223223
return "+" + title + "+";
224224
}
225225
return "`" + title + "`";

spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public void requestParametersWithEscapedContent() throws IOException {
200200
}
201201

202202
private String escapeIfNecessary(String input) {
203-
if (this.templateFormat.equals(TemplateFormats.markdown())) {
203+
if (this.templateFormat == TemplateFormats.markdown()) {
204204
return input;
205205
}
206206
return input.replace("|", "\\|");

spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void requestPartsWithEscapedContent() throws IOException {
191191
}
192192

193193
private String escapeIfNecessary(String input) {
194-
if (this.templateFormat.equals(TemplateFormats.markdown())) {
194+
if (this.templateFormat == TemplateFormats.markdown()) {
195195
return input;
196196
}
197197
return input.replace("|", "\\|");

0 commit comments

Comments
 (0)