Skip to content

Commit cd375f8

Browse files
Align APIs: replace manualStart() with buildAndStart() for server.
1 parent 100ed29 commit cd375f8

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

objectbox-java/src/main/java/io/objectbox/sync/server/SyncServerBuilder.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class SyncServerBuilder {
2323

2424
@Nullable String certificatePath;
2525
SyncChangeListener changesListener;
26-
boolean manualStart;
2726

2827
public SyncServerBuilder(BoxStore boxStore, String url, SyncCredentials authenticatorCredentials) {
2928
checkNotNull(boxStore, "BoxStore is required.");
@@ -52,17 +51,6 @@ public SyncServerBuilder authenticatorCredentials(SyncCredentials authenticatorC
5251
return this;
5352
}
5453

55-
/**
56-
* Prevents the server from starting automatically.
57-
* It will need to be started manually later.
58-
*
59-
* @see SyncServer#start()
60-
*/
61-
public SyncServerBuilder manualStart() {
62-
manualStart = true;
63-
return this;
64-
}
65-
6654
/**
6755
* Sets a listener to observe fine granular changes happening during sync.
6856
* This listener can also be set (or removed) on the sync client directly.
@@ -90,6 +78,8 @@ public SyncServerBuilder peer(String url, SyncCredentials credentials) {
9078
}
9179

9280
/**
81+
* Builds and returns a Sync server ready to {@link SyncServer#start()}.
82+
*
9383
* Note: this clears all previously set authenticator credentials.
9484
*/
9585
public SyncServer build() {
@@ -99,6 +89,15 @@ public SyncServer build() {
9989
return new SyncServerImpl(this);
10090
}
10191

92+
/**
93+
* Builds, {@link SyncServer#start() starts} and returns a Sync server.
94+
*/
95+
public SyncServer buildAndStart() {
96+
SyncServer syncServer = build();
97+
syncServer.start();
98+
return syncServer;
99+
}
100+
102101
private void checkNotNull(Object object, String message) {
103102
if (object == null) {
104103
throw new IllegalArgumentException(message);

objectbox-java/src/main/java/io/objectbox/sync/server/SyncServerImpl.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ public class SyncServerImpl implements SyncServer {
4444
if (builder.changesListener != null) {
4545
setSyncChangesListener(builder.changesListener);
4646
}
47-
48-
if (!builder.manualStart) {
49-
start();
50-
}
5147
}
5248

5349
@Override

0 commit comments

Comments
 (0)