Skip to content

Commit 35d4cc2

Browse files
authored
chore: various non-functional refactors (#1066)
Signed-off-by: Todd Baert <[email protected]>
1 parent ea59e7f commit 35d4cc2

8 files changed

+73
-17
lines changed

Diff for: src/main/java/dev/openfeature/sdk/BooleanHook.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package dev.openfeature.sdk;
22

33
/**
4-
* {@inheritDoc}
4+
* An extension point which can run around flag resolution. They are intended to be used as a way to add custom logic
5+
* to the lifecycle of flag evaluation.
6+
*
7+
* @see Hook
58
*/
69
public interface BooleanHook extends Hook<Boolean> {
710

Diff for: src/main/java/dev/openfeature/sdk/DoubleHook.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package dev.openfeature.sdk;
22

33
/**
4-
* {@inheritDoc}
4+
* An extension point which can run around flag resolution. They are intended to be used as a way to add custom logic
5+
* to the lifecycle of flag evaluation.
6+
*
7+
* @see Hook
58
*/
69
public interface DoubleHook extends Hook<Double> {
710

Diff for: src/main/java/dev/openfeature/sdk/ImmutableContext.java

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package dev.openfeature.sdk;
22

3-
import lombok.ToString;
4-
import lombok.experimental.Delegate;
5-
63
import java.util.HashMap;
74
import java.util.Map;
5+
import java.util.function.Function;
6+
import dev.openfeature.sdk.internal.ExcludeFromGeneratedCoverageReport;
7+
import lombok.ToString;
8+
import lombok.experimental.Delegate;
89

910
/**
1011
* The EvaluationContext is a container for arbitrary contextual data
@@ -16,8 +17,8 @@
1617
@SuppressWarnings("PMD.BeanMembersShouldSerialize")
1718
public final class ImmutableContext implements EvaluationContext {
1819

19-
@Delegate
20-
private final Structure structure;
20+
@Delegate(excludes = DelegateExclusions.class)
21+
private final ImmutableStructure structure;
2122

2223
/**
2324
* Create an immutable context with an empty targeting_key and attributes provided.
@@ -84,4 +85,15 @@ public EvaluationContext merge(EvaluationContext overridingContext) {
8485
return new ImmutableContext(
8586
this.merge(ImmutableStructure::new, this.asMap(), overridingContext.asMap()));
8687
}
88+
89+
@SuppressWarnings("all")
90+
private static class DelegateExclusions {
91+
@ExcludeFromGeneratedCoverageReport
92+
public <T extends Structure> Map<String, Value> merge(Function<Map<String, Value>, Structure> newStructure,
93+
Map<String, Value> base,
94+
Map<String, Value> overriding) {
95+
96+
return null;
97+
}
98+
}
8799
}

Diff for: src/main/java/dev/openfeature/sdk/IntegerHook.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package dev.openfeature.sdk;
22

33
/**
4-
* {@inheritDoc}
4+
* An extension point which can run around flag resolution. They are intended to be used as a way to add custom logic
5+
* to the lifecycle of flag evaluation.
6+
*
7+
* @see Hook
58
*/
69
public interface IntegerHook extends Hook<Integer> {
710

Diff for: src/main/java/dev/openfeature/sdk/MutableContext.java

+19-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package dev.openfeature.sdk;
22

3-
import lombok.EqualsAndHashCode;
4-
import lombok.ToString;
5-
import lombok.experimental.Delegate;
6-
73
import java.time.Instant;
84
import java.util.HashMap;
95
import java.util.List;
106
import java.util.Map;
7+
import java.util.function.Function;
8+
import dev.openfeature.sdk.internal.ExcludeFromGeneratedCoverageReport;
9+
import lombok.EqualsAndHashCode;
10+
import lombok.ToString;
11+
import lombok.experimental.Delegate;
1112

1213
/**
1314
* The EvaluationContext is a container for arbitrary contextual data
@@ -20,7 +21,8 @@
2021
@SuppressWarnings("PMD.BeanMembersShouldSerialize")
2122
public class MutableContext implements EvaluationContext {
2223

23-
@Delegate(excludes = HideDelegateAddMethods.class) private final MutableStructure structure;
24+
@Delegate(excludes = DelegateExclusions.class)
25+
private final MutableStructure structure;
2426

2527
public MutableContext() {
2628
this(new HashMap<>());
@@ -124,11 +126,21 @@ public EvaluationContext merge(EvaluationContext overridingContext) {
124126
/**
125127
* Hidden class to tell Lombok not to copy these methods over via delegation.
126128
*/
127-
private static class HideDelegateAddMethods {
129+
@SuppressWarnings("all")
130+
private static class DelegateExclusions {
131+
132+
@ExcludeFromGeneratedCoverageReport
133+
public <T extends Structure> Map<String, Value> merge(Function<Map<String, Value>, Structure> newStructure,
134+
Map<String, Value> base,
135+
Map<String, Value> overriding) {
136+
137+
return null;
138+
}
139+
128140
public MutableStructure add(String ignoredKey, Boolean ignoredValue) {
129141
return null;
130142
}
131-
143+
132144
public MutableStructure add(String ignoredKey, Double ignoredValue) {
133145
return null;
134146
}

Diff for: src/main/java/dev/openfeature/sdk/OpenFeatureClient.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@
1717
import lombok.extern.slf4j.Slf4j;
1818

1919
/**
20-
* {@inheritDoc}
20+
* OpenFeature Client implementation.
21+
* You should not instantiate this or reference this class.
22+
* Use the dev.openfeature.sdk.Client interface instead.
23+
* @see Client
24+
*
25+
* @deprecated // TODO: eventually we will make this non-public. See issue #872
2126
*/
2227
@Slf4j
2328
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.BeanMembersShouldSerialize",
2429
"PMD.UnusedLocalVariable", "unchecked", "rawtypes" })
30+
@Deprecated() // TODO: eventually we will make this non-public. See issue #872
2531
public class OpenFeatureClient implements Client {
2632

2733
private final OpenFeatureAPI openfeatureApi;

Diff for: src/main/java/dev/openfeature/sdk/StringHook.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package dev.openfeature.sdk;
22

33
/**
4-
* {@inheritDoc}
4+
* An extension point which can run around flag resolution. They are intended to be used as a way to add custom logic
5+
* to the lifecycle of flag evaluation.
6+
*
7+
* @see Hook
58
*/
69
public interface StringHook extends Hook<String> {
710

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package dev.openfeature.sdk.internal;
2+
3+
import java.lang.annotation.Retention;
4+
import java.lang.annotation.Target;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.ElementType;
7+
8+
/**
9+
* JaCoCo ignores coverage of methods annotated with any annotation with "generated" in the name.
10+
*/
11+
@Retention(RetentionPolicy.RUNTIME)
12+
@Target(ElementType.METHOD)
13+
public @interface ExcludeFromGeneratedCoverageReport {
14+
}

0 commit comments

Comments
 (0)