├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── feature_request.md ├── dependabot.yml └── workflows │ └── close-no-response.yml ├── .gitignore ├── .gitlab-ci.yml ├── .gitlab └── merge_request_templates │ └── Default.md ├── CHANGELOG.md ├── Jenkinsfile ├── LICENSE.txt ├── README.md ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts ├── settings.gradle.kts └── src │ └── main │ └── kotlin │ └── objectbox-publish.gradle.kts ├── ci ├── Jenkinsfile-Windows └── send-to-gchat.sh ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── logo.png ├── objectbox-java-api ├── LICENSE ├── NOTICE ├── build.gradle └── src │ └── main │ └── java │ └── io │ └── objectbox │ ├── annotation │ ├── Backlink.java │ ├── BaseEntity.java │ ├── ConflictStrategy.java │ ├── Convert.java │ ├── DatabaseType.java │ ├── DefaultValue.java │ ├── Entity.java │ ├── ExternalPropertyType.java │ ├── ExternalType.java │ ├── HnswFlags.java │ ├── HnswIndex.java │ ├── Id.java │ ├── IdCompanion.java │ ├── Index.java │ ├── IndexType.java │ ├── NameInDb.java │ ├── NotNull.java │ ├── OrderBy.java │ ├── Sync.java │ ├── TargetIdProperty.java │ ├── Transient.java │ ├── Type.java │ ├── Uid.java │ ├── Unique.java │ ├── Unsigned.java │ ├── VectorDistanceType.java │ ├── apihint │ │ ├── Beta.java │ │ ├── Experimental.java │ │ ├── Internal.java │ │ └── package-info.java │ └── package-info.java │ └── converter │ ├── PropertyConverter.java │ └── package-info.java ├── objectbox-java ├── build.gradle ├── spotbugs-exclude.xml └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── objectbox │ │ │ ├── Box.java │ │ │ ├── BoxStore.java │ │ │ ├── BoxStoreBuilder.java │ │ │ ├── Cursor.java │ │ │ ├── DebugFlags.java │ │ │ ├── EntityInfo.java │ │ │ ├── Factory.java │ │ │ ├── InternalAccess.java │ │ │ ├── KeyValueCursor.java │ │ │ ├── ModelBuilder.java │ │ │ ├── ObjectClassPublisher.java │ │ │ ├── Property.java │ │ │ ├── Transaction.java │ │ │ ├── TxCallback.java │ │ │ ├── config │ │ │ ├── DebugFlags.java │ │ │ ├── FlatStoreOptions.java │ │ │ ├── TreeOptionFlags.java │ │ │ ├── ValidateOnOpenModeKv.java │ │ │ └── ValidateOnOpenModePages.java │ │ │ ├── converter │ │ │ ├── FlexObjectConverter.java │ │ │ ├── IntegerFlexMapConverter.java │ │ │ ├── IntegerLongMapConverter.java │ │ │ ├── LongFlexMapConverter.java │ │ │ ├── LongLongMapConverter.java │ │ │ ├── NullToEmptyStringConverter.java │ │ │ ├── StringFlexMapConverter.java │ │ │ ├── StringLongMapConverter.java │ │ │ └── StringMapConverter.java │ │ │ ├── exception │ │ │ ├── ConstraintViolationException.java │ │ │ ├── DbDetachedException.java │ │ │ ├── DbException.java │ │ │ ├── DbExceptionListener.java │ │ │ ├── DbFullException.java │ │ │ ├── DbMaxDataSizeExceededException.java │ │ │ ├── DbMaxReadersExceededException.java │ │ │ ├── DbSchemaException.java │ │ │ ├── DbShutdownException.java │ │ │ ├── FeatureNotAvailableException.java │ │ │ ├── FileCorruptException.java │ │ │ ├── NonUniqueResultException.java │ │ │ ├── NumericOverflowException.java │ │ │ ├── PagesCorruptException.java │ │ │ ├── UniqueViolationException.java │ │ │ └── package-info.java │ │ │ ├── flatbuffers │ │ │ ├── ArrayReadWriteBuf.java │ │ │ ├── BaseVector.java │ │ │ ├── BooleanVector.java │ │ │ ├── ByteBufferReadWriteBuf.java │ │ │ ├── ByteBufferUtil.java │ │ │ ├── ByteVector.java │ │ │ ├── Constants.java │ │ │ ├── DoubleVector.java │ │ │ ├── FlatBufferBuilder.java │ │ │ ├── FlexBuffers.java │ │ │ ├── FlexBuffersBuilder.java │ │ │ ├── FloatVector.java │ │ │ ├── IntVector.java │ │ │ ├── LICENSE.txt │ │ │ ├── LongVector.java │ │ │ ├── README.md │ │ │ ├── ReadBuf.java │ │ │ ├── ReadWriteBuf.java │ │ │ ├── ShortVector.java │ │ │ ├── StringVector.java │ │ │ ├── Struct.java │ │ │ ├── Table.java │ │ │ ├── UnionVector.java │ │ │ ├── Utf8.java │ │ │ ├── Utf8Old.java │ │ │ └── Utf8Safe.java │ │ │ ├── ideasonly │ │ │ ├── ModelModifier.java │ │ │ └── ModelUpdate.java │ │ │ ├── internal │ │ │ ├── CallWithHandle.java │ │ │ ├── CursorFactory.java │ │ │ ├── DebugCursor.java │ │ │ ├── Feature.java │ │ │ ├── IdGetter.java │ │ │ ├── JniTest.java │ │ │ ├── NativeLibraryLoader.java │ │ │ ├── ObjectBoxThreadPool.java │ │ │ ├── ReflectionCache.java │ │ │ ├── ToManyGetter.java │ │ │ ├── ToOneGetter.java │ │ │ └── package-info.java │ │ │ ├── model │ │ │ ├── EntityFlags.java │ │ │ ├── ExternalPropertyType.java │ │ │ ├── HnswDistanceType.java │ │ │ ├── HnswFlags.java │ │ │ ├── HnswParams.java │ │ │ ├── IdUid.java │ │ │ ├── Model.java │ │ │ ├── ModelEntity.java │ │ │ ├── ModelProperty.java │ │ │ ├── ModelRelation.java │ │ │ ├── PropertyFlags.java │ │ │ ├── PropertyType.java │ │ │ └── ValidateOnOpenMode.java │ │ │ ├── package-info.java │ │ │ ├── query │ │ │ ├── BreakForEach.java │ │ │ ├── EagerRelation.java │ │ │ ├── IdWithScore.java │ │ │ ├── InternalAccess.java │ │ │ ├── LazyList.java │ │ │ ├── LogicQueryCondition.java │ │ │ ├── ObjectWithScore.java │ │ │ ├── OrderFlags.java │ │ │ ├── PropertyQuery.java │ │ │ ├── PropertyQueryCondition.java │ │ │ ├── PropertyQueryConditionImpl.java │ │ │ ├── Query.java │ │ │ ├── QueryBuilder.java │ │ │ ├── QueryCondition.java │ │ │ ├── QueryConditionImpl.java │ │ │ ├── QueryConsumer.java │ │ │ ├── QueryFilter.java │ │ │ ├── QueryPublisher.java │ │ │ ├── QueryThreadLocal.java │ │ │ ├── RelationCountCondition.java │ │ │ └── package-info.java │ │ │ ├── reactive │ │ │ ├── DataObserver.java │ │ │ ├── DataPublisher.java │ │ │ ├── DataPublisherUtils.java │ │ │ ├── DataSubscription.java │ │ │ ├── DataSubscriptionImpl.java │ │ │ ├── DataSubscriptionList.java │ │ │ ├── DataTransformer.java │ │ │ ├── DelegatingObserver.java │ │ │ ├── ErrorObserver.java │ │ │ ├── RunWithParam.java │ │ │ ├── Scheduler.java │ │ │ ├── Schedulers.java │ │ │ ├── SubscriptionBuilder.java │ │ │ ├── WeakDataObserver.java │ │ │ └── package-info.java │ │ │ ├── relation │ │ │ ├── ListFactory.java │ │ │ ├── RelationInfo.java │ │ │ ├── ToMany.java │ │ │ ├── ToOne.java │ │ │ └── package-info.java │ │ │ ├── sync │ │ │ ├── ConnectivityMonitor.java │ │ │ ├── Credentials.java │ │ │ ├── CredentialsType.java │ │ │ ├── ObjectsMessageBuilder.java │ │ │ ├── Sync.java │ │ │ ├── SyncBuilder.java │ │ │ ├── SyncChange.java │ │ │ ├── SyncClient.java │ │ │ ├── SyncClientImpl.java │ │ │ ├── SyncCredentials.java │ │ │ ├── SyncCredentialsToken.java │ │ │ ├── SyncCredentialsUserPassword.java │ │ │ ├── SyncFlags.java │ │ │ ├── SyncHybrid.java │ │ │ ├── SyncHybridBuilder.java │ │ │ ├── SyncLoginCodes.java │ │ │ ├── SyncState.java │ │ │ ├── internal │ │ │ │ └── Platform.java │ │ │ ├── listener │ │ │ │ ├── AbstractSyncListener.java │ │ │ │ ├── SyncChangeListener.java │ │ │ │ ├── SyncCompletedListener.java │ │ │ │ ├── SyncConnectionListener.java │ │ │ │ ├── SyncListener.java │ │ │ │ ├── SyncLoginListener.java │ │ │ │ └── SyncTimeListener.java │ │ │ ├── package-info.java │ │ │ └── server │ │ │ │ ├── ClusterFlags.java │ │ │ │ ├── ClusterPeerConfig.java │ │ │ │ ├── ClusterPeerInfo.java │ │ │ │ ├── JwtConfig.java │ │ │ │ ├── SyncServer.java │ │ │ │ ├── SyncServerBuilder.java │ │ │ │ ├── SyncServerFlags.java │ │ │ │ ├── SyncServerImpl.java │ │ │ │ └── SyncServerOptions.java │ │ │ └── tree │ │ │ ├── Branch.java │ │ │ ├── Leaf.java │ │ │ ├── LeafNode.java │ │ │ ├── Tree.java │ │ │ └── package-info.java │ └── resources │ │ └── META-INF │ │ └── proguard │ │ └── objectbox-java.pro │ └── web │ └── overview.html ├── objectbox-kotlin ├── build.gradle └── src │ └── main │ └── kotlin │ └── io │ └── objectbox │ └── kotlin │ ├── Box.kt │ ├── BoxStore.kt │ ├── Flow.kt │ ├── Property.kt │ ├── PropertyQueryCondition.kt │ ├── QueryBuilder.kt │ ├── QueryCondition.kt │ └── ToMany.kt ├── objectbox-rxjava ├── README.md ├── build.gradle └── src │ ├── main │ └── java │ │ └── io │ │ └── objectbox │ │ └── rx │ │ ├── RxBoxStore.java │ │ └── RxQuery.java │ └── test │ └── java │ └── io │ └── objectbox │ ├── query │ ├── FakeQueryPublisher.java │ └── MockQuery.java │ └── rx │ └── QueryObserverTest.java ├── objectbox-rxjava3 ├── README.md ├── build.gradle └── src │ ├── main │ └── java │ │ └── io │ │ └── objectbox │ │ └── rx3 │ │ ├── Query.kt │ │ ├── RxBoxStore.java │ │ └── RxQuery.java │ └── test │ └── java │ └── io │ └── objectbox │ ├── query │ ├── FakeQueryPublisher.java │ └── MockQuery.java │ └── rx3 │ ├── QueryKtxTest.kt │ └── QueryObserverTest.java ├── scripts ├── test-with-asan.sh └── update-flatbuffers.sh ├── settings.gradle.kts └── tests ├── README.md ├── objectbox-java-test ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── io │ │ └── objectbox │ │ ├── TestEntity.java │ │ ├── TestEntityCursor.java │ │ ├── TestEntityMinimal.java │ │ ├── TestEntityMinimalCursor.java │ │ ├── TestEntityMinimal_.java │ │ ├── TestEntity_.java │ │ ├── index │ │ └── model │ │ │ ├── EntityLongIndex.java │ │ │ ├── EntityLongIndexCursor.java │ │ │ ├── EntityLongIndex_.java │ │ │ └── MyObjectBox.java │ │ └── relation │ │ ├── Customer.java │ │ ├── CustomerCursor.java │ │ ├── Customer_.java │ │ ├── MyObjectBox.java │ │ ├── Order.java │ │ ├── OrderCursor.java │ │ └── Order_.java │ └── test │ ├── java │ └── io │ │ └── objectbox │ │ ├── AbstractObjectBoxTest.java │ │ ├── BoxStoreBuilderTest.java │ │ ├── BoxStoreTest.java │ │ ├── BoxStoreTestK.kt │ │ ├── BoxStoreValidationTest.java │ │ ├── BoxTest.java │ │ ├── CursorBytesTest.java │ │ ├── CursorTest.java │ │ ├── DebugCursorTest.java │ │ ├── FlowTest.kt │ │ ├── JniBasicsTest.java │ │ ├── NonArgConstructorTest.java │ │ ├── ObjectClassObserverTest.java │ │ ├── TestUtils.java │ │ ├── TransactionTest.java │ │ ├── Utf8HashIndexTest.java │ │ ├── Utf8Test.java │ │ ├── Utf8ValueIndexTest.java │ │ ├── converter │ │ ├── FlexMapConverterTest.java │ │ ├── FlexObjectConverterTest.java │ │ └── StringMapConverterTest.java │ │ ├── exception │ │ └── ExceptionTest.java │ │ ├── index │ │ └── IndexReaderRenewTest.java │ │ ├── query │ │ ├── AbstractQueryTest.java │ │ ├── FlexQueryTest.java │ │ ├── LazyListTest.java │ │ ├── PropertyQueryTest.java │ │ ├── QueryCopyTest.java │ │ ├── QueryFilterComparatorTest.java │ │ ├── QueryObserverTest.java │ │ ├── QueryRelationCountTest.java │ │ ├── QueryScalarVectorTest.java │ │ ├── QueryTest.java │ │ ├── QueryTest2.java │ │ └── QueryTestK.kt │ │ ├── relation │ │ ├── AbstractRelationTest.java │ │ ├── ExternalTypeTest.java │ │ ├── LinkQueryTest.java │ │ ├── MultithreadedRelationTest.java │ │ ├── RelationEagerTest.java │ │ ├── RelationTest.java │ │ ├── ToManyStandaloneTest.java │ │ ├── ToManyTest.java │ │ └── ToOneTest.java │ │ ├── sync │ │ ├── ConnectivityMonitorTest.java │ │ ├── PlatformTest.java │ │ └── SyncTest.java │ │ └── tree │ │ ├── DataBranch.java │ │ ├── DataBranchCursor.java │ │ ├── DataBranch_.java │ │ ├── DataLeaf.java │ │ ├── DataLeafCursor.java │ │ ├── DataLeaf_.java │ │ ├── MetaBranch.java │ │ ├── MetaBranchCursor.java │ │ ├── MetaBranch_.java │ │ ├── MetaLeaf.java │ │ ├── MetaLeafCursor.java │ │ ├── MetaLeaf_.java │ │ ├── MyTreeModel.java │ │ └── TreeTest.java │ └── resources │ └── io │ └── objectbox │ ├── corrupt-keysize0-data.mdb │ └── corrupt-pageno-in-branch-data.mdb └── test-proguard ├── build.gradle.kts ├── proguard-android-optimize.txt └── src ├── main └── java │ └── io │ └── objectbox │ └── test │ └── proguard │ ├── MyObjectBox.java │ ├── ObfuscatedEntity.java │ ├── ObfuscatedEntityCursor.java │ └── ObfuscatedEntity_.java └── test └── java └── io └── objectbox └── test └── proguard └── ObfuscatedEntityTest.java /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Question 4 | url: https://stackoverflow.com/questions/tagged/objectbox 5 | about: Ask how to do something, or why it isn't working on Stack Overflow. 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an improvement for ObjectBox. 4 | title: '' 5 | labels: 'enhancement' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 18 | 19 | ### Is there an existing issue? 20 | 21 | - [ ] I have searched [existing issues](https://github.com/objectbox/objectbox-java/issues) 22 | 23 | ### Use case 24 | 25 | _TODO Describe what problem you are trying to solve._ 26 | 27 | ### Proposed solution 28 | 29 | _TODO Describe what you want to be able to do with ObjectBox._ 30 | 31 | ### Alternatives 32 | 33 | _TODO Describe any alternative solutions or features you've considered._ 34 | 35 | ### Additional context 36 | 37 | _TODO Add any other context (e.g. platform or language) about the feature request here._ 38 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Please see the documentation for all configuration options: 2 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 3 | 4 | version: 2 5 | updates: 6 | - package-ecosystem: "github-actions" 7 | directory: "/" 8 | schedule: 9 | interval: "weekly" 10 | -------------------------------------------------------------------------------- /.github/workflows/close-no-response.yml: -------------------------------------------------------------------------------- 1 | name: Close inactive issues 2 | on: 3 | schedule: 4 | - cron: "15 1 * * *" # “At 01:15.” 5 | workflow_dispatch: # To support running manually. 6 | 7 | # Minimal access by default 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | close-issues: 13 | runs-on: ubuntu-latest 14 | permissions: 15 | issues: write 16 | pull-requests: write 17 | steps: 18 | # https://github.com/marketplace/actions/close-stale-issues 19 | - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 20 | with: 21 | days-before-stale: -1 # Add the stale label manually. 22 | days-before-close: 21 23 | only-labels: "more info required" 24 | stale-issue-label: "more info required" 25 | close-issue-message: "Without additional information, we are unfortunately not sure how to resolve this issue. Therefore this issue has been automatically closed. Feel free to comment with additional details and we can re-open this issue." 26 | close-pr-message: "Without additional information, we are unfortunately not sure how to address this pull request. Therefore this pull request has been automatically closed. Feel free to comment with additional details or submit a new pull request." 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | # IntelliJ Idea 4 | .idea/ 5 | *.iml 6 | 7 | # Gradle & Java build 8 | .gradle 9 | build/ 10 | bin/ 11 | gen/ 12 | target/ 13 | out/ 14 | classes/ 15 | 16 | # Local build properties 17 | build.properties 18 | local.properties 19 | 20 | # Native libs 21 | objectbox*.dll 22 | libobjectbox*.so 23 | libobjectbox*.dylib 24 | 25 | ### Test DB files 26 | data.mdb 27 | lock.mdb 28 | test-db/ 29 | jni-unit-test-db/ 30 | test-db64/ 31 | perf-test-db/ 32 | perf-test-db64/ 33 | 34 | ## Backups 35 | .gitignore~ 36 | *.txt~ 37 | default.json.bak 38 | 39 | # Java crash reports 40 | hs_err_pid*.log 41 | -------------------------------------------------------------------------------- /.gitlab/merge_request_templates/Default.md: -------------------------------------------------------------------------------- 1 | ## What does this merge request do? 2 | 3 | TODO Link associated issue from title, like: `
29 | * Example (to-one relation): one "Order" references one "Customer". 30 | * The backlink to this is a to-many in the reverse direction: one "Customer" has a number of "Order"s. 31 | *
32 | * Example (to-many relation): one "Teacher" references multiple "Student"s. 33 | * The backlink to this: one "Student" has a number of "Teacher"s. 34 | *
35 | * Note: changes made to a backlink relation based on a to-many relation are ignored. 36 | */ 37 | @Retention(RetentionPolicy.CLASS) 38 | @Target(ElementType.FIELD) 39 | @Beta 40 | public @interface Backlink { 41 | /** 42 | * Name of the relation the backlink should be based on (e.g. name of a ToOne or ToMany property in the target entity). 43 | * Can be left empty if there is just a single relation from the target to the source entity. 44 | */ 45 | String to() default ""; 46 | } 47 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/BaseEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Marks a class as an ObjectBox Entity super class. 26 | * ObjectBox will store properties of this class as part of an Entity that inherits from this class. 27 | * See the Entity Inheritance documentation for details. 28 | */ 29 | @Retention(RetentionPolicy.CLASS) 30 | @Target(ElementType.TYPE) 31 | public @interface BaseEntity { 32 | } 33 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/ConflictStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2021 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | /** 20 | * Used with {@link Unique} to specify the conflict resolution strategy. 21 | */ 22 | public enum ConflictStrategy { 23 | 24 | /** 25 | * Throws UniqueViolationException if any property violates a {@link Unique} constraint. 26 | */ 27 | FAIL, 28 | /** 29 | * Any conflicting objects are deleted before the object is inserted. 30 | */ 31 | REPLACE 32 | 33 | } 34 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/Convert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import io.objectbox.converter.PropertyConverter; 25 | 26 | /** 27 | * Supplies a {@link PropertyConverter converter} to store custom Property types as a supported {@link #dbType()}. 28 | * See the Custom Types documentation for details. 29 | */ 30 | @Retention(RetentionPolicy.CLASS) 31 | @Target(ElementType.FIELD) 32 | public @interface Convert { 33 | /** 34 | * The converter class that ObjectBox should use. See {@link PropertyConverter} for implementation guidelines. 35 | */ 36 | Class extends PropertyConverter> converter(); 37 | 38 | /** 39 | * The Property type the Java field value is converted to/from. 40 | * See the Custom Types documentation for a list 41 | * of supported types. 42 | */ 43 | Class dbType(); 44 | } 45 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/DatabaseType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | /** 20 | * Use with {@link Type @Type} to override how a property value is stored and interpreted in the database. 21 | */ 22 | public enum DatabaseType { 23 | 24 | /** 25 | * Use with 64-bit long properties to store them as high precision time 26 | * representing nanoseconds since 1970-01-01 (unix epoch). 27 | *
28 | * By default, a 64-bit long value is interpreted as time in milliseconds (a Date). 29 | */ 30 | DateNano 31 | 32 | } 33 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/DefaultValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Defines the Java code of the default value to use for a property, when getting an existing entity and the database 26 | * value for the property is null. 27 | *
28 | * Currently only {@code @DefaultValue("")} is supported. 29 | */ 30 | @Retention(RetentionPolicy.CLASS) 31 | @Target({ElementType.FIELD}) 32 | public @interface DefaultValue { 33 | String value(); 34 | } 35 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/ExternalType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Sets the type of a property or the type of object IDs of a ToMany in an external system (like another database). 27 | *
28 | * This is useful if there is no default mapping of the ObjectBox type to the type in the external system. 29 | *
30 | * Carefully look at the documentation of the external type to ensure it is compatible with the ObjectBox type. 31 | */ 32 | @Retention(RetentionPolicy.CLASS) 33 | @Target({ElementType.FIELD}) 34 | public @interface ExternalType { 35 | 36 | ExternalPropertyType value(); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/HnswFlags.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | /** 20 | * Flags as a part of the {@link HnswIndex} configuration. 21 | */ 22 | public @interface HnswFlags { 23 | 24 | /** 25 | * Enables debug logs. 26 | */ 27 | boolean debugLogs() default false; 28 | 29 | /** 30 | * Enables "high volume" debug logs, e.g. individual gets/puts. 31 | */ 32 | boolean debugLogsDetailed() default false; 33 | 34 | /** 35 | * Padding for SIMD is enabled by default, which uses more memory but may be faster. This flag turns it off. 36 | */ 37 | boolean vectorCacheSimdPaddingOff() default false; 38 | 39 | /** 40 | * If the speed of removing nodes becomes a concern in your use case, you can speed it up by setting this flag. By 41 | * default, repairing the graph after node removals creates more connections to improve the graph's quality. The 42 | * extra costs for this are relatively low (e.g. vs. regular indexing), and thus the default is recommended. 43 | */ 44 | boolean reparationLimitCandidates() default false; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/Id.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Marks the ID property of an {@link Entity @Entity}. 26 | * The property must be of type long (or Long in Kotlin) and have not-private visibility 27 | * (or a not-private getter and setter method). 28 | *
29 | * ID properties are unique and indexed by default. 30 | */ 31 | @Retention(RetentionPolicy.CLASS) 32 | @Target(ElementType.FIELD) 33 | public @interface Id { 34 | // /** 35 | // * Specifies that id should increase monotonic without reusing IDs. This decreases performance a little bit for 36 | // * putting new objects (inserts) because the state needs to be persisted. Gaps between two IDs may still occur, 37 | // * e.g. if inserts are rollbacked. 38 | // */ 39 | // boolean monotonic() default false; 40 | 41 | /** 42 | * Allows IDs of new entities to be assigned manually. 43 | * Warning: This has side effects, check the online documentation on self-assigned object IDs for details. 44 | *
45 | * This may allow re-use of IDs assigned elsewhere, e.g. by a server. 46 | */ 47 | boolean assignable() default false; 48 | } 49 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/IdCompanion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Marks a property as a companion to an @Id property. There can only be one companion property. 26 | *
27 | * By defining an @Id companion property, the entity type uses a special ID encoding scheme involving this property 28 | * in addition to the ID. 29 | *
30 | * For Time Series IDs, a companion property of type Date or DateNano represents the exact timestamp. 31 | */ 32 | @Retention(RetentionPolicy.CLASS) 33 | @Target(ElementType.FIELD) 34 | public @interface IdCompanion { 35 | } 36 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/Index.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2018 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Specifies that the property should be indexed. 26 | *
27 | * It is highly recommended to index properties that are used in a query to improve query performance. 28 | * When building a query, make sure to use case sensitive String conditions to utilize the index. 29 | *
30 | * To fine tune indexing of a property you can override the default index {@link #type()}. 31 | *
32 | * Note: indexes are currently not supported for string array, byte array, float or double properties. 33 | */ 34 | @Retention(RetentionPolicy.CLASS) 35 | @Target(ElementType.FIELD) 36 | public @interface Index { 37 | /** 38 | * Sets the {@link IndexType}, defaults to {@link IndexType#DEFAULT}. 39 | */ 40 | IndexType type() default IndexType.DEFAULT; 41 | } 42 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/IndexType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | /** 20 | * ObjectBox offers a value and two hash index types, from which it chooses a reasonable default (see {@link #DEFAULT}). 21 | *
22 | * For some queries/use cases it might make sense to override the default choice for optimization purposes. 23 | *
24 | * Note: hash indexes are currently only supported for string properties. 25 | */ 26 | public enum IndexType { 27 | /** 28 | * Use the default index type depending on the property type: 29 | * {@link #VALUE} for scalars and {@link #HASH} for Strings. 30 | */ 31 | DEFAULT, 32 | 33 | /** 34 | * Use the property value to build the index. 35 | * For Strings this may occupy more space than the default setting. 36 | */ 37 | VALUE, 38 | 39 | /** 40 | * Use a (fast non-cryptographic) hash of the property value to build the index. 41 | * Internally, it uses a 32 bit hash with a decent hash collision behavior. 42 | * Because occasional collisions do not really impact performance, this is usually a better choice than 43 | * {@link #HASH64} as it takes less space. 44 | */ 45 | HASH, 46 | 47 | /** 48 | * Use a long (fast non-cryptographic) hash of the property value to build the index. 49 | */ 50 | HASH64 51 | } 52 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/NameInDb.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Allows to specify a simple name mapping for entities and properties. 26 | * If names have diverged on the Java side (vs. the DB), you can specify the name used in the database here. 27 | * This allows simple renames in Java. For more advanced renames you should consider @{@link Uid} instead. 28 | */ 29 | @Retention(RetentionPolicy.CLASS) 30 | @Target({ElementType.FIELD, ElementType.TYPE}) 31 | public @interface NameInDb { 32 | /** 33 | * Name used in the database. 34 | */ 35 | String value(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/NotNull.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Specifies that property is not null 26 | *
27 | * You can also use any another NotNull or NonNull annotation (from any library or your own), 28 | * they are equal to using this 29 | *
30 | */ 31 | @Retention(RetentionPolicy.CLASS) 32 | @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) 33 | /* TODO public */ @interface NotNull { 34 | } 35 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/OrderBy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Specifies ordering of related collection of {@link Relation} relation 26 | * E.g.: @OrderBy("name, age DESC") List collection; 27 | * If used as marker (@OrderBy List collection), then collection is ordered by primary key 28 | */ 29 | @Retention(RetentionPolicy.CLASS) 30 | @Target(ElementType.FIELD) 31 | /* TODO public */ @interface OrderBy { 32 | /** 33 | * Comma-separated list of properties, e.g. "propertyA, propertyB, propertyC" 34 | * To specify direction, add ASC or DESC after property name, e.g.: "propertyA DESC, propertyB ASC" 35 | * Default direction for each property is ASC 36 | * If value is omitted, then collection is ordered by primary key 37 | */ 38 | String value() default ""; 39 | } 40 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/TargetIdProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Defines the property serving as the target ID of a ToOne. 26 | * This allows exposing an explicit property, which may be convenient for other parsers/serializers (e.g. JSON). 27 | */ 28 | @Retention(RetentionPolicy.CLASS) 29 | @Target({ElementType.FIELD, ElementType.TYPE}) 30 | public @interface TargetIdProperty { 31 | /** 32 | * Name used in the database. 33 | */ 34 | String value(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/Transient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.Target; 22 | 23 | 24 | import static java.lang.annotation.RetentionPolicy.CLASS; 25 | 26 | /** 27 | * Transient fields are not persisted in the database. 28 | */ 29 | @Retention(CLASS) 30 | @Target(ElementType.FIELD) 31 | public @interface Transient { 32 | } 33 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Use on a property to override how its value is stored and interpreted in the database. 26 | *27 | * For example to change a long to be interpreted as nanoseconds instead of milliseconds: 28 | *
29 | * @Type(DatabaseType.DateNano) 30 | * public long timeInNanos; 31 | *32 | */ 33 | @Retention(RetentionPolicy.CLASS) 34 | @Target({ElementType.FIELD}) 35 | public @interface Type { 36 | 37 | DatabaseType value(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/Uid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | 25 | /** 26 | * UIDs identify entities (and properties) uniquely in the meta object model file (objectbox-model/default.json). 27 | * With UIDs you can map entities to their meta model representation in a stable way without its name. 28 | * Once a UID is set, you can rename the entity as often as you like - ObjectBox keeps track of it automatically. 29 | * Thus, it is advisable to lookup the UID in objectbox-model/default.json and use it here before renaming a entity. 30 | */ 31 | @Retention(RetentionPolicy.CLASS) 32 | @Target({ElementType.FIELD, ElementType.TYPE}) 33 | public @interface Uid { 34 | /** 35 | * The UID associated with an entity/property. 36 | *
37 | * Special values: 38 | *
27 | * Trying to put an object with offending values will result in a UniqueViolationException (see {@link ConflictStrategy#FAIL}). 28 | * Set {@link #onConflict()} to change this strategy. 29 | *
30 | * Note: Unique properties are based on an {@link Index @Index}, so the same restrictions apply. 31 | * It is supported to explicitly add the {@link Index @Index} annotation to configure the index. 32 | */ 33 | @Retention(RetentionPolicy.CLASS) 34 | @Target(ElementType.FIELD) 35 | public @interface Unique { 36 | 37 | /** 38 | * The strategy to use when a conflict is detected when an object is put. 39 | */ 40 | ConflictStrategy onConflict() default ConflictStrategy.FAIL; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/Unsigned.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Indicates that values of an integer property (e.g. int and long in Java) 26 | * should be treated as unsigned when doing queries or creating indexes. 27 | *
28 | * For example consider a set of integers sorted by the default order: [-2, -1, 0, 1, 2]. 29 | * If all values are treated as unsigned, the order would be [0, 1, 2, -2, -1] instead. 30 | */ 31 | @Retention(RetentionPolicy.CLASS) 32 | @Target(ElementType.FIELD) 33 | public @interface Unsigned { 34 | } 35 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/apihint/Beta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation.apihint; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * APIs annotated with @Beta may change and may be even removed in a future release (but is somewhat less likely 27 | * compared to {@link Experimental}). You can still use this API - just be aware that a future version may require 28 | * changes of your code. This is intended for getting feedback on planned features. 29 | */ 30 | @Retention(RetentionPolicy.CLASS) 31 | @Target({ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) 32 | @Documented 33 | public @interface Beta { 34 | } 35 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/apihint/Experimental.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation.apihint; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * APIs annotated with @Experimental are likely to change and may be even removed in a future release. 27 | * You can use this API - just be aware that a future version may require changes of your code. 28 | * This is intended for getting feedback on planned features. 29 | */ 30 | @Retention(RetentionPolicy.CLASS) 31 | @Target({ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) 32 | @Documented 33 | public @interface Experimental { 34 | } 35 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/apihint/Internal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.annotation.apihint; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * APIs annotated with @Internal must NOT be used. 27 | * Internal APIs must only be used by ObjectBox and may change or be removed in a future release. 28 | */ 29 | @Retention(RetentionPolicy.CLASS) 30 | @Target({ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) 31 | @Internal 32 | @Documented 33 | public @interface Internal { 34 | } 35 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/apihint/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Annotations to mark APIs as for example {@link io.objectbox.annotation.apihint.Internal @Internal} 19 | * or {@link io.objectbox.annotation.apihint.Experimental @Experimental}. 20 | */ 21 | package io.objectbox.annotation.apihint; -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/annotation/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Annotations to mark a class as an {@link io.objectbox.annotation.Entity @Entity}, 19 | * to specify the {@link io.objectbox.annotation.Id @Id} Property, 20 | * to create an {@link io.objectbox.annotation.Index @Index} or 21 | * a {@link io.objectbox.annotation.Transient @Transient} Property. 22 | *
23 | * For more details look at the documentation of individual classes and 24 | * docs.objectbox.io/entity-annotations. 25 | */ 26 | package io.objectbox.annotation; -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/converter/PropertyConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.objectbox.converter; 18 | 19 | /** 20 | * To use custom types in your entity, implement this to convert db values to entity values and back. 21 | *
22 | * Notes for implementations: 23 | *
{ 31 | P convertToEntityProperty(D databaseValue); 32 | 33 | D convertToDatabaseValue(P entityProperty); 34 | } 35 | -------------------------------------------------------------------------------- /objectbox-java-api/src/main/java/io/objectbox/converter/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 ObjectBox Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * For use with {@link io.objectbox.annotation.Convert @Convert}: {@link io.objectbox.converter.PropertyConverter} 19 | * to convert custom Property types. 20 | *
21 | * For more details look at the documentation of individual classes and
22 | * docs.objectbox.io/advanced/custom-types.
23 | */
24 | package io.objectbox.converter;
--------------------------------------------------------------------------------
/objectbox-java/spotbugs-exclude.xml:
--------------------------------------------------------------------------------
1 |
2 |
22 | * Used by default to convert {@code Map
24 | * Used by default to convert {@code Map
22 | * Used by default to convert {@code Map
24 | * Used by default to convert {@code Map
22 | * Used by default to convert {@code Map
24 | * Used by default to convert {@code Map
24 | * If your code uses manually assigned
25 | * IDs make sure it takes care of some things that ObjectBox would normally do by itself. This includes
26 | * {@link io.objectbox.Box#attach(Object) attaching} the Box to an object before modifying a ToMany.
27 | *
28 | * Also see the documentation about Updating
29 | * Relations and manually assigned
30 | * IDs for details.
31 | */
32 | public class DbDetachedException extends DbException {
33 |
34 | public DbDetachedException() {
35 | this("Entity must be attached to a Box.");
36 | }
37 |
38 | public DbDetachedException(String message) {
39 | super(message);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/DbException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.exception;
18 |
19 | /**
20 | * General exception for things that may go wrong with the database.
21 | * Also base class for more concrete exceptions.
22 | */
23 | public class DbException extends RuntimeException {
24 | private final int errorCode;
25 |
26 | public DbException(String message) {
27 | super(message);
28 | errorCode = 0;
29 | }
30 |
31 | public DbException(String message, Throwable cause) {
32 | super(message, cause);
33 | errorCode = 0;
34 | }
35 |
36 | public DbException(String message, int errorCode) {
37 | super(message);
38 | this.errorCode = errorCode;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return errorCode == 0 ? super.toString() :
44 | super.toString() + " (error code " + errorCode + ")";
45 | }
46 |
47 | /** 0 == no error code available */
48 | public int getErrorCode() {
49 | return errorCode;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/DbFullException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2024 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.exception;
18 |
19 | /**
20 | * Thrown when applying a database operation would exceed the (default)
21 | * {@link io.objectbox.BoxStoreBuilder#maxSizeInKByte(long) maxSizeInKByte} configured for the Store.
22 | *
23 | * This can occur for operations like when an Object is {@link io.objectbox.Box#put(Object) put}, at the point when the
24 | * (internal) transaction is committed. Or when the Store is opened with a max size too small for the existing database.
25 | */
26 | public class DbFullException extends DbException {
27 | public DbFullException(String message) {
28 | super(message);
29 | }
30 |
31 | public DbFullException(String message, int errorCode) {
32 | super(message, errorCode);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/DbMaxDataSizeExceededException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.exception;
18 |
19 | /**
20 | * Thrown when applying a transaction would exceed the {@link io.objectbox.BoxStoreBuilder#maxDataSizeInKByte(long) maxDataSizeInKByte}
21 | * configured for the store.
22 | */
23 | public class DbMaxDataSizeExceededException extends DbException {
24 | public DbMaxDataSizeExceededException(String message) {
25 | super(message);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/DbMaxReadersExceededException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.exception;
18 |
19 | import io.objectbox.BoxStore;
20 | import io.objectbox.BoxStoreBuilder;
21 |
22 | /**
23 | * Thrown when the maximum of readers (read transactions) was exceeded.
24 | * Verify that your code only uses a reasonable amount of threads.
25 | *
26 | * If a very high number of threads (>100) needs to be used, consider increasing the number of maximum readers
27 | * using {@link BoxStoreBuilder#maxReaders(int)} and enabling query retries using
28 | * {@link BoxStoreBuilder#queryAttempts(int)}.
29 | *
30 | * For debugging issues related to this exception, check {@link BoxStore#diagnose()}.
31 | */
32 | public class DbMaxReadersExceededException extends DbException {
33 | public DbMaxReadersExceededException(String message) {
34 | super(message);
35 | }
36 |
37 | public DbMaxReadersExceededException(String message, int errorCode) {
38 | super(message, errorCode);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/DbSchemaException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.exception;
18 |
19 | /**
20 | * Thrown when there is an error with the data schema (data model).
21 | *
22 | * Typically, there is a conflict between the data model defined in your code (using {@link io.objectbox.annotation.Entity @Entity}
23 | * classes) and the data model of the existing database file.
24 | *
25 | * Read the meta model docs
26 | * on why this can happen and how to resolve such conflicts.
27 | */
28 | public class DbSchemaException extends DbException {
29 | public DbSchemaException(String message) {
30 | super(message);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/DbShutdownException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.exception;
18 |
19 | /**
20 | * Thrown when an error occurred that requires the store to be closed.
21 | *
22 | * This may be an I/O error. Regular operations won't be possible.
23 | * To handle this exit the app or try to reopen the store.
24 | */
25 | public class DbShutdownException extends DbException {
26 | public DbShutdownException(String message) {
27 | super(message);
28 | }
29 |
30 | public DbShutdownException(String message, int errorCode) {
31 | super(message, errorCode);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/FeatureNotAvailableException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.exception;
18 |
19 | /**
20 | * Thrown when a special feature was used, which is not part of the native library.
21 | *
22 | * This typically indicates a developer error. Check that the correct dependencies for the native ObjectBox library are
23 | * included.
24 | */
25 | public class FeatureNotAvailableException extends DbException {
26 |
27 | // Note: this constructor is called by JNI, check before modifying/removing it.
28 | public FeatureNotAvailableException(String message) {
29 | super(message);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/FileCorruptException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.objectbox.exception;
17 |
18 | import io.objectbox.BoxStoreBuilder;
19 |
20 | /**
21 | * Errors were detected in a database file, e.g. illegal values or structural inconsistencies.
22 | *
23 | * It may be possible to re-open the store with {@link BoxStoreBuilder#usePreviousCommit()} to restore
24 | * to a working state.
25 | */
26 | public class FileCorruptException extends DbException {
27 | public FileCorruptException(String message) {
28 | super(message);
29 | }
30 |
31 | public FileCorruptException(String message, int errorCode) {
32 | super(message, errorCode);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/NonUniqueResultException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.exception;
18 |
19 | /**
20 | * Thrown if {@link io.objectbox.query.Query#findUnique() Query.findUnique()} or
21 | * {@link io.objectbox.query.Query#findUniqueId() Query.findUniqueId()} is called,
22 | * but the query matches more than one object.
23 | */
24 | public class NonUniqueResultException extends DbException {
25 | public NonUniqueResultException(String message) {
26 | super(message);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/NumericOverflowException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.exception;
18 |
19 | /**
20 | * Thrown if a property query aggregate function can not compute a result due to a number type overflowing.
21 | */
22 | public class NumericOverflowException extends DbException {
23 |
24 | public NumericOverflowException(String message) {
25 | super(message);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/PagesCorruptException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.objectbox.exception;
17 |
18 | /**
19 | * Errors related to pages were detected in a database file, e.g. bad page refs outside of the file.
20 | */
21 | public class PagesCorruptException extends FileCorruptException {
22 | public PagesCorruptException(String message) {
23 | super(message);
24 | }
25 |
26 | public PagesCorruptException(String message, int errorCode) {
27 | super(message, errorCode);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/UniqueViolationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2018 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.exception;
18 |
19 | /** Thrown when a @{@link io.objectbox.annotation.Unique} constraint would be violated during a put operation. */
20 | public class UniqueViolationException extends ConstraintViolationException {
21 | public UniqueViolationException(String message) {
22 | super(message);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | * Various exceptions thrown by ObjectBox.
19 | */
20 | package io.objectbox.exception;
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/flatbuffers/BooleanVector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.flatbuffers;
18 |
19 | import static io.objectbox.flatbuffers.Constants.*;
20 | import java.nio.ByteBuffer;
21 | import java.nio.ByteOrder;
22 | import java.nio.charset.Charset;
23 |
24 | /**
25 | * Helper type for accessing vector of booleans.
26 | */
27 | public final class BooleanVector extends BaseVector {
28 | /**
29 | * Assigns vector access object to vector data.
30 | *
31 | * @param _vector Start data of a vector.
32 | * @param _bb Table's ByteBuffer.
33 | * @return Returns current vector access object assigned to vector data whose offset is stored at
34 | * `vector`.
35 | */
36 | public BooleanVector __assign(int _vector, ByteBuffer _bb) {
37 | __reset(_vector, Constants.SIZEOF_BYTE, _bb); return this;
38 | }
39 |
40 | /**
41 | * Reads the boolean at the given index.
42 | *
43 | * @param j The index from which the boolean will be read.
44 | * @return the boolean value at the given index.
45 | */
46 | public boolean get(int j) {
47 | return 0 != bb.get(__element(j));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/flatbuffers/ByteBufferUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.flatbuffers;
18 |
19 | import static io.objectbox.flatbuffers.Constants.*;
20 |
21 | import java.nio.ByteBuffer;
22 |
23 | /// @file
24 | /// @addtogroup flatbuffers_java_api
25 | /// @{
26 |
27 | /**
28 | * Class that collects utility functions around `ByteBuffer`.
29 | */
30 | public class ByteBufferUtil {
31 |
32 | /**
33 | * Extract the size prefix from a `ByteBuffer`.
34 | *
35 | * @param bb a size-prefixed buffer
36 | * @return the size prefix
37 | */
38 | public static int getSizePrefix(ByteBuffer bb) {
39 | return bb.getInt(bb.position());
40 | }
41 |
42 | /**
43 | * Create a duplicate of a size-prefixed `ByteBuffer` that has its position
44 | * advanced just past the size prefix.
45 | *
46 | * @param bb a size-prefixed buffer
47 | * @return a new buffer on the same underlying data that has skipped the
48 | * size prefix
49 | */
50 | public static ByteBuffer removeSizePrefix(ByteBuffer bb) {
51 | ByteBuffer s = bb.duplicate();
52 | s.position(s.position() + SIZE_PREFIX_LENGTH);
53 | return s;
54 | }
55 |
56 | }
57 |
58 | /// @}
59 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/flatbuffers/DoubleVector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.flatbuffers;
18 |
19 | import static io.objectbox.flatbuffers.Constants.*;
20 | import java.nio.ByteBuffer;
21 | import java.nio.ByteOrder;
22 | import java.nio.charset.Charset;
23 |
24 | /**
25 | * Helper type for accessing vector of double values.
26 | */
27 | public final class DoubleVector extends BaseVector {
28 | /**
29 | * Assigns vector access object to vector data.
30 | *
31 | * @param _vector Start data of a vector.
32 | * @param _bb Table's ByteBuffer.
33 | * @return Returns current vector access object assigned to vector data whose offset is stored at
34 | * `vector`.
35 | */
36 | public DoubleVector __assign(int _vector, ByteBuffer _bb) {
37 | __reset(_vector, Constants.SIZEOF_DOUBLE, _bb); return this;
38 | }
39 |
40 | /**
41 | * Reads the double value at the given index.
42 | *
43 | * @param j The index from which the double value will be read.
44 | * @return the double value at the given index.
45 | */
46 | public double get(int j) {
47 | return bb.getDouble(__element(j));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/flatbuffers/FloatVector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.flatbuffers;
18 |
19 | import static io.objectbox.flatbuffers.Constants.*;
20 | import java.nio.ByteBuffer;
21 | import java.nio.ByteOrder;
22 | import java.nio.charset.Charset;
23 |
24 | /**
25 | * Helper type for accessing vector of float values.
26 | */
27 | public final class FloatVector extends BaseVector {
28 | /**
29 | * Assigns vector access object to vector data.
30 | *
31 | * @param _vector Start data of a vector.
32 | * @param _bb Table's ByteBuffer.
33 | * @return Returns current vector access object assigned to vector data whose offset is stored at
34 | * `vector`.
35 | */
36 | public FloatVector __assign(int _vector, ByteBuffer _bb) {
37 | __reset(_vector, Constants.SIZEOF_FLOAT, _bb); return this;
38 | }
39 |
40 | /**
41 | * Reads the float value at the given index.
42 | *
43 | * @param j The index from which the float value will be read.
44 | * @return the float value at the given index.
45 | */
46 | public float get(int j) {
47 | return bb.getFloat(__element(j));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/flatbuffers/LongVector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.flatbuffers;
18 |
19 | import static io.objectbox.flatbuffers.Constants.*;
20 | import java.nio.ByteBuffer;
21 | import java.nio.ByteOrder;
22 | import java.nio.charset.Charset;
23 |
24 | /**
25 | * Helper type for accessing vector of long values.
26 | */
27 | public final class LongVector extends BaseVector {
28 | /**
29 | * Assigns vector access object to vector data.
30 | *
31 | * @param _vector Start data of a vector.
32 | * @param _bb Table's ByteBuffer.
33 | * @return Returns current vector access object assigned to vector data whose offset is stored at
34 | * `vector`.
35 | */
36 | public LongVector __assign(int _vector, ByteBuffer _bb) {
37 | __reset(_vector, Constants.SIZEOF_LONG, _bb); return this;
38 | }
39 |
40 | /**
41 | * Reads the long value at the given index.
42 | *
43 | * @param j The index from which the long value will be read.
44 | * @return the signed 64-bit value at the given index.
45 | */
46 | public long get(int j) {
47 | return bb.getLong(__element(j));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/flatbuffers/README.md:
--------------------------------------------------------------------------------
1 | # FlatBuffers
2 |
3 | This is a copy of the [FlatBuffers](https://github.com/google/flatbuffers) for Java source code in a custom package
4 | to avoid conflicts with FlatBuffers generated Java code from users of this library.
5 |
6 | Current version: `23.5.26` (Note: version in `Constants.java` may be lower).
7 |
8 | Copy a different version using the script in `scripts\update-flatbuffers.sh`.
9 | It expects FlatBuffers source files in the `../flatbuffers` directory (e.g. check out
10 | the desired FlatBuffers tag from https://github.com/objectbox/flatbuffers next to this repo).
11 | The Java library is expected in `objectbox-java`, e.g. run the script from the root of this repo.
12 |
13 | ## Licensing
14 |
15 | Flatbuffers is licensed under the Apache License, Version 2.0.
16 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/flatbuffers/StringVector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.flatbuffers;
18 |
19 | import static io.objectbox.flatbuffers.Constants.*;
20 | import java.nio.ByteBuffer;
21 | import java.nio.ByteOrder;
22 | import java.nio.charset.Charset;
23 |
24 | /**
25 | * Helper type for accessing vector of String.
26 | */
27 | public final class StringVector extends BaseVector {
28 | private Utf8 utf8 = Utf8.getDefault();
29 |
30 | /**
31 | * Assigns vector access object to vector data.
32 | *
33 | * @param _vector Start data of a vector.
34 | * @param _element_size Size of a vector element.
35 | * @param _bb Table's ByteBuffer.
36 | * @return Returns current vector access object assigned to vector data whose offset is stored at
37 | * `vector`.
38 | */
39 | public StringVector __assign(int _vector, int _element_size, ByteBuffer _bb) {
40 | __reset(_vector, _element_size, _bb); return this;
41 | }
42 |
43 | /**
44 | * Reads the String at the given index.
45 | *
46 | * @param j The index from which the String value will be read.
47 | * @return the String at the given index.
48 | */
49 | public String get(int j) {
50 | return Table.__string(__element(j), bb, utf8);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/flatbuffers/UnionVector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.flatbuffers;
18 |
19 | import static io.objectbox.flatbuffers.Constants.*;
20 | import java.nio.ByteBuffer;
21 | import java.nio.ByteOrder;
22 | import java.nio.charset.Charset;
23 |
24 | /**
25 | * Helper type for accessing vector of unions.
26 | */
27 | public final class UnionVector extends BaseVector {
28 | /**
29 | * Assigns vector access object to vector data.
30 | *
31 | * @param _vector Start data of a vector.
32 | * @param _element_size Size of a vector element.
33 | * @param _bb Table's ByteBuffer.
34 | * @return Returns current vector access object assigned to vector data whose offset is stored at
35 | * `vector`.
36 | */
37 | public UnionVector __assign(int _vector, int _element_size, ByteBuffer _bb) {
38 | __reset(_vector, _element_size, _bb); return this;
39 | }
40 |
41 |
42 | /**
43 | * Initialize any Table-derived type to point to the union at the given `index`.
44 | *
45 | * @param obj A `Table`-derived type that should point to the union at `index`.
46 | * @param j An `int` index into the union vector.
47 | * @return Returns the Table that points to the union at `index`.
48 | */
49 | public Table get(Table obj, int j) {
50 | return Table.__union(obj, __element(j), bb);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/ideasonly/ModelUpdate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.ideasonly;
18 |
19 | public interface ModelUpdate {
20 | void updateModel(ModelModifier modifier, long oldVersion, long newVersion);
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/internal/CallWithHandle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.internal;
18 |
19 | import io.objectbox.annotation.apihint.Internal;
20 |
21 | @Internal
22 | public interface CallWithHandle
20 | * The following core classes are the essential interface to ObjectBox:
21 | *
28 | * For more details look at the documentation of individual classes and
29 | * docs.objectbox.io.
30 | */
31 | @ParametersAreNonnullByDefault
32 | package io.objectbox;
33 |
34 | import javax.annotation.ParametersAreNonnullByDefault;
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/query/BreakForEach.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.query;
18 |
19 | /**
20 | * You can throw this inside a {@link QueryConsumer} to signal {@link Query#forEach(QueryConsumer)} should "break".
21 | * This will stop consuming any further data.
22 | */
23 | public class BreakForEach extends RuntimeException {
24 | }
25 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/query/EagerRelation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.query;
18 |
19 | import io.objectbox.relation.RelationInfo;
20 |
21 | class EagerRelation
43 | * The query score indicates some quality measurement. E.g. for vector nearest neighbor searches, the score is the
44 | * distance to the given vector.
45 | */
46 | public double getScore() {
47 | return score;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/query/InternalAccess.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.query;
18 |
19 | import io.objectbox.annotation.apihint.Internal;
20 |
21 | /**
22 | * Exposes internal APIs to tests and code in other packages.
23 | */
24 | @Internal
25 | public class InternalAccess {
26 |
27 | @Internal
28 | public static
44 | * The query score indicates some quality measurement. E.g. for vector nearest neighbor searches, the score is the
45 | * distance to the given vector.
46 | */
47 | public double getScore() {
48 | return score;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/query/OrderFlags.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // automatically generated by the FlatBuffers compiler, do not modify
18 |
19 | package io.objectbox.query;
20 |
21 | /**
22 | * Not really an enum, but binary flags to use across languages
23 | */
24 | @SuppressWarnings("unused")
25 | public final class OrderFlags {
26 | private OrderFlags() { }
27 | /**
28 | * Reverts the order from ascending (default) to descending.
29 | */
30 | public static final int DESCENDING = 1;
31 | /**
32 | * Makes upper case letters (e.g. "Z") be sorted before lower case letters (e.g. "a").
33 | * If not specified, the default is case insensitive for ASCII characters.
34 | */
35 | public static final int CASE_SENSITIVE = 2;
36 | /**
37 | * For scalars only: changes the comparison to unsigned (default is signed).
38 | */
39 | public static final int UNSIGNED = 4;
40 | /**
41 | * null values will be put last.
42 | * If not specified, by default null values will be put first.
43 | */
44 | public static final int NULLS_LAST = 8;
45 | /**
46 | * null values should be treated equal to zero (scalars only).
47 | */
48 | public static final int NULLS_ZERO = 16;
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/query/PropertyQueryCondition.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.query;
18 |
19 | import io.objectbox.Property;
20 |
21 | /**
22 | * A condition on a {@link Property}, which can have an alias to allow referring to it later.
23 | */
24 | public interface PropertyQueryCondition
21 | * For more details look at the documentation of individual classes and
22 | * docs.objectbox.io/queries.
23 | */
24 | @ParametersAreNonnullByDefault
25 | package io.objectbox.query;
26 |
27 | import javax.annotation.ParametersAreNonnullByDefault;
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/reactive/DataObserver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.reactive;
18 |
19 | /**
20 | * Observer that can be subscribed to publishers (e.g. @{@link io.objectbox.BoxStore} and
21 | * {@link io.objectbox.query.Query}).
22 | *
23 | * @param
30 | * Exception note: if this method throws an exception, it can be reacted on via
31 | * {@link SubscriptionBuilder#onError(ErrorObserver)}.
32 | */
33 | void onData(T data);
34 | }
35 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/reactive/DataPublisher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.reactive;
18 |
19 | import javax.annotation.Nullable;
20 |
21 | import io.objectbox.annotation.apihint.Internal;
22 |
23 | @Internal
24 | public interface DataPublisher
23 | * Note that a transformer is not required to actually "transform" any data.
24 | * Technically, it's fine to return the same data it received and just do some processing with it.
25 | *
26 | * Threading notes: transformations are executed sequentially on a background thread
27 | * owned by the subscription publisher. It is OK to perform long lasting operations,
28 | * however this will block notifications to all other observers until finished.
29 | *
30 | * @param
21 | * For more details look at the documentation of individual classes and
22 | * docs.objectbox.io/data-observers-and-rx.
23 | */
24 | @ParametersAreNonnullByDefault
25 | package io.objectbox.reactive;
26 |
27 | import javax.annotation.ParametersAreNonnullByDefault;
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/relation/ListFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.relation;
18 |
19 | import java.io.Serializable;
20 | import java.util.ArrayList;
21 | import java.util.List;
22 | import java.util.concurrent.CopyOnWriteArrayList;
23 |
24 | import io.objectbox.annotation.apihint.Experimental;
25 |
26 | @Experimental
27 | public interface ListFactory extends Serializable {
28 |
21 | * For more details look at the documentation of individual classes and
22 | * docs.objectbox.io/relations.
23 | */
24 | @ParametersAreNonnullByDefault
25 | package io.objectbox.relation;
26 |
27 | import javax.annotation.ParametersAreNonnullByDefault;
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/ObjectsMessageBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.sync;
18 |
19 | /**
20 | * @see SyncClient#startObjectsMessage
21 | */
22 | public interface ObjectsMessageBuilder {
23 |
24 | ObjectsMessageBuilder addString(long optionalId, String value);
25 |
26 | ObjectsMessageBuilder addBytes(long optionalId, byte[] value, boolean isFlatBuffers);
27 |
28 | /**
29 | * Sends the message, returns true if successful.
30 | */
31 | boolean send();
32 | }
33 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/SyncCredentialsUserPassword.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.sync;
18 |
19 | import io.objectbox.annotation.apihint.Internal;
20 |
21 | /**
22 | * Internal credentials implementation for user and password authentication.
23 | * Use {@link SyncCredentials} to build credentials.
24 | */
25 | @Internal
26 | public final class SyncCredentialsUserPassword extends SyncCredentials {
27 |
28 | private final String username;
29 | private final String password;
30 |
31 | SyncCredentialsUserPassword(CredentialsType type, String username, String password) {
32 | super(type);
33 | this.username = username;
34 | this.password = password;
35 | }
36 |
37 | public String getUsername() {
38 | return username;
39 | }
40 |
41 | public String getPassword() {
42 | return password;
43 | }
44 |
45 | @Override
46 | SyncCredentials createClone() {
47 | return new SyncCredentialsUserPassword(getType(), this.username, this.password);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/SyncFlags.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // automatically generated by the FlatBuffers compiler, do not modify
18 |
19 | package io.objectbox.sync;
20 |
21 | /**
22 | * Flags to adjust sync behavior like additional logging.
23 | */
24 | @SuppressWarnings("unused")
25 | public final class SyncFlags {
26 | private SyncFlags() { }
27 | /**
28 | * Enable (rather extensive) logging on how IDs are mapped (local <-> global)
29 | */
30 | public static final int DebugLogIdMapping = 1;
31 | /**
32 | * If the client gets in a state that does not allow any further synchronization, this flag instructs Sync to
33 | * keep local data nevertheless. While this preserves data, you need to resolve the situation manually.
34 | * For example, you could backup the data and start with a fresh database.
35 | * Note that the default behavior (this flag is not set) is to wipe existing data from all sync-enabled types and
36 | * sync from scratch from the server.
37 | * Client-only: setting this flag for Sync server has no effect.
38 | */
39 | public static final int ClientKeepDataOnSyncError = 2;
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/SyncLoginCodes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2020 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.sync;
18 |
19 | import io.objectbox.annotation.apihint.Experimental;
20 | import io.objectbox.sync.listener.SyncListener;
21 |
22 | /**
23 | * Codes used by {@link SyncListener#onLoginFailed(long)}.
24 | */
25 | @Experimental
26 | public class SyncLoginCodes {
27 |
28 | public static final long OK = 20;
29 | public static final long REQ_REJECTED = 40;
30 | public static final long CREDENTIALS_REJECTED = 43;
31 | public static final long UNKNOWN = 50;
32 | public static final long AUTH_UNREACHABLE = 53;
33 | public static final long BAD_VERSION = 55;
34 | public static final long CLIENT_ID_TAKEN = 61;
35 | public static final long TX_VIOLATED_UNIQUE = 71;
36 |
37 | private SyncLoginCodes() {
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/SyncState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2020 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.sync;
18 |
19 | /**
20 | * Returned by {@link io.objectbox.sync.SyncClientImpl#getSyncState()}.
21 | */
22 | public enum SyncState {
23 |
24 | UNKNOWN(0),
25 | CREATED(1),
26 | STARTED(2),
27 | CONNECTED(3),
28 | LOGGED_IN(4),
29 | DISCONNECTED(5),
30 | STOPPED(6),
31 | DEAD(7);
32 |
33 | public final int id;
34 |
35 | SyncState(int id) {
36 | this.id = id;
37 | }
38 |
39 | public static SyncState fromId(int id) {
40 | for (SyncState value : values()) {
41 | if (value.id == id) return value;
42 | }
43 | return UNKNOWN;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/listener/AbstractSyncListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.sync.listener;
18 |
19 | import io.objectbox.annotation.apihint.Experimental;
20 | import io.objectbox.sync.SyncChange;
21 |
22 | /**
23 | * A {@link SyncListener} with empty implementations of all interface methods.
24 | * This is helpful if you only want to override some methods.
25 | */
26 | @Experimental
27 | public abstract class AbstractSyncListener implements SyncListener {
28 |
29 | @Override
30 | public void onLoggedIn() {
31 | }
32 |
33 | @Override
34 | public void onLoginFailed(long syncLoginCode) {
35 | }
36 |
37 | @Override
38 | public void onUpdatesCompleted() {
39 | }
40 |
41 | @Override
42 | public void onSyncChanges(SyncChange[] syncChanges) {
43 | }
44 |
45 | @Override
46 | public void onServerTimeUpdate(long serverTimeNanos) {
47 | }
48 |
49 | @Override
50 | public void onDisconnected() {
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/listener/SyncChangeListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2020 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.sync.listener;
18 |
19 | import io.objectbox.annotation.apihint.Experimental;
20 | import io.objectbox.sync.SyncChange;
21 |
22 | /**
23 | * Notifies of fine granular changes on the object level happening during sync.
24 | * Register your listener using {@link io.objectbox.sync.SyncBuilder#changeListener(SyncChangeListener) SyncBuilder.changesListener(SyncChangesListener)}.
25 | * Note that enabling fine granular notification can slightly reduce performance.
26 | *
27 | * See also {@link SyncListener} for the general sync listener.
28 | */
29 | @SuppressWarnings({"unused"})
30 | @Experimental
31 | public interface SyncChangeListener {
32 |
33 | // Note: this method is expected by JNI, check before modifying/removing it.
34 |
35 | /**
36 | * Called each time when data from sync was applied locally.
37 | *
38 | * @param syncChanges This contains the entity type (schema) ID, the removed IDs and the put IDs for that entity.
39 | */
40 | void onSyncChanges(SyncChange[] syncChanges);
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/listener/SyncCompletedListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.sync.listener;
18 |
19 | /**
20 | * Listens to sync completed events.
21 | */
22 | public interface SyncCompletedListener {
23 |
24 | /**
25 | * Called each time a sync was "completed", in the sense that the client caught up with the current server state.
26 | * The client is "up-to-date".
27 | */
28 | void onUpdatesCompleted();
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/listener/SyncConnectionListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.sync.listener;
18 |
19 | /**
20 | * Listens to sync connection events.
21 | */
22 | public interface SyncConnectionListener {
23 |
24 | /**
25 | * Called when the client is disconnected from the sync server, e.g. due to a network error.
26 | *
27 | * Depending on the configuration, the sync client typically tries to reconnect automatically,
28 | * triggering a {@link SyncLoginListener} again.
29 | */
30 | void onDisconnected();
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/listener/SyncListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.sync.listener;
18 |
19 | import io.objectbox.annotation.apihint.Experimental;
20 | import io.objectbox.sync.SyncBuilder;
21 | import io.objectbox.sync.SyncClient;
22 |
23 | /**
24 | * This listener has callback methods invoked by all fundamental synchronization events.
25 | * Set via {@link SyncBuilder#listener(SyncListener)} or {@link SyncClient#setSyncListener(SyncListener)}.
26 | *
27 | * See {@link AbstractSyncListener} for a no-op convenience implementation.
28 | *
29 | * Use more specific listeners, like {@link SyncLoginListener}, to only receive a sub-set of events.
30 | */
31 | @Experimental
32 | public interface SyncListener extends SyncLoginListener, SyncCompletedListener, SyncChangeListener, SyncConnectionListener, SyncTimeListener {
33 | }
34 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/listener/SyncLoginListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.sync.listener;
18 |
19 | import io.objectbox.sync.SyncLoginCodes;
20 |
21 | /**
22 | * Listens to login events.
23 | */
24 | public interface SyncLoginListener {
25 |
26 | /**
27 | * Called on a successful login.
28 | *
29 | * At this point the connection to the sync destination was established and
30 | * entered an operational state, in which data can be sent both ways.
31 | */
32 | void onLoggedIn();
33 |
34 | /**
35 | * Called on a login failure. One of {@link SyncLoginCodes}, but never {@link SyncLoginCodes#OK}.
36 | */
37 | void onLoginFailed(long syncLoginCode);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/listener/SyncTimeListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.sync.listener;
18 |
19 | public interface SyncTimeListener {
20 |
21 | /**
22 | * Called when server time information is received on the client.
23 | */
24 | void onServerTimeUpdate(long serverTimeNanos);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/server/ClusterFlags.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // automatically generated by the FlatBuffers compiler, do not modify
18 |
19 | package io.objectbox.sync.server;
20 |
21 | /**
22 | * Special bit flags used in cluster mode only.
23 | */
24 | @SuppressWarnings("unused")
25 | public final class ClusterFlags {
26 | private ClusterFlags() { }
27 | /**
28 | * Indicates that this cluster always stays in the "follower" cluster role.
29 | * Thus, it does not participate in leader elections.
30 | * This is useful e.g. for weaker cluster nodes that should not become leaders.
31 | */
32 | public static final int FixedFollower = 1;
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/server/ClusterPeerInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2024 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.sync.server;
18 |
19 | import io.objectbox.annotation.apihint.Internal;
20 | import io.objectbox.sync.SyncCredentialsToken;
21 |
22 | /**
23 | * Internal class to keep configuration for a cluster peer.
24 | */
25 | @Internal
26 | final class ClusterPeerInfo {
27 | String url;
28 | SyncCredentialsToken credentials;
29 |
30 | ClusterPeerInfo(String url, SyncCredentialsToken credentials) {
31 | this.url = url;
32 | this.credentials = credentials;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/sync/server/SyncServerFlags.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // automatically generated by the FlatBuffers compiler, do not modify
18 |
19 | package io.objectbox.sync.server;
20 |
21 | /**
22 | * Bit flags to configure the Sync Server.
23 | */
24 | @SuppressWarnings("unused")
25 | public final class SyncServerFlags {
26 | private SyncServerFlags() { }
27 | /**
28 | * By default, if the Sync Server allows logins without credentials, it logs a warning message.
29 | * If this flag is set, the message is logged only as "info".
30 | */
31 | public static final int AuthenticationNoneLogInfo = 1;
32 | /**
33 | * By default, the Admin server is enabled; this flag disables it.
34 | */
35 | public static final int AdminDisabled = 2;
36 | /**
37 | * By default, the Sync Server logs messages when it starts and stops; this flag disables it.
38 | */
39 | public static final int LogStartStopDisabled = 4;
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/tree/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | * APIs to interact with tree structures stored in ObjectBox.
19 | */
20 | @ParametersAreNonnullByDefault
21 | package io.objectbox.tree;
22 |
23 | import javax.annotation.ParametersAreNonnullByDefault;
--------------------------------------------------------------------------------
/objectbox-java/src/main/resources/META-INF/proguard/objectbox-java.pro:
--------------------------------------------------------------------------------
1 | # When editing this file, also look at consumer-proguard-rules.pro of objectbox-android.
2 |
3 | -keepattributes *Annotation*
4 |
5 | # Native methods
6 | -keepclasseswithmembernames class io.objectbox.** {
7 | native
4 | Welcome to the JavaDocs for ObjectBox, the super-fast database for objects.
5 | On these pages, you will find the API reference for the ObjectBox Java library.
6 |
8 | The main documentation is available at docs.objectbox.io and offers
9 | a changelog, a getting started guide, and many more topics.
10 |
12 | GitHub links: ObjectBox Java,
13 | Examples for Java, Kotlin and Android
14 |
22 | *
27 | * {
22 | public final int limit;
23 | public final RelationInfo relationInfo;
24 |
25 | EagerRelation(int limit, RelationInfo relationInfo) {
26 | this.limit = limit;
27 | this.relationInfo = relationInfo;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/objectbox-java/src/main/java/io/objectbox/query/IdWithScore.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 ObjectBox Ltd. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.objectbox.query;
18 |
19 | /**
20 | * Wraps the ID of a matching object and a score when using {@link Query#findIdsWithScores}.
21 | */
22 | public class IdWithScore {
23 |
24 | private final long id;
25 | private final double score;
26 |
27 | // Note: this constructor is called by JNI, check before modifying/removing it.
28 | public IdWithScore(long id, double score) {
29 | this.id = id;
30 | this.score = score;
31 | }
32 |
33 | /**
34 | * Returns the object ID.
35 | */
36 | public long getId() {
37 | return id;
38 | }
39 |
40 | /**
41 | * Returns the query score for the {@link #getId() id}.
42 | *