Skip to content

Commit 33565e2

Browse files
author
Tobias Burdow [Kaleidox]
committed
Patched out Lombok
1 parent 24dad67 commit 33565e2

File tree

3 files changed

+42
-9
lines changed

3 files changed

+42
-9
lines changed

src/main/java/io/codebottle/api/CodeBottle.java

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,30 @@
1515
import io.codebottle.api.model.Snippet;
1616
import io.codebottle.api.rest.CodeBottleRequest;
1717
import io.codebottle.api.rest.Endpoint;
18-
import lombok.Builder;
19-
import lombok.Getter;
2018
import okhttp3.OkHttpClient;
2119
import org.jetbrains.annotations.Nullable;
2220

2321
/**
2422
* API Class. Create an instance of this using {@code #builder()} to use the API.
2523
*/
26-
@Builder
2724
public final class CodeBottle {
2825
private final Map<String, Language> languageCache = new ConcurrentHashMap<>();
2926
private final Map<String, Category> categoryCache = new ConcurrentHashMap<>();
3027
private final Map<String, Snippet> snippetCache = new ConcurrentHashMap<>();
31-
@Builder.Default
32-
private final @Nullable String token = null;
33-
@Builder.Default
34-
private @Getter final OkHttpClient httpClient = new OkHttpClient.Builder().build();
28+
private final @Nullable String token;
29+
private final OkHttpClient httpClient;
3530
/**
3631
* A {@link CompletableFuture} that completes once lazy loading was finished.
3732
* <p>
3833
* Lazy loading is calling {@link #requestLanguages()} and {@link #requestCategories()} on API construction.
3934
*/
4035
public final CompletableFuture<Void> lazyLoading = CompletableFuture.allOf(requestLanguages(), requestCategories());
4136

37+
private CodeBottle(@Nullable String token, OkHttpClient httpClient) {
38+
this.token = token;
39+
this.httpClient = httpClient;
40+
}
41+
4242
/**
4343
* Waits for {@linkplain #lazyLoading lazy loading} to finish using {@link CompletableFuture#join()}.
4444
* This method is intended to be used for API chaining, otherwise it is recommended to wait for {@link #lazyLoading} yourself.
@@ -331,4 +331,37 @@ public CompletableFuture<Collection<Snippet.Revision>> requestAllRevisions() {
331331
return yields;
332332
});
333333
}
334+
335+
public OkHttpClient getHttpClient() {
336+
return httpClient;
337+
}
338+
339+
public final static class Builder {
340+
private @Nullable String token = null;
341+
private OkHttpClient httpClient = new OkHttpClient.Builder().build();
342+
343+
public Optional<String> getToken() {
344+
return Optional.ofNullable(token);
345+
}
346+
347+
public void setToken(@Nullable String token) {
348+
this.token = token;
349+
}
350+
351+
public void removeToken() {
352+
setToken(null);
353+
}
354+
355+
public Optional<OkHttpClient> getHttpClient() {
356+
return Optional.ofNullable(httpClient);
357+
}
358+
359+
public void setHttpClient(OkHttpClient httpClient) {
360+
this.httpClient = httpClient;
361+
}
362+
363+
public CodeBottle build() {
364+
return new CodeBottle(token, httpClient);
365+
}
366+
}
334367
}

src/test/java/io/codebottle/api/test/PerformanceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void requestEverything() {
1616

1717
out.print("Requesting everything...");
1818

19-
final CodeBottle codeBottle = CodeBottle.builder().build();
19+
final CodeBottle codeBottle = new CodeBottle.Builder().build();
2020

2121
// wait for all loading to finish
2222
CompletableFuture.allOf(codeBottle.lazyLoading, codeBottle.requestAllRevisions())

src/test/java/io/codebottle/api/test/RequestTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class RequestTest {
1212

1313
@Before
1414
public void setUp() {
15-
codeBottle = CodeBottle.builder()
15+
codeBottle = new CodeBottle.Builder()
1616
.build()
1717
.waitForLazyLoading();
1818
}

0 commit comments

Comments
 (0)