Skip to content

Commit 14ae034

Browse files
Annotations: unify class and constructor documentation
Dart API documentation displays all classes in a list. Explicitly mention which classes are an annotation. Also note what Dart elements they can be applied on.
1 parent 7eb6299 commit 14ae034

File tree

1 file changed

+42
-23
lines changed

1 file changed

+42
-23
lines changed

objectbox/lib/src/annotations.dart

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import '../objectbox.dart';
22

3-
/// See [Entity.new].
3+
/// An annotation to mark a class as an ObjectBox Entity. See [Entity.new].
44
class Entity {
55
/// ObjectBox keeps track of entities and properties by assigning them unique
66
/// identifiers, UIDs, during the code-generation phase. All those UIDs are
@@ -32,7 +32,8 @@ class Entity {
3232
const Entity({this.uid, this.realClass});
3333
}
3434

35-
/// See [Property.new].
35+
/// An optional annotation to configure how a field of an [Entity] class is
36+
/// stored. See [Property.new].
3637
class Property {
3738
/// ObjectBox keeps track of entities and properties by assigning them unique
3839
/// identifiers, UIDs, during the code-generation phase. All those UIDs are
@@ -69,7 +70,8 @@ class Property {
6970
/// executing queries or creating indexes. Defaults to `true`.
7071
final bool signed;
7172

72-
/// Optionally configures how a field is stored in the database.
73+
/// Optionally configures how a field of an [Entity] class is stored in the
74+
/// database.
7375
///
7476
/// For example:
7577
///
@@ -176,6 +178,7 @@ enum PropertyType {
176178
// stringVector
177179
}
178180

181+
/// An annotation to mark a field of an [Entity] class as the ID property.
179182
/// See [Id.new].
180183
class Id {
181184
/// When you put a new object you don't assign an ID by default, it's assigned
@@ -188,17 +191,18 @@ class Id {
188191
/// telling which objects are new and which are already saved.
189192
final bool assignable;
190193

191-
/// Marks the ID property of an [Entity]. The property must be of type [int],
192-
/// be non-final and have not-private visibility (or a not-private getter and
193-
/// setter method).
194+
/// Marks the field of an [Entity] class as its ID property. The field must be
195+
/// of type [int], be non-final and have not-private visibility (or a
196+
/// not-private getter and setter method).
194197
///
195198
/// ID properties are unique and indexed by default.
196199
const Id({this.assignable = false});
197200
}
198201

199-
/// See [Transient.new].
202+
/// An annotation to mark a field of an [Entity] class that should not be
203+
/// stored. See [Transient.new].
200204
class Transient {
201-
/// Marks that a field should not be stored in the database.
205+
/// Marks a field of an [Entity] class so it is not stored in the database.
202206
const Transient();
203207
}
204208

@@ -208,12 +212,13 @@ class Transient {
208212
// const Sync();
209213
// }
210214

211-
/// See [Index.new].
215+
/// An annotation to create an index for a field of an [Entity] class. See
216+
/// [Index.new].
212217
class Index {
213218
/// Index type.
214219
final IndexType? type;
215220

216-
/// Specifies that the property should be indexed.
221+
/// Creates an index for a field of an [Entity] class.
217222
///
218223
/// It is highly recommended to index properties that are used in a Query to
219224
/// improve query performance. To fine tune indexing of a property you can
@@ -250,11 +255,14 @@ enum IndexType {
250255
hash64,
251256
}
252257

253-
/// See [Unique.new].
258+
/// An annotation to create a unique index for a field of an [Entity] class. See
259+
/// [Unique.new].
254260
class Unique {
255261
/// The strategy to use when a conflict is detected when an object is put.
256262
final ConflictStrategy onConflict;
257263

264+
/// Creates a unique index for a field of an [Entity] class.
265+
///
258266
/// Enforces that the value of a property is unique among all objects in a Box
259267
/// before an object can be put.
260268
///
@@ -278,15 +286,16 @@ enum ConflictStrategy {
278286
replace,
279287
}
280288

281-
/// See [Backlink.new].
289+
/// An annotation for a [ToMany] field of an [Entity] class to create a relation
290+
/// based on another relation. See [Backlink.new].
282291
class Backlink {
283292
/// Name of the relation the backlink should be based on (e.g. name of a
284293
/// [ToOne] or [ToMany] property in the target entity). Can be left empty if
285294
/// there is just a single relation from the target to the source entity.
286295
final String to;
287296

288-
/// Defines a backlink relation, which is based on another relation reversing
289-
/// the direction.
297+
/// Marks a [ToMany] field in an [Entity] class to indicate the relation
298+
/// should be created based on another relation by reversing the direction.
290299
///
291300
/// Pass the name of the relation the backlink should be based on (e.g. name
292301
/// of a [ToOne] or [ToMany] property in the target entity). Can be left empty
@@ -405,7 +414,8 @@ class HnswFlags {
405414
this.reparationLimitCandidates = false});
406415
}
407416

408-
/// See [HnswIndex.new].
417+
/// An annotation to create an HSNW index for a field of an [Entity] class. See
418+
/// [HnswIndex.new].
409419
class HnswIndex {
410420
/// Dimensions of vectors; vector data with fewer dimensions are ignored.
411421
/// Vectors with more dimensions than specified here are only evaluated up to
@@ -471,8 +481,10 @@ class HnswIndex {
471481
/// for large changes, it can double due to multi-version transactions.
472482
final int? vectorCacheHintSizeKB;
473483

474-
/// Parameters to configure HNSW-based approximate nearest neighbor (ANN)
475-
/// search.
484+
/// Creates an HNSW index for a field of an [Entity] class.
485+
///
486+
/// Use the parameters to configure HNSW-based approximate nearest neighbor
487+
/// (ANN) search.
476488
///
477489
/// Some of the parameters can influence index construction and searching.
478490
///
@@ -615,15 +627,19 @@ enum ExternalPropertyType {
615627
mongoRegex
616628
}
617629

618-
/// See the constructor documentation.
630+
/// An annotation to specify the type of a field in an [Entity] class in an
631+
/// external system. See [ExternalType.new].
619632
class ExternalType {
620633
/// The type of the property in the external system.
621634
///
622635
/// See [ExternalPropertyType] for possible values.
623636
final ExternalPropertyType type;
624637

625-
/// Sets the type of a property or the type of object IDs of a [ToMany] in an
626-
/// external system (like another database).
638+
/// Sets the type of a field in an [Entity] class in an external system (like
639+
/// another database).
640+
///
641+
/// When used on a [ToMany] field, this sets the type of the object IDs
642+
/// of the relation instead.
627643
///
628644
/// This is useful if there is no default mapping of the ObjectBox type to the
629645
/// type in the external system.
@@ -633,12 +649,15 @@ class ExternalType {
633649
const ExternalType({required this.type});
634650
}
635651

636-
/// See the constructor documentation.
652+
/// An annotation to specify the name of an [Entity] class or field of an
653+
/// [Entity] class in an external system. See [ExternalName.new].
637654
class ExternalName {
638655
/// The name assigned to the property in the external system.
639656
final String name;
640657

641-
/// Sets the name of an @Entity, a property or a [ToMany] in an external
642-
/// system (like another database).
658+
/// Sets the name of an [Entity] class or a field of an [Entity] class in an
659+
/// external system (like another database).
660+
///
661+
/// The field may be of type [ToMany].
643662
const ExternalName({required this.name});
644663
}

0 commit comments

Comments
 (0)