Skip to content

Commit 93746a9

Browse files
greenrobotgreenrobot-team
authored andcommitted
Rename ValidateOnOpenMode to ValidateOnOpenModePages #190
1 parent d539ad4 commit 93746a9

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
import io.objectbox.annotation.apihint.Internal;
3636
import io.objectbox.config.DebugFlags;
3737
import io.objectbox.config.FlatStoreOptions;
38-
import io.objectbox.config.ValidateOnOpenMode;
3938
import io.objectbox.config.ValidateOnOpenModeKv;
39+
import io.objectbox.config.ValidateOnOpenModePages;
4040
import io.objectbox.exception.DbException;
4141
import io.objectbox.exception.DbFullException;
4242
import io.objectbox.exception.DbMaxDataSizeExceededException;
@@ -414,13 +414,14 @@ public BoxStoreBuilder usePreviousCommit() {
414414
* See also {@link #validateOnOpenPageLimit(long)} to fine-tune this check and {@link #validateOnOpenKv(short)} for
415415
* additional checks.
416416
*
417-
* @param validateOnOpenMode One of {@link ValidateOnOpenMode}.
417+
* @param validateOnOpenModePages One of {@link ValidateOnOpenModePages}.
418418
*/
419-
public BoxStoreBuilder validateOnOpen(short validateOnOpenMode) {
420-
if (validateOnOpenMode < ValidateOnOpenMode.None || validateOnOpenMode > ValidateOnOpenMode.Full) {
421-
throw new IllegalArgumentException("Must be one of ValidateOnOpenMode");
419+
public BoxStoreBuilder validateOnOpen(short validateOnOpenModePages) {
420+
if (validateOnOpenModePages < ValidateOnOpenModePages.None
421+
|| validateOnOpenModePages > ValidateOnOpenModePages.Full) {
422+
throw new IllegalArgumentException("Must be one of ValidateOnOpenModePages");
422423
}
423-
this.validateOnOpenModePages = validateOnOpenMode;
424+
this.validateOnOpenModePages = validateOnOpenModePages;
424425
return this;
425426
}
426427

@@ -429,10 +430,12 @@ public BoxStoreBuilder validateOnOpen(short validateOnOpenMode) {
429430
* This is measured in "pages" with a page typically holding 4000.
430431
* Usually a low number (e.g. 1-20) is sufficient and does not impact startup performance significantly.
431432
* <p>
432-
* This can only be used with {@link ValidateOnOpenMode#Regular} and {@link ValidateOnOpenMode#WithLeaves}.
433+
* This can only be used with {@link ValidateOnOpenModePages#Regular} and
434+
* {@link ValidateOnOpenModePages#WithLeaves}.
433435
*/
434436
public BoxStoreBuilder validateOnOpenPageLimit(long limit) {
435-
if (validateOnOpenModePages != ValidateOnOpenMode.Regular && validateOnOpenModePages != ValidateOnOpenMode.WithLeaves) {
437+
if (validateOnOpenModePages != ValidateOnOpenModePages.Regular &&
438+
validateOnOpenModePages != ValidateOnOpenModePages.WithLeaves) {
436439
throw new IllegalStateException("Must call validateOnOpen(mode) with mode Regular or WithLeaves first");
437440
}
438441
if (limit < 1) {

objectbox-java/src/main/java/io/objectbox/config/ValidateOnOpenMode.java renamed to objectbox-java/src/main/java/io/objectbox/config/ValidateOnOpenModePages.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
* Defines if and how the database is checked for structural consistency (pages) when opening it.
2323
*/
2424
@SuppressWarnings("unused")
25-
public final class ValidateOnOpenMode {
26-
private ValidateOnOpenMode() { }
25+
public final class ValidateOnOpenModePages {
26+
private ValidateOnOpenModePages() { }
2727
/**
2828
* Not a real type, just best practice (e.g. forward compatibility)
2929
*/

objectbox-java/src/main/java/io/objectbox/model/ValidateOnOpenMode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* Defines if and how the database is checked for structural consistency (pages) when opening it.
2323
*
24-
* @deprecated This class has moved to the config package, use {@link io.objectbox.config.ValidateOnOpenMode} instead.
24+
* @deprecated This class has moved to the config package, use {@link io.objectbox.config.ValidateOnOpenModePages} instead.
2525
*/
2626
@Deprecated
2727
@SuppressWarnings("unused")

tests/objectbox-java-test/src/test/java/io/objectbox/BoxStoreValidationTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.io.IOException;
2222
import java.io.InputStream;
2323

24-
import io.objectbox.config.ValidateOnOpenMode;
24+
import io.objectbox.config.ValidateOnOpenModePages;
2525
import io.objectbox.exception.FileCorruptException;
2626
import io.objectbox.exception.PagesCorruptException;
2727
import org.greenrobot.essentials.io.IoUtils;
@@ -62,7 +62,7 @@ public void validateOnOpen() {
6262
// Then re-open database with validation and ensure db is operational
6363
builder = new BoxStoreBuilder(model).directory(boxStoreDir);
6464
builder.entity(new TestEntity_());
65-
builder.validateOnOpen(ValidateOnOpenMode.Full);
65+
builder.validateOnOpen(ValidateOnOpenModePages.Full);
6666
store = builder.build();
6767
assertNotNull(getTestEntityBox().get(id));
6868
getTestEntityBox().put(new TestEntity(0));
@@ -75,7 +75,7 @@ public void validateOnOpenCorruptFile() throws IOException {
7575
prepareBadDataFile(dir, "corrupt-pageno-in-branch-data.mdb");
7676

7777
builder = BoxStoreBuilder.createDebugWithoutModel().directory(dir);
78-
builder.validateOnOpen(ValidateOnOpenMode.Full);
78+
builder.validateOnOpen(ValidateOnOpenModePages.Full);
7979

8080
@SuppressWarnings("resource")
8181
FileCorruptException ex = assertThrows(PagesCorruptException.class, () -> builder.build());
@@ -90,7 +90,7 @@ public void usePreviousCommitWithCorruptFile() throws IOException {
9090
File dir = prepareTempDir("object-store-test-corrupted");
9191
prepareBadDataFile(dir, "corrupt-pageno-in-branch-data.mdb");
9292
builder = BoxStoreBuilder.createDebugWithoutModel().directory(dir);
93-
builder.validateOnOpen(ValidateOnOpenMode.Full).usePreviousCommit();
93+
builder.validateOnOpen(ValidateOnOpenModePages.Full).usePreviousCommit();
9494
store = builder.build();
9595
String diagnoseString = store.diagnose();
9696
assertTrue(diagnoseString.contains("entries=2"));
@@ -104,7 +104,7 @@ public void usePreviousCommitAfterFileCorruptException() throws IOException {
104104
File dir = prepareTempDir("object-store-test-corrupted");
105105
prepareBadDataFile(dir, "corrupt-pageno-in-branch-data.mdb");
106106
builder = BoxStoreBuilder.createDebugWithoutModel().directory(dir);
107-
builder.validateOnOpen(ValidateOnOpenMode.Full);
107+
builder.validateOnOpen(ValidateOnOpenModePages.Full);
108108
try {
109109
store = builder.build();
110110
fail("Should have thrown");

0 commit comments

Comments
 (0)