Skip to content

Commit 95d0126

Browse files
committed
-moves everything to Java 8
1 parent 472dc19 commit 95d0126

File tree

13 files changed

+63
-53
lines changed

13 files changed

+63
-53
lines changed

.github/workflows/merge.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222

2323
steps:
2424
- uses: actions/checkout@v3
25-
- name: Set up JDK 11
25+
- name: Set up JDK 8
2626
uses: actions/setup-java@v3
2727
with:
28-
java-version: '11'
28+
java-version: '8'
2929
distribution: 'temurin'
3030
- name: Build with Gradle
3131
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee

.github/workflows/pullrequest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222

2323
steps:
2424
- uses: actions/checkout@v3
25-
- name: Set up JDK 11
25+
- name: Set up JDK 8
2626
uses: actions/setup-java@v3
2727
with:
28-
java-version: '11'
28+
java-version: '8'
2929
distribution: 'temurin'
3030
- name: Build with Gradle
3131
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121

2222
steps:
2323
- uses: actions/checkout@v3
24-
- name: Set up JDK 11
24+
- name: Set up JDK 8
2525
uses: actions/setup-java@v3
2626
with:
27-
java-version: '11'
27+
java-version: '8'
2828
distribution: 'temurin'
2929
- name: Build with Gradle
3030
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee

lib/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ dependencies {
4242
api 'org.apache.commons:commons-math3:3.6.1'
4343
}
4444

45+
java {
46+
toolchain {
47+
languageVersion.set(JavaLanguageVersion.of(8))
48+
}
49+
}
50+
4551
tasks.named('test') {
4652
// Use JUnit Platform for unit tests.
4753
useJUnitPlatform()

lib/src/main/java/dev/openfeature/javasdk/FlagEvaluationOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ public class FlagEvaluationOptions {
1010
@Singular
1111
List<Hook> hooks;
1212
@Builder.Default
13-
Map<String, Object> hookHints = Map.of();
13+
Map<String, Object> hookHints = new HashMap<>();
1414
}

lib/src/main/java/dev/openfeature/javasdk/HookSupport.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dev.openfeature.javasdk;
22

33
import java.util.*;
4-
import java.util.function.Consumer;
4+
import java.util.function.*;
55
import java.util.stream.Stream;
66

77
import com.google.common.collect.Lists;
@@ -59,7 +59,7 @@ private <T> void executeChecked(Hook<T> hook, Consumer<Hook<T>> hookCode, String
5959
}
6060

6161
public EvaluationContext beforeHooks(FlagValueType flagValueType, HookContext hookCtx, List<Hook> hooks, Map<String, Object> hints) {
62-
var result = callBeforeHooks(flagValueType, hookCtx, hooks, hints);
62+
Stream<EvaluationContext> result = callBeforeHooks(flagValueType, hookCtx, hooks, hints);
6363
return EvaluationContext.merge(hookCtx.getCtx(), collectContexts(result));
6464
}
6565

@@ -71,7 +71,9 @@ private Stream<EvaluationContext> callBeforeHooks(FlagValueType flagValueType, H
7171
.filter(hook -> isHookCompatible(flagValueType, hook))
7272
.map(hook -> hook.before(hookCtx, hints))
7373
.filter(Objects::nonNull)
74-
.flatMap(Optional::stream);
74+
.filter(Optional::isPresent)
75+
.map(Optional::get)
76+
.map(EvaluationContext.class::cast);
7577
}
7678

7779
//for whatever reason, an error `error: incompatible types: invalid method reference` is thrown on compilation with javac

lib/src/main/java/dev/openfeature/javasdk/OpenFeatureClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ public OpenFeatureClient(OpenFeatureAPI openFeatureAPI, String name, String vers
2727

2828
@Override
2929
public void addHooks(Hook... hooks) {
30-
this.clientHooks.addAll(List.of(hooks));
30+
this.clientHooks.addAll(Arrays.asList(hooks));
3131
}
3232

3333
private <T> FlagEvaluationDetails<T> evaluateFlag(FlagValueType type, String key, T defaultValue, EvaluationContext ctx, FlagEvaluationOptions options) {
34-
var flagOptions = ObjectUtils.defaultIfNull(options, () -> FlagEvaluationOptions.builder().build());
34+
FlagEvaluationOptions flagOptions = ObjectUtils.defaultIfNull(options, () -> FlagEvaluationOptions.builder().build());
3535
FeatureProvider provider = openfeatureApi.getProvider();
3636
Map<String, Object> hints = Collections.unmodifiableMap(flagOptions.getHookHints());
3737
if (ctx == null) {

lib/src/test/java/dev/openfeature/javasdk/DeveloperExperienceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DeveloperExperienceTest {
3333
}
3434

3535
private Hook<Boolean> createBooleanHook() {
36-
var hook = Mockito.mock(Hook.class);
36+
Hook hook = mock(Hook.class);
3737
when(hook.supportsFlagValueType()).thenReturn(FlagValueType.BOOLEAN);
3838
return hook;
3939
}

lib/src/test/java/dev/openfeature/javasdk/FlagEvaluationSpecTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ private Client _client() {
143143

144144
@Specification(number="1.5.1", text="The evaluation options structure's hooks field denotes an ordered collection of hooks that the client MUST execute for the respective flag evaluation, in addition to those already configured.")
145145
@Test void hooks() {
146-
var c = _client();
147-
var clientHook = mockBooleanHook();
148-
var invocationHook = mockBooleanHook();
146+
Client c = _client();
147+
Hook<Boolean> clientHook = mockBooleanHook();
148+
Hook<Boolean> invocationHook = mockBooleanHook();
149149
c.addHooks(clientHook);
150150
c.getBooleanValue("key", false, null, FlagEvaluationOptions.builder()
151151
.hook(invocationHook)

lib/src/test/java/dev/openfeature/javasdk/HookSpecTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.*;
44

5+
import com.google.common.collect.ImmutableMap;
56
import dev.openfeature.javasdk.fixtures.HookFixtures;
67
import lombok.SneakyThrows;
78
import org.junit.jupiter.api.*;
@@ -248,7 +249,7 @@ public void finallyAfter(HookContext<Boolean> ctx, Map<String, Object> hints) {
248249
})
249250
.build());
250251

251-
List<String> expectedOrder = List.of(
252+
List<String> expectedOrder = Arrays.asList(
252253
"api before", "client before", "invocation before",
253254
"invocation after", "client after", "api after",
254255
"invocation error", "client error", "api error",
@@ -320,7 +321,7 @@ public void finallyAfter(HookContext<Boolean> ctx, Map<String, Object> hints) {
320321
}
321322
};
322323

323-
Map<String, Object> hh = new HashMap<>(Map.of(hintKey, "My hint value"));
324+
Map<String, Object> hh = new HashMap<>(ImmutableMap.of(hintKey, "My hint value"));
324325

325326
client.getBooleanValue("key", false, new EvaluationContext(), FlagEvaluationOptions.builder()
326327
.hook(mutatingHook)

0 commit comments

Comments
 (0)