Skip to content

Commit 2f65787

Browse files
build: apply spotless
1 parent 94d5e8b commit 2f65787

File tree

393 files changed

+9138
-9266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

393 files changed

+9138
-9266
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ pom.xml.versionsBackup
2424
jacoco.exec
2525

2626
out
27+
tmp

handlebars-caffeine/src/main/java/com/github/jknack/handlebars/cache/CaffeineTemplateCache.java

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
/**
2-
* Copyright (c) 2012-2015 Edgar Espina
3-
*
4-
* This file is part of Handlebars.java.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
1+
/*
2+
* Handlebars.java: https://github.com/jknack/handlebars.java
3+
* Apache License Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
4+
* Copyright (c) 2012 Edgar Espina
175
*/
186
package com.github.jknack.handlebars.cache;
197

@@ -36,9 +24,7 @@
3624
*/
3725
public class CaffeineTemplateCache implements TemplateCache {
3826

39-
/**
40-
* Internal cache.
41-
*/
27+
/** Internal cache. */
4228
private final Cache<TemplateSource, Template> cache;
4329

4430
/**
@@ -50,28 +36,32 @@ public CaffeineTemplateCache(final Cache<TemplateSource, Template> cache) {
5036
this.cache = requireNonNull(cache, "The cache is required.");
5137
}
5238

53-
@Override public void clear() {
39+
@Override
40+
public void clear() {
5441
cache.invalidateAll();
5542
}
5643

57-
@Override public void evict(final TemplateSource source) {
44+
@Override
45+
public void evict(final TemplateSource source) {
5846
cache.invalidate(source);
5947
}
6048

61-
@Override public Template get(final TemplateSource source, final Parser parser) {
49+
@Override
50+
public Template get(final TemplateSource source, final Parser parser) {
6251
return cache.get(source, parseTemplate(parser));
6352
}
6453

6554
/**
66-
* This method does nothing on Caffeine. Better option is to use a loading cache with a
67-
* eviction policy of your choice.
55+
* This method does nothing on Caffeine. Better option is to use a loading cache with a eviction
56+
* policy of your choice.
6857
*
69-
* Don't use this method.
58+
* <p>Don't use this method.
7059
*
7160
* @param reload Ignored.
7261
* @return This template cache.
7362
*/
74-
@Override public TemplateCache setReload(final boolean reload) {
63+
@Override
64+
public TemplateCache setReload(final boolean reload) {
7565
// NOOP
7666
return this;
7767
}

handlebars-caffeine/src/main/java/com/github/jknack/handlebars/io/CaffeineTemplateLoader.java

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
/**
2-
* Copyright (c) 2012-2015 Edgar Espina
3-
*
4-
* This file is part of Handlebars.java.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
1+
/*
2+
* Handlebars.java: https://github.com/jknack/handlebars.java
3+
* Apache License Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
4+
* Copyright (c) 2012 Edgar Espina
175
*/
186
package com.github.jknack.handlebars.io;
197

@@ -25,80 +13,66 @@
2513
import com.github.jknack.handlebars.Handlebars;
2614

2715
/**
28-
* Decorates an existing TemplateLoader with a GuavaCache.
29-
* This is useful to avoid constantly creating TemplateSources.
16+
* Decorates an existing TemplateLoader with a GuavaCache. This is useful to avoid constantly
17+
* creating TemplateSources.
18+
*
3019
* @author agent
3120
*/
3221
public class CaffeineTemplateLoader implements TemplateLoader {
3322

34-
/**
35-
* never null.
36-
*/
23+
/** never null. */
3724
private final TemplateLoader delegate;
38-
/**
39-
* never null.
40-
*/
25+
26+
/** never null. */
4127
private final Cache<String, TemplateSource> cache;
4228

4329
/**
44-
* @param delegate
45-
* wrappped template loader.
46-
* @param cache
47-
* Guava Cache.
30+
* @param delegate wrappped template loader.
31+
* @param cache Guava Cache.
4832
*/
49-
public CaffeineTemplateLoader(final TemplateLoader delegate,
50-
final Cache<String, TemplateSource> cache) {
33+
public CaffeineTemplateLoader(
34+
final TemplateLoader delegate, final Cache<String, TemplateSource> cache) {
5135
this.delegate = delegate;
5236
this.cache = cache;
5337
}
5438

55-
/**
56-
* {@inheritDoc}
57-
*/
39+
/** {@inheritDoc} */
5840
public TemplateSource sourceAt(final String location) {
5941
return cache.get(location, loadTemplate());
6042
}
6143

62-
/**
63-
* {@inheritDoc}
64-
*/
44+
/** {@inheritDoc} */
6545
public String resolve(final String location) {
6646
return delegate.resolve(location);
6747
}
6848

69-
/**
70-
* {@inheritDoc}
71-
*/
49+
/** {@inheritDoc} */
7250
public String getPrefix() {
7351
return delegate.getPrefix();
7452
}
7553

76-
/**
77-
* {@inheritDoc}
78-
*/
54+
/** {@inheritDoc} */
7955
public String getSuffix() {
8056
return delegate.getSuffix();
8157
}
8258

83-
/**
84-
* {@inheritDoc}
85-
*/
59+
/** {@inheritDoc} */
8660
public void setPrefix(final String prefix) {
8761
delegate.setPrefix(prefix);
8862
}
8963

90-
/**
91-
* {@inheritDoc}
92-
*/
64+
/** {@inheritDoc} */
9365
public void setSuffix(final String suffix) {
9466
delegate.setSuffix(suffix);
9567
}
9668

97-
@Override public void setCharset(final Charset charset) {
69+
@Override
70+
public void setCharset(final Charset charset) {
9871
delegate.setCharset(charset);
9972
}
10073

101-
@Override public Charset getCharset() {
74+
@Override
75+
public Charset getCharset() {
10276
return delegate.getCharset();
10377
}
10478

handlebars-caffeine/src/test/java/com/github/jknack/handlebars/cache/CaffeineTemplateCacheTest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Handlebars.java: https://github.com/jknack/handlebars.java
3+
* Apache License Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
4+
* Copyright (c) 2012 Edgar Espina
5+
*/
16
package com.github.jknack.handlebars.cache;
27

38
import static org.junit.Assert.assertEquals;
@@ -64,12 +69,11 @@ public void shouldGetTemplate() throws IOException {
6469
Parser parser = mock(Parser.class);
6570
when(parser.parse(key)).thenReturn(template);
6671

67-
ArgumentCaptor<Function<TemplateSource, Template>> captor = ArgumentCaptor.forClass(
68-
Function.class);
72+
ArgumentCaptor<Function<TemplateSource, Template>> captor =
73+
ArgumentCaptor.forClass(Function.class);
6974

7075
Cache<TemplateSource, Template> cache = mock(Cache.class);
71-
when(cache.get(eq(key), captor.capture()))
72-
.thenReturn(template);
76+
when(cache.get(eq(key), captor.capture())).thenReturn(template);
7377

7478
CaffeineTemplateCache templateCache = new CaffeineTemplateCache(cache);
7579

@@ -87,11 +91,10 @@ public void shouldReThrowExceptionOnGetTemplate() throws IOException {
8791
Parser parser = mock(Parser.class);
8892
when(parser.parse(key)).thenThrow(error);
8993

90-
ArgumentCaptor<Function<TemplateSource, Template>> captor = ArgumentCaptor.forClass(
91-
Function.class);
94+
ArgumentCaptor<Function<TemplateSource, Template>> captor =
95+
ArgumentCaptor.forClass(Function.class);
9296

93-
Cache<TemplateSource, Template> cache = Caffeine.newBuilder()
94-
.build();
97+
Cache<TemplateSource, Template> cache = Caffeine.newBuilder().build();
9598

9699
CaffeineTemplateCache templateCache = new CaffeineTemplateCache(cache);
97100

handlebars-guava-cache/src/main/java/com/github/jknack/handlebars/cache/GuavaTemplateCache.java

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
/**
2-
* Copyright (c) 2012-2015 Edgar Espina
3-
*
4-
* This file is part of Handlebars.java.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
1+
/*
2+
* Handlebars.java: https://github.com/jknack/handlebars.java
3+
* Apache License Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
4+
* Copyright (c) 2012 Edgar Espina
175
*/
186
package com.github.jknack.handlebars.cache;
197

8+
import static java.util.Objects.requireNonNull;
9+
2010
import java.io.IOException;
2111
import java.util.concurrent.ExecutionException;
2212

@@ -26,21 +16,18 @@
2616
import com.github.jknack.handlebars.io.ReloadableTemplateSource;
2717
import com.github.jknack.handlebars.io.TemplateSource;
2818
import com.google.common.cache.Cache;
29-
import static java.util.Objects.requireNonNull;
3019

3120
/**
3221
* An implementation of {@link TemplateCache} built on top of Guava. If {@link #setReload(boolean)}
33-
* is <code>on</code> we recommended one of the available auto-eviction policy of Guava, it
34-
* helps to reduce leaks when auto-reload is <code>on</code>.
22+
* is <code>on</code> we recommended one of the available auto-eviction policy of Guava, it helps to
23+
* reduce leaks when auto-reload is <code>on</code>.
3524
*
3625
* @author edgar.espina
3726
* @since 0.11.0
3827
*/
3928
public class GuavaTemplateCache implements TemplateCache {
4029

41-
/**
42-
* The guava cache.
43-
*/
30+
/** The guava cache. */
4431
private final Cache<TemplateSource, Template> cache;
4532

4633
/** Turn on/off auto reloading of templates. */
@@ -106,5 +93,4 @@ private RuntimeException launderThrowable(final TemplateSource source, final Thr
10693
private TemplateSource key(final TemplateSource source) {
10794
return reload ? new ReloadableTemplateSource(source) : source;
10895
}
109-
11096
}

0 commit comments

Comments
 (0)