Skip to content

Commit 12f7f4d

Browse files
committed
add deprecated default getName to be backward compatible as much as possible
Signed-off-by: Kavindu Dodanduwa <[email protected]>
1 parent 2d2c5cf commit 12f7f4d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/main/java/dev/openfeature/sdk/ClientMetadata.java

+6
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,10 @@
55
*/
66
public interface ClientMetadata {
77
String getDomain();
8+
9+
@Deprecated
10+
// this is here for compatibility with getName() exposed from {@link Metadata}
11+
default String getName() {
12+
return getDomain();
13+
}
814
}

src/test/java/dev/openfeature/sdk/FlagEvaluationSpecTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,14 @@ public void initialize(EvaluationContext evaluationContext) throws Exception {
280280
@Specification(number="1.2.2", text="The client interface MUST define a metadata member or accessor, containing an immutable domain field or accessor of type string, which corresponds to the domain value supplied during client creation. In previous drafts, this property was called name. For backwards compatibility, implementations should consider name an alias to domain.")
281281
@Test void clientMetadata() {
282282
Client c = _client();
283+
assertNull(c.getMetadata().getName());
283284
assertNull(c.getMetadata().getDomain());
284285

285286
String domainName = "test domain";
286287
FeatureProviderTestUtils.setFeatureProvider(new AlwaysBrokenProvider());
287288
Client c2 = api.getClient(domainName);
289+
290+
assertEquals(domainName, c2.getMetadata().getName());
288291
assertEquals(domainName, c2.getMetadata().getDomain());
289292
}
290293

0 commit comments

Comments
 (0)