Skip to content

Commit afd04fe

Browse files
Unify import order, javadoc and code formatting.
1 parent c1727bf commit afd04fe

29 files changed

+123
-107
lines changed

objectbox-java/src/main/java/io/objectbox/Box.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ public boolean isEmpty() {
302302

303303
/**
304304
* Returns all stored Objects in this Box.
305+
*
305306
* @return since 2.4 the returned list is always mutable (before an empty result list was immutable)
306307
*/
307308
public List<T> getAll() {
@@ -320,8 +321,9 @@ public List<T> getAll() {
320321
/**
321322
* Check if an object with the given ID exists in the database.
322323
* This is more efficient than a {@link #get(long)} and comparing against null.
324+
*
325+
* @return true if an object with the given ID was found, false otherwise.
323326
* @since 2.7
324-
* @return true if a object with the given ID was found, false otherwise
325327
*/
326328
public boolean contains(long id) {
327329
Cursor<T> reader = getReader();
@@ -425,6 +427,7 @@ public void putBatched(@Nullable Collection<T> entities, int batchSize) {
425427

426428
/**
427429
* Removes (deletes) the Object by its ID.
430+
*
428431
* @return true if an entity was actually removed (false if no entity exists with the given ID)
429432
*/
430433
public boolean remove(long id) {
@@ -486,6 +489,7 @@ public void removeByIds(@Nullable Collection<Long> ids) {
486489

487490
/**
488491
* Removes (deletes) the given Object.
492+
*
489493
* @return true if an entity was actually removed (false if no entity exists with the given ID)
490494
*/
491495
public boolean remove(T object) {

objectbox-java/src/main/java/io/objectbox/BoxStore.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
package io.objectbox;
1818

19-
import io.objectbox.internal.Feature;
20-
import org.greenrobot.essentials.collections.LongHashMap;
21-
2219
import java.io.Closeable;
2320
import java.io.File;
2421
import java.io.IOException;
@@ -49,12 +46,14 @@
4946
import io.objectbox.exception.DbException;
5047
import io.objectbox.exception.DbExceptionListener;
5148
import io.objectbox.exception.DbSchemaException;
49+
import io.objectbox.internal.Feature;
5250
import io.objectbox.internal.NativeLibraryLoader;
5351
import io.objectbox.internal.ObjectBoxThreadPool;
5452
import io.objectbox.reactive.DataObserver;
5553
import io.objectbox.reactive.DataPublisher;
5654
import io.objectbox.reactive.SubscriptionBuilder;
5755
import io.objectbox.sync.SyncClient;
56+
import org.greenrobot.essentials.collections.LongHashMap;
5857

5958
/**
6059
* An ObjectBox database that provides {@link Box Boxes} to put and get objects of specific entity classes
@@ -267,7 +266,7 @@ public static boolean isSyncServerAvailable() {
267266

268267
try {
269268
handle = nativeCreateWithFlatOptions(builder.buildFlatStoreOptions(canonicalPath), builder.model);
270-
if(handle == 0) throw new DbException("Could not create native store");
269+
if (handle == 0) throw new DbException("Could not create native store");
271270

272271
int debugFlags = builder.debugFlags;
273272
if (debugFlags != 0) {
@@ -539,7 +538,7 @@ public Transaction beginTx() {
539538
System.out.println("Begin TX with commit count " + initialCommitCount);
540539
}
541540
long nativeTx = nativeBeginTx(handle);
542-
if(nativeTx == 0) throw new DbException("Could not create native transaction");
541+
if (nativeTx == 0) throw new DbException("Could not create native transaction");
543542

544543
Transaction tx = new Transaction(this, nativeTx, initialCommitCount);
545544
synchronized (transactions) {
@@ -565,7 +564,7 @@ public Transaction beginReadTx() {
565564
System.out.println("Begin read TX with commit count " + initialCommitCount);
566565
}
567566
long nativeTx = nativeBeginReadTx(handle);
568-
if(nativeTx == 0) throw new DbException("Could not create native read transaction");
567+
if (nativeTx == 0) throw new DbException("Could not create native read transaction");
569568

570569
Transaction tx = new Transaction(this, nativeTx, initialCommitCount);
571570
synchronized (transactions) {
@@ -601,7 +600,7 @@ public void close() {
601600
synchronized (this) {
602601
oldClosedState = closed;
603602
if (!closed) {
604-
if(objectBrowserPort != 0) { // not linked natively (yet), so clean up here
603+
if (objectBrowserPort != 0) { // not linked natively (yet), so clean up here
605604
try {
606605
stopObjectBrowser();
607606
} catch (Throwable e) {
@@ -679,7 +678,7 @@ public boolean deleteAllFiles() {
679678
* BoxStoreBuilder#DEFAULT_NAME})".
680679
*
681680
* @param objectStoreDirectory directory to be deleted; this is the value you previously provided to {@link
682-
* BoxStoreBuilder#directory(File)}
681+
* BoxStoreBuilder#directory(File)}
683682
* @return true if the directory 1) was deleted successfully OR 2) did not exist in the first place.
684683
* Note: If false is returned, any number of files may have been deleted before the failure happened.
685684
* @throws IllegalStateException if the given directory is still used by a open {@link BoxStore}.
@@ -715,9 +714,9 @@ public static boolean deleteAllFiles(File objectStoreDirectory) {
715714
* If you did not use a custom name with BoxStoreBuilder, you can pass "new File({@link
716715
* BoxStoreBuilder#DEFAULT_NAME})".
717716
*
718-
* @param androidContext provide an Android Context like Application or Service
717+
* @param androidContext provide an Android Context like Application or Service
719718
* @param customDbNameOrNull use null for default name, or the name you previously provided to {@link
720-
* BoxStoreBuilder#name(String)}.
719+
* BoxStoreBuilder#name(String)}.
721720
* @return true if the directory 1) was deleted successfully OR 2) did not exist in the first place.
722721
* Note: If false is returned, any number of files may have been deleted before the failure happened.
723722
* @throws IllegalStateException if the given name is still used by a open {@link BoxStore}.
@@ -736,9 +735,9 @@ public static boolean deleteAllFiles(Object androidContext, @Nullable String cus
736735
* BoxStoreBuilder#DEFAULT_NAME})".
737736
*
738737
* @param baseDirectoryOrNull use null for no base dir, or the value you previously provided to {@link
739-
* BoxStoreBuilder#baseDirectory(File)}
740-
* @param customDbNameOrNull use null for default name, or the name you previously provided to {@link
741-
* BoxStoreBuilder#name(String)}.
738+
* BoxStoreBuilder#baseDirectory(File)}
739+
* @param customDbNameOrNull use null for default name, or the name you previously provided to {@link
740+
* BoxStoreBuilder#name(String)}.
742741
* @return true if the directory 1) was deleted successfully OR 2) did not exist in the first place.
743742
* Note: If false is returned, any number of files may have been deleted before the failure happened.
744743
* @throws IllegalStateException if the given directory (+name) is still used by a open {@link BoxStore}.
@@ -1055,8 +1054,9 @@ public String diagnose() {
10551054
/**
10561055
* Validate database pages, a lower level storage unit (integrity check).
10571056
* Do not call this inside a transaction (currently unsupported).
1057+
*
10581058
* @param pageLimit the maximum of pages to validate (e.g. to limit time spent on validation).
1059-
* Pass zero set no limit and thus validate all pages.
1059+
* Pass zero set no limit and thus validate all pages.
10601060
* @param checkLeafLevel Flag to validate leaf pages. These do not point to other pages but contain data.
10611061
* @return Number of pages validated, which may be twice the given pageLimit as internally there are "two DBs".
10621062
* @throws DbException if validation failed to run (does not tell anything about DB file consistency).
@@ -1172,7 +1172,7 @@ public String startObjectBrowser(String urlToBindTo) {
11721172

11731173
@Experimental
11741174
public synchronized boolean stopObjectBrowser() {
1175-
if(objectBrowserPort == 0) {
1175+
if (objectBrowserPort == 0) {
11761176
throw new IllegalStateException("ObjectBrowser has not been started before");
11771177
}
11781178
objectBrowserPort = 0;

objectbox-java/src/main/java/io/objectbox/BoxStoreBuilder.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
package io.objectbox;
1818

19-
import io.objectbox.flatbuffers.FlatBufferBuilder;
20-
21-
import org.greenrobot.essentials.io.IoUtils;
22-
2319
import java.io.BufferedInputStream;
2420
import java.io.BufferedOutputStream;
2521
import java.io.File;
@@ -38,9 +34,11 @@
3834
import io.objectbox.annotation.apihint.Experimental;
3935
import io.objectbox.annotation.apihint.Internal;
4036
import io.objectbox.exception.DbException;
37+
import io.objectbox.flatbuffers.FlatBufferBuilder;
4138
import io.objectbox.ideasonly.ModelUpdate;
4239
import io.objectbox.model.FlatStoreOptions;
4340
import io.objectbox.model.ValidateOnOpenMode;
41+
import org.greenrobot.essentials.io.IoUtils;
4442

4543
/**
4644
* Configures and builds a {@link BoxStore} with reasonable defaults. To get an instance use {@code MyObjectBox.builder()}.
@@ -299,7 +297,7 @@ public BoxStoreBuilder fileMode(int mode) {
299297
* amount of threads you are using.
300298
* For highly concurrent setups (e.g. you are using ObjectBox on the server side) it may make sense to increase the
301299
* number.
302-
*
300+
* <p>
303301
* Note: Each thread that performed a read transaction and is still alive holds on to a reader slot.
304302
* These slots only get vacated when the thread ends. Thus, be mindful with the number of active threads.
305303
* Alternatively, you can opt to try the experimental noReaderThreadLocals option flag.
@@ -312,9 +310,9 @@ public BoxStoreBuilder maxReaders(int maxReaders) {
312310
/**
313311
* Disables the usage of thread locals for "readers" related to read transactions.
314312
* This can make sense if you are using a lot of threads that are kept alive.
315-
*
313+
* <p>
316314
* Note: This is still experimental, as it comes with subtle behavior changes at a low level and may affect
317-
* corner cases with e.g. transactions, which may not be fully tested at the moment.
315+
* corner cases with e.g. transactions, which may not be fully tested at the moment.
318316
*/
319317
public BoxStoreBuilder noReaderThreadLocals() {
320318
this.noReaderThreadLocals = true;
@@ -527,7 +525,7 @@ byte[] buildFlatStoreOptions(String canonicalPath) {
527525
int offset = FlatStoreOptions.endFlatStoreOptions(fbb);
528526
fbb.finish(offset);
529527
return fbb.sizedByteArray();
530-
}
528+
}
531529

532530
/**
533531
* Builds a {@link BoxStore} using any given configuration.

objectbox-java/src/main/java/io/objectbox/ModelBuilder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616

1717
package io.objectbox;
1818

19-
import io.objectbox.flatbuffers.FlatBufferBuilder;
20-
2119
import java.util.ArrayList;
2220
import java.util.List;
2321

2422
import javax.annotation.Nullable;
2523

2624
import io.objectbox.annotation.apihint.Internal;
25+
import io.objectbox.flatbuffers.FlatBufferBuilder;
2726
import io.objectbox.model.IdUid;
2827
import io.objectbox.model.Model;
2928
import io.objectbox.model.ModelEntity;

objectbox-java/src/main/java/io/objectbox/ObjectClassPublisher.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
package io.objectbox;
1818

19-
import org.greenrobot.essentials.collections.MultimapSet;
20-
import org.greenrobot.essentials.collections.MultimapSet.SetType;
21-
2219
import java.util.ArrayDeque;
2320
import java.util.Collection;
2421
import java.util.Collections;
@@ -32,6 +29,8 @@
3229
import io.objectbox.reactive.DataPublisher;
3330
import io.objectbox.reactive.DataPublisherUtils;
3431
import io.objectbox.reactive.SubscriptionBuilder;
32+
import org.greenrobot.essentials.collections.MultimapSet;
33+
import org.greenrobot.essentials.collections.MultimapSet.SetType;
3534

3635
/**
3736
* A {@link DataPublisher} that notifies {@link DataObserver}s about changes in an entity box.
@@ -45,14 +44,17 @@ class ObjectClassPublisher implements DataPublisher<Class>, Runnable {
4544
final BoxStore boxStore;
4645
final MultimapSet<Integer, DataObserver<Class>> observersByEntityTypeId = MultimapSet.create(SetType.THREAD_SAFE);
4746
private final Deque<PublishRequest> changesQueue = new ArrayDeque<>();
47+
4848
private static class PublishRequest {
4949
@Nullable private final DataObserver<Class> observer;
5050
private final int[] entityTypeIds;
51+
5152
PublishRequest(@Nullable DataObserver<Class> observer, int[] entityTypeIds) {
5253
this.observer = observer;
5354
this.entityTypeIds = entityTypeIds;
5455
}
5556
}
57+
5658
volatile boolean changePublisherRunning;
5759

5860
ObjectClassPublisher(BoxStore boxStore) {

objectbox-java/src/main/java/io/objectbox/Property.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717
package io.objectbox;
1818

19+
import java.io.Serializable;
20+
import java.util.Collection;
21+
import java.util.Date;
22+
23+
import javax.annotation.Nullable;
24+
1925
import io.objectbox.annotation.apihint.Internal;
2026
import io.objectbox.converter.PropertyConverter;
2127
import io.objectbox.exception.DbException;
@@ -34,11 +40,6 @@
3440
import io.objectbox.query.PropertyQueryConditionImpl.StringStringCondition;
3541
import io.objectbox.query.QueryBuilder.StringOrder;
3642

37-
import javax.annotation.Nullable;
38-
import java.io.Serializable;
39-
import java.util.Collection;
40-
import java.util.Date;
41-
4243
/**
4344
* Meta data describing a Property of an ObjectBox Entity.
4445
* Properties are typically used when defining {@link io.objectbox.query.Query Query} conditions
@@ -60,7 +61,8 @@ public class Property<ENTITY> implements Serializable {
6061
public final boolean isId;
6162
public final boolean isVirtual;
6263
public final String dbName;
63-
@SuppressWarnings("rawtypes") // Use raw type of PropertyConverter to allow users to supply a generic implementation.
64+
@SuppressWarnings("rawtypes")
65+
// Use raw type of PropertyConverter to allow users to supply a generic implementation.
6466
public final Class<? extends PropertyConverter> converterClass;
6567

6668
/** Type, which is converted to a type supported by the DB. */
@@ -83,14 +85,16 @@ public Property(EntityInfo<ENTITY> entity, int ordinal, int id, Class<?> type, S
8385
this(entity, ordinal, id, type, name, isId, dbName, null, null);
8486
}
8587

86-
@SuppressWarnings("rawtypes") // Use raw type of PropertyConverter to allow users to supply a generic implementation.
88+
@SuppressWarnings("rawtypes")
89+
// Use raw type of PropertyConverter to allow users to supply a generic implementation.
8790
public Property(EntityInfo<ENTITY> entity, int ordinal, int id, Class<?> type, String name, boolean isId,
8891
@Nullable String dbName, @Nullable Class<? extends PropertyConverter> converterClass,
8992
@Nullable Class<?> customType) {
9093
this(entity, ordinal, id, type, name, isId, false, dbName, converterClass, customType);
9194
}
9295

93-
@SuppressWarnings("rawtypes") // Use raw type of PropertyConverter to allow users to supply a generic implementation.
96+
@SuppressWarnings("rawtypes")
97+
// Use raw type of PropertyConverter to allow users to supply a generic implementation.
9498
public Property(EntityInfo<ENTITY> entity, int ordinal, int id, Class<?> type, String name, boolean isId,
9599
boolean isVirtual, @Nullable String dbName,
96100
@Nullable Class<? extends PropertyConverter> converterClass, @Nullable Class<?> customType) {

objectbox-java/src/main/java/io/objectbox/Transaction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public <T> Cursor<T> createCursor(Class<T> entityClass) {
184184
EntityInfo<T> entityInfo = store.getEntityInfo(entityClass);
185185
CursorFactory<T> factory = entityInfo.getCursorFactory();
186186
long cursorHandle = nativeCreateCursor(transaction, entityInfo.getDbName(), entityClass);
187-
if(cursorHandle == 0) throw new DbException("Could not create native cursor");
187+
if (cursorHandle == 0) throw new DbException("Could not create native cursor");
188188
return factory.createCursor(this, cursorHandle, store);
189189
}
190190

objectbox-java/src/main/java/io/objectbox/ideasonly/ModelModifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void remove() {
3535
}
3636

3737
public PropertyModifier property(String name) {
38-
return new PropertyModifier(this, name);
38+
return new PropertyModifier(this, name);
3939
}
4040
}
4141

objectbox-java/src/main/java/io/objectbox/internal/DebugCursor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class DebugCursor implements Closeable {
4242
public static DebugCursor create(Transaction tx) {
4343
long txHandle = InternalAccess.getHandle(tx);
4444
long handle = nativeCreate(txHandle);
45-
if(handle == 0) throw new DbException("Could not create native debug cursor");
45+
if (handle == 0) throw new DbException("Could not create native debug cursor");
4646
return new DebugCursor(tx, handle);
4747
}
4848

objectbox-java/src/main/java/io/objectbox/internal/Feature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public enum Feature {
1111
/** TimeSeries support (date/date-nano companion ID and other time-series functionality). */
1212
TIME_SERIES(2),
1313

14-
/** Sync client availability. Visit <a href="https://objectbox.io/sync">the ObjectBox Sync website</a> for more details. */
14+
/** Sync client availability. Visit <a href="https://objectbox.io/sync">the ObjectBox Sync website</a> for more details. */
1515
SYNC(3),
1616

1717
/** Check whether debug log can be enabled during runtime. */

objectbox-java/src/main/java/io/objectbox/internal/NativeLibraryLoader.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616

1717
package io.objectbox.internal;
1818

19-
import io.objectbox.BoxStore;
20-
import org.greenrobot.essentials.io.IoUtils;
21-
22-
import javax.annotation.Nonnull;
23-
import javax.annotation.Nullable;
2419
import java.io.BufferedInputStream;
2520
import java.io.BufferedOutputStream;
2621
import java.io.BufferedReader;
@@ -37,6 +32,12 @@
3732
import java.net.URLConnection;
3833
import java.util.Arrays;
3934

35+
import javax.annotation.Nonnull;
36+
import javax.annotation.Nullable;
37+
38+
import io.objectbox.BoxStore;
39+
import org.greenrobot.essentials.io.IoUtils;
40+
4041
/**
4142
* Separate class, so we can mock BoxStore.
4243
*/
@@ -162,7 +163,7 @@ private static String getCpuArch() {
162163
String cpuArchOS = cpuArchOSOrNull.toLowerCase();
163164
if (cpuArchOS.startsWith("armv7")) {
164165
cpuArch = "armv7";
165-
} else if (cpuArchOS.startsWith("armv6")){
166+
} else if (cpuArchOS.startsWith("armv6")) {
166167
cpuArch = "armv6";
167168
} // else use fall back below.
168169
} // else use fall back below.

objectbox-java/src/main/java/io/objectbox/internal/ObjectBoxThreadPool.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
* <li>Reduce keep-alive time for threads to 20 seconds</li>
3434
* <li>Uses a ThreadFactory to name threads like "ObjectBox-1-Thread-1"</li>
3535
* </ul>
36-
*
3736
*/
3837
@Internal
3938
public class ObjectBoxThreadPool extends ThreadPoolExecutor {

0 commit comments

Comments
 (0)