Skip to content

Commit cc68042

Browse files
committed
Rename OutOfBandLibraryVersionRegistrar to GlobalLibraryVersionRegistrar
1 parent 6d7b42c commit cc68042

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

firebase-common/src/main/java/com/google/firebase/platforminfo/DefaultUserAgentPublisher.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
*/
2828
public class DefaultUserAgentPublisher implements UserAgentPublisher {
2929
private final String javaSDKVersionUserAgent;
30-
private final OutOfBandLibraryVersionRegistrar gamesSDKRegistrar;
30+
private final GlobalLibraryVersionRegistrar gamesSDKRegistrar;
3131

3232
DefaultUserAgentPublisher(
33-
Set<LibraryVersion> libraryVersions, OutOfBandLibraryVersionRegistrar gamesSDKRegistrar) {
33+
Set<LibraryVersion> libraryVersions, GlobalLibraryVersionRegistrar gamesSDKRegistrar) {
3434
this.javaSDKVersionUserAgent = toUserAgent(libraryVersions);
3535
this.gamesSDKRegistrar = gamesSDKRegistrar;
3636
}
@@ -70,7 +70,7 @@ public static Component<UserAgentPublisher> component() {
7070
.factory(
7171
c ->
7272
new DefaultUserAgentPublisher(
73-
c.setOf(LibraryVersion.class), OutOfBandLibraryVersionRegistrar.getInstance()))
73+
c.setOf(LibraryVersion.class), GlobalLibraryVersionRegistrar.getInstance()))
7474
.build();
7575
}
7676
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
/**
2222
* In order to allow the C++ and Unity SDKs to publish their versions without the use of the
2323
* components framework, we have a mechanism where the versions can be wired as out of band as side
24-
* effects. See {@link OutOfBandLibraryVersionRegistrar#registerVersion(String, String)}
24+
* effects. See {@link GlobalLibraryVersionRegistrar#registerVersion(String, String)}
2525
*
2626
* <p>Java libraries should use {@link LibraryVersionComponent#create(String, String)} instead.
2727
*/
28-
public class OutOfBandLibraryVersionRegistrar {
28+
public class GlobalLibraryVersionRegistrar {
2929
private final Set<LibraryVersion> infos = new HashSet<>();
30-
private static volatile OutOfBandLibraryVersionRegistrar INSTANCE;
30+
private static volatile GlobalLibraryVersionRegistrar INSTANCE;
3131

32-
OutOfBandLibraryVersionRegistrar() {}
32+
GlobalLibraryVersionRegistrar() {}
3333

3434
/**
3535
* Thread safe method to publish versions outside of the components mechanics.
@@ -49,14 +49,14 @@ Set<LibraryVersion> getRegisteredVersions() {
4949
}
5050
}
5151

52-
/** Returns an instance of {@link OutOfBandLibraryVersionRegistrar} */
53-
public static OutOfBandLibraryVersionRegistrar getInstance() {
54-
OutOfBandLibraryVersionRegistrar localRef = INSTANCE;
52+
/** Returns an instance of {@link GlobalLibraryVersionRegistrar} */
53+
public static GlobalLibraryVersionRegistrar getInstance() {
54+
GlobalLibraryVersionRegistrar localRef = INSTANCE;
5555
if (localRef == null) {
56-
synchronized (OutOfBandLibraryVersionRegistrar.class) {
56+
synchronized (GlobalLibraryVersionRegistrar.class) {
5757
localRef = INSTANCE;
5858
if (localRef == null) {
59-
INSTANCE = localRef = new OutOfBandLibraryVersionRegistrar();
59+
INSTANCE = localRef = new GlobalLibraryVersionRegistrar();
6060
}
6161
}
6262
}

firebase-common/src/test/java/com/google/firebase/platforminfo/DefaultUserAgentPublisherTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@
3030
public class DefaultUserAgentPublisherTest {
3131
private Set<LibraryVersion> libraryVersions;
3232
private DefaultUserAgentPublisher userAgentPublisher;
33-
private OutOfBandLibraryVersionRegistrar outOfBandLibraryVersionRegistrar;
33+
private GlobalLibraryVersionRegistrar globalLibraryVersionRegistrar;
3434

3535
@Before
3636
public void before() {
3737
libraryVersions = new HashSet<>();
3838
libraryVersions.add(LibraryVersion.create("foo", "1"));
3939
libraryVersions.add(LibraryVersion.create("bar", "2"));
4040

41-
outOfBandLibraryVersionRegistrar = mock(OutOfBandLibraryVersionRegistrar.class);
41+
globalLibraryVersionRegistrar = mock(GlobalLibraryVersionRegistrar.class);
4242

43-
when(outOfBandLibraryVersionRegistrar.getRegisteredVersions()).thenReturn(new HashSet<>());
43+
when(globalLibraryVersionRegistrar.getRegisteredVersions()).thenReturn(new HashSet<>());
4444

4545
userAgentPublisher =
46-
new DefaultUserAgentPublisher(libraryVersions, outOfBandLibraryVersionRegistrar);
46+
new DefaultUserAgentPublisher(libraryVersions, globalLibraryVersionRegistrar);
4747
}
4848

4949
@Test
@@ -59,7 +59,7 @@ public void getUserAgent_createsConcatenatedStringOfSdkVersions() {
5959
@Test
6060
public void getUserAgent_returnsEmptyString_whenVersionSetIsEmpty() {
6161
userAgentPublisher =
62-
new DefaultUserAgentPublisher(new HashSet<>(), outOfBandLibraryVersionRegistrar);
62+
new DefaultUserAgentPublisher(new HashSet<>(), globalLibraryVersionRegistrar);
6363

6464
assertThat(userAgentPublisher.getUserAgent()).isEqualTo("");
6565
}
@@ -71,9 +71,9 @@ public void getUserAgent_returnsEmptyString_whenVersionSetIsEmpty() {
7171
HashSet<LibraryVersion> gamesLibraryVersions = new HashSet<>();
7272
gamesLibraryVersions.add(LibraryVersion.create("fizz", "1"));
7373
gamesLibraryVersions.add(LibraryVersion.create("buzz", "2"));
74-
when(outOfBandLibraryVersionRegistrar.getRegisteredVersions()).thenReturn(gamesLibraryVersions);
74+
when(globalLibraryVersionRegistrar.getRegisteredVersions()).thenReturn(gamesLibraryVersions);
7575
userAgentPublisher =
76-
new DefaultUserAgentPublisher(libraryVersions, outOfBandLibraryVersionRegistrar);
76+
new DefaultUserAgentPublisher(libraryVersions, globalLibraryVersionRegistrar);
7777

7878
String[] actualUserAgent = userAgentPublisher.getUserAgent().split(" ");
7979
Arrays.sort(actualUserAgent);
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
import org.junit.runners.JUnit4;
2222

2323
@RunWith(JUnit4.class)
24-
public class OutOfBandLibraryVersionRegistrarTest {
24+
public class GlobalLibraryVersionRegistrarTest {
2525
@Test
2626
public void registerVersion_persistsVersion() {
27-
OutOfBandLibraryVersionRegistrar outOfBandLibraryVersionRegistrar =
28-
new OutOfBandLibraryVersionRegistrar();
29-
outOfBandLibraryVersionRegistrar.registerVersion("foo", "1.1.1");
27+
GlobalLibraryVersionRegistrar globalLibraryVersionRegistrar =
28+
new GlobalLibraryVersionRegistrar();
29+
globalLibraryVersionRegistrar.registerVersion("foo", "1.1.1");
3030

31-
assertThat(outOfBandLibraryVersionRegistrar.getRegisteredVersions())
31+
assertThat(globalLibraryVersionRegistrar.getRegisteredVersions())
3232
.contains(LibraryVersion.create("foo", "1.1.1"));
3333
}
3434

3535
@Test
3636
public void getRegisteredVersions_returnsEmptySet_whenNoVersionsAreRegistered() {
37-
OutOfBandLibraryVersionRegistrar outOfBandLibraryVersionRegistrar =
38-
new OutOfBandLibraryVersionRegistrar();
37+
GlobalLibraryVersionRegistrar globalLibraryVersionRegistrar =
38+
new GlobalLibraryVersionRegistrar();
3939

40-
assertThat(outOfBandLibraryVersionRegistrar.getRegisteredVersions()).isEmpty();
40+
assertThat(globalLibraryVersionRegistrar.getRegisteredVersions()).isEmpty();
4141
}
4242
}

0 commit comments

Comments
 (0)