Skip to content

Commit 16c5247

Browse files
Align APIs: replace manualStart() with buildAndStart().
1 parent b967dff commit 16c5247

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

objectbox-java/src/main/java/io/objectbox/sync/SyncBuilder.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public class SyncBuilder {
2525
@Nullable
2626
String[] trustedCertPaths;
2727
boolean uncommittedAcks;
28-
boolean manualStart;
2928

3029
RequestUpdatesMode requestUpdatesMode = RequestUpdatesMode.AUTO;
3130

@@ -103,18 +102,6 @@ public SyncBuilder uncommittedAcks() {
103102
return this;
104103
}
105104

106-
107-
/**
108-
* Prevents the client from starting (connecting, logging in, syncing) automatically.
109-
* It will need to be started manually later.
110-
*
111-
* @see SyncClient#start()
112-
*/
113-
public SyncBuilder manualStart() {
114-
manualStart = true;
115-
return this;
116-
}
117-
118105
/**
119106
* Sets a listener to observe sync events like login or sync completion.
120107
* This listener can also be set (or removed) on the sync client directly.
@@ -137,13 +124,22 @@ public SyncBuilder changesListener(SyncChangesListener changesListener) {
137124
return this;
138125
}
139126

127+
/**
128+
* Builds and returns a Sync client ready to {@link SyncClient#start()}.
129+
*/
140130
public SyncClient build() {
141-
if (credentials == null) {
142-
throw new IllegalStateException("Credentials are required.");
143-
}
144131
return new SyncClientImpl(this);
145132
}
146133

134+
/**
135+
* Builds, {@link SyncClient#start() starts} and returns a Sync client.
136+
*/
137+
public SyncClient buildAndStart() {
138+
SyncClient syncClient = build();
139+
syncClient.start();
140+
return syncClient;
141+
}
142+
147143
private void checkNotNull(Object object, String message) {
148144
//noinspection ConstantConditions Non-null annotation does not enforce, so check for null.
149145
if (object == null) {

objectbox-java/src/main/java/io/objectbox/sync/SyncClientImpl.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ public class SyncClientImpl implements SyncClient {
5757
}
5858

5959
setLoginCredentials(builder.credentials);
60-
61-
if (!builder.manualStart) {
62-
start();
63-
}
6460
}
6561

6662
@Override

0 commit comments

Comments
 (0)