Skip to content

Commit

Permalink
remove webJarVersion and hide the constructor to override the cache imp
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesward committed Apr 26, 2024
1 parent 9959870 commit b5f34a2
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 23 deletions.
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,3 @@ WebJarVersionLocator webJarVersionLocator = new WebJarVersionLocator();
webJarVersionLocator.version("bootstrap"); // cache miss
webJarVersionLocator.version("bootstrap"); // cache hit, avoiding looking up metadata in the classpath
```

The default cache uses a `ConcurrentHashMap` but you can provide a custom cache implementation:
```
class WebJarCacheMine implements WebJarCache {
...
}
WebJarVersionLocator webJarVersionLocator = new WebJarVersionLocator(new WebJarCacheMine());
```
2 changes: 1 addition & 1 deletion src/main/java/org/webjars/WebJarCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Cache keys and values are Strings because that is all that is needed.
*/
@NullMarked
public interface WebJarCache {
interface WebJarCache {

Optional<String> computeIfAbsent(String key, Function<String, Optional<String>> function);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/webjars/WebJarCacheDefault.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


@NullMarked
public class WebJarCacheDefault implements WebJarCache {
class WebJarCacheDefault implements WebJarCache {

final ConcurrentMap<String, Optional<String>> cache;

Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/webjars/WebJarVersionLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public WebJarVersionLocator() {
this.cache = new WebJarCacheDefault(new ConcurrentHashMap<>());
}

public WebJarVersionLocator(WebJarCache cache) {
WebJarVersionLocator(WebJarCache cache) {
this.cache = cache;
}

Expand Down Expand Up @@ -77,17 +77,6 @@ public String path(final String webJarName, final String exactPath) {
return null;
}

/**
* @param webJarName The name of the WebJar, i.e. bootstrap
* @return The version of the WebJar, i.e 3.1.1
* @deprecated Use {@link #version(String)} instead
*/
@Deprecated
@Nullable
public String webJarVersion(final String webJarName) {
return version(webJarName);
}

/**
* @param webJarName The name of the WebJar, i.e. bootstrap
* @return The version of the WebJar, i.e 3.1.1
Expand Down

0 comments on commit b5f34a2

Please sign in to comment.