Class DatabaseInstance<T extends DatabaseInstance<T>>
- All Implemented Interfaces:
Database.Dissolvable
,Database.UpdateListener
- Direct Known Subclasses:
DatabaseInstance.PropertyField.NullInstance
,Event
,EventAssociation
,Facility
,Image
,Notification
,User
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static class
A property wrapper for Single instance propertiesstatic class
DatabaseInstance.PropertyField<V,
W extends DatabaseInstance<W>> Designates a property that is maintained by a Database instancestatic class
DatabaseInstance.PropertyWrapper<V,
W extends DatabaseInstance<W>> Designates a property and its current value for a database instanceNested classes/interfaces inherited from interface com.syzygy.events.database.Database.UpdateListener
Database.UpdateListener.Type
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Database.Collections
The database collection which the instance belongs toprotected final Database
The databaseprivate final String
A non-modifiable documentID that uniquely identifies the instance within its collectionprivate final Set<Database.InitializationListener<T>>
A set of listeners which are called when the instance is initializedThe set of properties that need to loadprivate boolean
If the instance has been deletedprivate boolean
If this instance is dereferenced.private boolean
If the instance has been initialized with dataprivate boolean
If the instance has been initialized with dataprotected final Map<String,
DatabaseInstance.PropertyWrapper<?, ?>> The set of properties that don't need to loadprivate int
The number of references to this Instanceprivate com.google.firebase.firestore.ListenerRegistration
The snapshot listener that is associated with the database.private final Set<Database.UpdateListener>
The set of listeners. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DatabaseInstance
(Database db, String documentID, Database.Collections collection, DatabaseInstance.PropertyField<?, ?>[] properties) Checks to make sure the generic type is the type of this instance -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Adds a new initialization listener to this instancefinal void
addListener
(Database.UpdateListener listener) Adds a new update listener to this instanceprotected final void
Checks if the instance is in a legal state The instance is in an illegal state if The instance is dereferencedisDereferenced
or The instance has not been initialized with dataisInitialized
protected abstract T
cast()
Gets this instance casted to the generic typevoid
deleteInstance
(int deletionType, Consumer<Boolean> listener) Dereferences the instance.private void
deleteSubInstances
(int deletionType, Consumer<Boolean> listener) Deletes all subinstances that are cascadedprotected final void
Checks if the instance is dereferenced, in which case its tells the database to forget this instance and to remove it from cache.void
dissolve()
Decreases the reference count of this instancevoid
dissolve
(Database.UpdateListener listener) Removes the listener from the instance and decreases the referencefinal boolean
doesPropertyLoadInstance
(int resID) Checks if the property loads an instanceprivate <W extends DatabaseInstance<W>>
booleanexchangeInstance
(DatabaseInstance.InstancePropertyWrapper<W> prop, W newInstance) Exchanges a instance property's instance and id with the given new instance.private <W extends DatabaseInstance<W>>
voidexchangeInstance
(DatabaseInstance.PropertyWrapper<?, ?> p, String newID, Consumer<Boolean> onComplete) Exchanges a instance property's value with the given id.fetch()
Increases the reference count of this instance.fetch
(Database.UpdateListener listener) Increases the reference count of this instance and attaches the listenerprivate T
Increases the reference count of this instance.void
Decreases the reference count to zerofinal Image
Returns the image associated with this instance.Returns the name that should be given to the image instance.final Database.Collections
Returns the collection that this instance is apart of(package private) final com.google.firebase.firestore.CollectionReference
Returns theCollectionReference
associated with this instancegetData()
Returns the data of the instance(package private) final String
Returns a unique identifier for the instance within the full databasefinal String
Returns the document IDfinal com.google.firebase.firestore.DocumentReference
Returns theDocumentReference
associated with this instancestatic DatabaseInstance.PropertyField<?,
?>[] getFields
(Database.Collections collection) Gets all properties of the given collection instancefinal Object
getPropertyInstance
(int resID) Gets the instance of an single instance propertyfinal <W extends DatabaseInstance<W>>
WgetPropertyInstanceI
(int resID) Gets the instance of an single instance propertyfinal Object
getPropertyValue
(int resID) Gets the value of a single property.final <V> V
getPropertyValueI
(int resID) Gets the value of a single property.(package private) final void
initializeData
(Map<String, Object> data, boolean exists, Database.InitializationListener<T> onComplete) Initializes the instance with data.isDataValid
(Map<Integer, Object> map, Database.Collections collection) Tests if the map is valid for this instanceisDataValid
(Map<Integer, Object> map, DatabaseInstance.PropertyField<?, ?>[] fields) Tests if the map is valid for this instancefinal boolean
Returns if the object is in a legal statefinal boolean
isPropertyEditable
(int resID) Checks if the property is editablefinal boolean
isPropertyValid
(int resID, Object value) Test if the data is valid for the propertyfinal boolean
isPropertyValid
(DatabaseInstance.PropertyWrapper<?, ?> prop, Object value) Test if the data is valid for the propertyprotected final boolean
Checks if the reference count is positiveprotected final boolean
Modifies the properties of the object given the data set.protected final void
Notifies each listenerprivate void
onSubInstanceDelete
(DatabaseInstance<?> instance) Updates this instance appropriately when the subinstance is deleted<S extends DatabaseInstance<S>>
voidonUpdate
(DatabaseInstance<S> instance, Database.UpdateListener.Type type) Called whenever any subinstance is updated.protected final void
Notifies all listeners that an update has occurred and modifies the database to matchfinal boolean
removeListener
(Database.UpdateListener listener) Removes a listenerprotected void
requiredFirstDelete
(int deletionType, Consumer<Boolean> listener) Deletes any sub objects that are not instancesvoid
setAssociatedImage
(android.net.Uri image, Consumer<Boolean> onComplete) Sets the associated Image instance.final <W extends DatabaseInstance<W>>
BooleansetPropertyInstance
(int resID, W instance) Edits the value of an instance property to the new instance.final boolean
setPropertyValue
(int resID, Object newValue, Consumer<Boolean> onComplete) Edits the value of a property.protected void
Called when this instance is dereferenced.protected <X extends DatabaseInstance<X>>
voidsubInitialize
(Database.InitializationListener<T> listener, int count) Deprecated.Modify data already does this, this is never called without modify data being called firstprotected abstract List<android.util.Pair<com.google.firebase.firestore.Query,
Database.Collections>> toString()
(package private) final boolean
Modifies the properties of the object given the data set and notifies all listeners if the instance was changed.updateDataFromMap
(Map<Integer, Object> data, android.net.Uri image, String locName, Consumer<Boolean> onComplete) Validates the given data then creates the image and upon success updates the values and notifies listeners.Validates the given data then updates the values and notifies listeners.
-
Field Details
-
referenceCount
private int referenceCountThe number of references to this Instance -
isDereferenced
private boolean isDereferencedIf this instance is dereferenced.If the instance is no longer referenced, it is no longer maintained and updated by the database.
-
isInitialized
private boolean isInitializedIf the instance has been initialized with data -
isInitializing
private boolean isInitializingIf the instance has been initialized with data -
isDeleted
private boolean isDeletedIf the instance has been deleted -
db
The database -
documentID
A non-modifiable documentID that uniquely identifies the instance within its collection -
snapshotListener
private com.google.firebase.firestore.ListenerRegistration snapshotListenerThe snapshot listener that is associated with the database. This listener is called whenever the associated document is updated. -
collection
The database collection which the instance belongs to -
properties
The set of properties that don't need to load -
iproperties
The set of properties that need to load -
updateListeners
The set of listeners. Whenever the data of this instance changes, each listener is notified- See Also:
-
initializationListeners
private final Set<Database.InitializationListener<T extends DatabaseInstance<T>>> initializationListenersA set of listeners which are called when the instance is initialized
-
-
Constructor Details
-
DatabaseInstance
@Salty protected DatabaseInstance(Database db, String documentID, Database.Collections collection, @NonNull DatabaseInstance.PropertyField<?, ?>[] properties) throws ClassCastException, IllegalArgumentExceptionChecks to make sure the generic type is the type of this instance- Parameters:
db
- The databasedocumentID
- the unique identifier of the instance within its collectioncollection
- the database collection to which the instance belongs- Throws:
ClassCastException
- If the generic type is not the type of this instanceIllegalArgumentException
- if the properties are empty- See Also:
-
-
Method Details
-
cast
Gets this instance casted to the generic type- Returns:
- This as the generic type
-
getAssociatedImage
Returns the image associated with this instance. Null if no image -
getAssociatedImageLocName
Returns the name that should be given to the image instance. If no image is associated, returns null -
addListener
public final void addListener(@Nullable Database.UpdateListener listener) throws IllegalStateException Adds a new update listener to this instanceIf the same listener is added twice, the listener will only be notified of an update once
- Parameters:
listener
- The listener- Throws:
IllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
- See Also:
-
removeListener
Removes a listener- Parameters:
listener
- The listener- Returns:
- If the set of listeners changed as a result
-
addInitializationListener
@MustStir public final void addInitializationListener(@Nullable Database.InitializationListener<T> listener) throws IllegalStateException Adds a new initialization listener to this instanceIf the same listener is added twice, the listener will only be notified of an update once
If the instance is already initialized, the listener is called immediately
- Parameters:
listener
- The listener- Throws:
IllegalStateException
- if the instance is dereferenced- See Also:
-
notifyUpdate
Notifies each listener- Parameters:
type
- The type of update that occurred- Throws:
IllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
- See Also:
-
fetchWithoutThrow
Increases the reference count of this instance.- Returns:
- This instance casted to the generic type
-
fetch
Increases the reference count of this instance.- Returns:
- This instance casted to the generic type
- Throws:
IllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
-
fetch
Increases the reference count of this instance and attaches the listener- Parameters:
listener
- the update listener- Returns:
- This instance casted to the generic type
- Throws:
IllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
-
dissolve
Decreases the reference count of this instance- Specified by:
dissolve
in interfaceDatabase.Dissolvable
-
dissolve
@AutoStir @StirsDeep(what="Property Instances", when="No Longer Referenced") public void dissolve(Database.UpdateListener listener) Removes the listener from the instance and decreases the reference- Parameters:
listener
- The listener
-
fullDissolve
Decreases the reference count to zero -
isReferenced
protected final boolean isReferenced()Checks if the reference count is positive- Returns:
true
if one or more objects are referencing this instance
-
isLegalState
public final boolean isLegalState()Returns if the object is in a legal state- Returns:
- If the object is in a legal state
- See Also:
-
assertNotIllegalState
Checks if the instance is in a legal state The instance is in an illegal state if- The instance is dereferenced
isDereferenced
or - The instance has not been initialized with data
isInitialized
- Throws:
IllegalStateException
- if the instance is in an illegal state- See Also:
- The instance is dereferenced
-
dereferenceInstance
Checks if the instance is dereferenced, in which case its tells the database to forget this instance and to remove it from cache. Also, clears all listeners. -
subDereferenceInstance
Called when this instance is dereferenced. This function should dissolve any sub-instances -
onUpdate
@AutoStir(when="Instance is deleted and Property is not nullable") @StirsDeep(what="Property Instances", when="Instance is deleted and Property is not nullable") public <S extends DatabaseInstance<S>> void onUpdate(@Observes DatabaseInstance<S> instance, Database.UpdateListener.Type type) Called whenever any subinstance is updated. Notifies the listeners that a subupdate occurred unless an instance was deleted, then an actual update is notified- Specified by:
onUpdate
in interfaceDatabase.UpdateListener
- Type Parameters:
S
- The type of the subinstance- Parameters:
instance
- The subinstancetype
- The type of the update- See Also:
-
onSubInstanceDelete
@AutoStir(when="Property is not nullable") @StirsDeep(what="Property Instances", when="Property is not nullable") private void onSubInstanceDelete(@Observes DatabaseInstance<?> instance) Updates this instance appropriately when the subinstance is deletedRemoves the instance. If the property cannot be null and is now null, this instance is deleted. Otherwise, notifies the listeners that an update occurred
- Parameters:
instance
- The subinstance
-
toString
- Overrides:
toString
in classObject
- Throws:
IllegalStateException
-
getDocumentID
Returns the document ID- Returns:
- the unique identifier of the instance within the collection
-
getDatabaseID
Returns a unique identifier for the instance within the full database- Returns:
- The unique database identifier
- Throws:
IllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
- See Also:
-
exchangeInstance
@StirsDeep(what="Previous Instance") private <W extends DatabaseInstance<W>> void exchangeInstance(DatabaseInstance.PropertyWrapper<?, ?> p, @Dilutes String newID, Consumer<Boolean> onComplete) throws IllegalArgumentException, ClassCastExceptionExchanges a instance property's value with the given id. Loads the new ID.- Type Parameters:
W
- The type of the instance- Parameters:
p
- The property to editnewID
- The ID of the new instanceonComplete
- called on completion, true if no errors occurred, might not be called before return- Throws:
IllegalArgumentException
- If the property is not an instance propertyClassCastException
- If the type does not match the properties type
-
exchangeInstance
@AutoStir @StirsDeep(what="Previous Instance") private <W extends DatabaseInstance<W>> boolean exchangeInstance(DatabaseInstance.InstancePropertyWrapper<W> prop, @Dilutes W newInstance) throws ClassCastException Exchanges a instance property's instance and id with the given new instance. Fetches a reference to the newInstance- Type Parameters:
W
- The type of the instance- Parameters:
prop
- The property to editnewInstance
- The new Instance- Returns:
- If success full
- Throws:
IllegalArgumentException
- If the property is not an instance propertyClassCastException
- If the type does not match the properties type
-
modifyData
@StirsDeep(what="Old Instances of Instance properties that are modified") protected final boolean modifyData(@Dilutes Map<String, Object> data, Consumer<Boolean> onComplete) throws IllegalArgumentException, ClassCastExceptionModifies the properties of the object given the data set. Calls all initialization listeners. Adds a snapshot listener to the document.Ignores if the field can edit
- Parameters:
data
- The property key-value setonComplete
- called on completion. true if no errors. If none of the properties are setting an instance id, will be called before return.- Returns:
true
if the instance was changed as a result- Throws:
IllegalArgumentException
- if a key is not one of the available properties, or if the value is not validClassCastException
- if a value does not match an properties type
-
setPropertyValue
@StirsDeep(what="The previous instance", when="Modifying an instance property") public final boolean setPropertyValue(int resID, @Dilutes Object newValue, Consumer<Boolean> onComplete) throws IllegalArgumentException, IllegalStateException Edits the value of a property. If the property is an instance, loads the property and fetches the reference- Parameters:
resID
- The res id of the property namenewValue
- the new value of the propertyonComplete
- called on completion, true if no errors occurred. Will be called before return if setting a non loading property or if setting a loading property with an already instantiated instance- Returns:
- if the property was changed
- Throws:
IllegalArgumentException
- if the property does not exist or if the property cannot be edited or the new value is invalidIllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
ClassCastException
- if the value type does not match the properties type
-
setPropertyInstance
@StirsDeep(what="The previous instance") public final <W extends DatabaseInstance<W>> Boolean setPropertyInstance(int resID, @Nullable @Dilutes W instance) throws IllegalArgumentException, ClassCastException, IllegalStateException Edits the value of an instance property to the new instance. Fetches a reference to the new instance- Parameters:
resID
- The res id of the property nameinstance
- the instance to make the new value. This function will retrieve its own reference- Returns:
- if the property was changed (null if error)
- Throws:
IllegalArgumentException
- if the property does not exist or if the property cannot be edited or the new value is invalid or the property is not an instance propertyIllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
ClassCastException
- if the instance type does not match the properties type
-
getPropertyValue
@Observes public final Object getPropertyValue(int resID) throws IllegalArgumentException, ClassCastException Gets the value of a single property. In the case of instance properties, this returns the id- Parameters:
resID
- The res id of the property name- Returns:
- The value of the property as an Object
- Throws:
IllegalArgumentException
- if the property does not existClassCastException
- if the generic is incorrect
-
getPropertyValueI
@Observes public final <V> V getPropertyValueI(int resID) throws IllegalArgumentException, ClassCastException Gets the value of a single property. In the case of instance properties, this returns the id- Type Parameters:
V
- The type of the property- Parameters:
resID
- The res id of the property name- Returns:
- The value of the property as an Object
- Throws:
IllegalArgumentException
- if the property does not existClassCastException
- if the generic is incorrect
-
getPropertyInstance
Gets the instance of an single instance property- Parameters:
resID
- The res id of the property name- Returns:
- The value of the property as an Object
- Throws:
IllegalArgumentException
- if the property does not exist or does not have instances
-
getPropertyInstanceI
@Observes public final <W extends DatabaseInstance<W>> W getPropertyInstanceI(int resID) throws IllegalArgumentException, ClassCastException Gets the instance of an single instance property- Parameters:
resID
- The res id of the property name- Returns:
- The value of the property as an Object
- Throws:
IllegalArgumentException
- if the property does not exist or does not have instancesClassCastException
- if the generic is incorrect
-
isPropertyValid
Test if the data is valid for the property- Parameters:
resID
- The res id of the property namevalue
- The value to test- Returns:
true
if the value is valid
-
isPropertyValid
public final boolean isPropertyValid(DatabaseInstance.PropertyWrapper<?, ?> prop, @Observes Object value) Test if the data is valid for the property- Parameters:
prop
- the propertyvalue
- the value to test- Returns:
true
if the value is valid
-
getFields
Gets all properties of the given collection instance- Returns:
- The property fields of the instance type
-
isDataValid
public static Set<Integer> isDataValid(@Observes Map<Integer, Object> map, Database.Collections collection) Tests if the map is valid for this instance- Parameters:
map
- The property resID-value map where resID is the res ID of the property namecollection
- The collection of the instance- Returns:
- The set of all invalid ids
-
isDataValid
static Set<Integer> isDataValid(@Observes Map<Integer, Object> map, DatabaseInstance.PropertyField<?, ?>[] fields) Tests if the map is valid for this instance- Parameters:
map
- The property resID-value map where resID is the res ID of the property namefields
- The set of propertyFields to test against- Returns:
- The set of all invalid ids
-
isPropertyEditable
public final boolean isPropertyEditable(int resID) Checks if the property is editable- Parameters:
resID
- the res id of the property name- Returns:
true
if the property is present and editable
-
doesPropertyLoadInstance
public final boolean doesPropertyLoadInstance(int resID) Checks if the property loads an instance- Parameters:
resID
- the res id of the property name- Returns:
true
if the property is present and loads an instance
-
initializeData
@AutoStir(when="Error or not exists") @Stirred final void initializeData(@Dilutes Map<String, Object> data, boolean exists, Database.InitializationListener<T> onComplete) throws IllegalStateExceptionInitializes the instance with data.This function sets the data. Then it sets the instance to a valid state. Then it notifies all initialization listeners and update listeners. Finally it adds the snapshot listener to the document
If it does not exist, full dissolves and notifies all listeners with null
- Parameters:
data
- The property key-value mapping of the dataexists
- If the document exists in the databaseonComplete
- Called when initialization is complete before the any other initialization listeners. This listener will not return a fetched instance, all other initialization listeners attached to the object will return a fetch instance.- Throws:
IllegalStateException
- if the instance has already been initialized
-
subInitialize
@Titrates(what="Sub instances") @Deprecated protected <X extends DatabaseInstance<X>> void subInitialize(Database.InitializationListener<T> listener, int count) throws IllegalArgumentException Deprecated.Modify data already does this, this is never called without modify data being called firstThis function is called after this instance's data has been initialized and set. This function should call the getter's for each sub-instance that needs to be stored. The listener should only be called once all sub-objects have been loaded. The listener's success should be set to false if any of the objects failed. Only sub-instances that are successfully loaded should be non-null when the listener is called, all failed should be set to null (they will be dereferenced automatically by their own initializers)- Parameters:
listener
- The listener that should be called once all initialization is complete- Throws:
IllegalArgumentException
- If the value is empty but the property is not nullable TODO does this X hack work?
-
updateDataFromDatabase
@StirsDeep(what="Old Instances of Instance properties that are modified") final boolean updateDataFromDatabase(@Dilutes Map<String, Object> data, Consumer<Boolean> onComplete) throws IllegalStateExceptionModifies the properties of the object given the data set and notifies all listeners if the instance was changed.- Parameters:
data
- The property key-value setonComplete
- called once complete, true if no errors. If not modifying any instance ids, will be called before return- Returns:
true
if the instance was changed as a result- Throws:
IllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
-
updateDataFromMap
@StirsDeep(what="Old Instances of Instance properties that are modified") public final Set<Integer> updateDataFromMap(@Dilutes Map<Integer, Object> data, @Nullable android.net.Uri image, String locName, Consumer<Boolean> onComplete) throws IllegalStateException, IllegalArgumentException, ClassCastExceptionValidates the given data then creates the image and upon success updates the values and notifies listeners. Then updates the database. Updates the associated image with the new image- Parameters:
data
- The property name id -> value mapping of all fields to be editedimage
- The imagelocName
- The name of the location where the image is storedonComplete
- called once complete, true if no errors. If not modifying any instance ids, will be called before return- Returns:
- The set of invalid property ids upon validation
- Throws:
IllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
IllegalArgumentException
- if a key is not one of the available properties to edit or a value is not validClassCastException
- If a value's type does not match the property type- See Also:
-
updateDataFromMap
@StirsDeep(what="Old Instances of Instance properties that are modified") public final Set<Integer> updateDataFromMap(@Dilutes Map<Integer, Object> data, Consumer<Boolean> onComplete) throws IllegalStateException, IllegalArgumentException, ClassCastExceptionValidates the given data then updates the values and notifies listeners. Then updates the database.- Parameters:
data
- The property name id -> value mapping of all fields to be editedonComplete
- called once complete, true if no errors. If not modifying any instance ids, will be called before return- Returns:
- The set of invalid property ids upon validation
- Throws:
IllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
IllegalArgumentException
- if a key is not one of the available properties to edit or a value is not validClassCastException
- If a value's type does not match the property type
-
setAssociatedImage
@StirsDeep(what="The previous Image") public void setAssociatedImage(@Nullable android.net.Uri image, Consumer<Boolean> onComplete) throws UnsupportedOperationException Sets the associated Image instance. This function will create a new reference to the instance.- Parameters:
image
- The new instanceonComplete
- called on completion with if the update was successful- Throws:
UnsupportedOperationException
- if the instance type does not have an editable associated image
-
getData
Returns the data of the instance- Returns:
- The property key-value map of the instance
- Throws:
IllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
-
processUpdate
Notifies all listeners that an update has occurred and modifies the database to match- Throws:
IllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
- See Also:
-
deleteInstance
@AutoStir @StirsDeep(what="Sub Instances") public void deleteInstance(int deletionType, Consumer<Boolean> listener) Dereferences the instance. Then cascade deletes all cascading properties. Then notifies all listeners that the instance was deleted.- Parameters:
deletionType
- TheDatabaseInstance.DeletionType
reason this instance is being deletedlistener
- called on completion of deletion, returns false if one or more errors occured- See Also:
-
requiredFirstDelete
Deletes any sub objects that are not instances- Parameters:
deletionType
- TheDatabaseInstance.DeletionType
reason this instance is being deletedlistener
- Called before the instance and sub instances are deleted; they are only deleted if this returns true
-
deleteSubInstances
@StirsDeep(what="Sub instances") private void deleteSubInstances(int deletionType, Consumer<Boolean> listener) Deletes all subinstances that are cascaded- Parameters:
deletionType
- TheDatabaseInstance.DeletionType
reason this instance is being deletedlistener
- called on completion of deletion
-
subInstanceCascadeDeleteQuery
protected abstract List<android.util.Pair<com.google.firebase.firestore.Query,Database.Collections>> subInstanceCascadeDeleteQuery()- Returns:
- A list of all querries that should be run whose instances will be deleted when this instance is deleted
-
getCollection
Returns the collection that this instance is apart of- Returns:
- the
Database.Collections
-
getDocumentReference
public final com.google.firebase.firestore.DocumentReference getDocumentReference()Returns theDocumentReference
associated with this instanceIf the document did not exist, a new document is created
- Returns:
- the database reference to this instance
- See Also:
-
getCollectionReference
final com.google.firebase.firestore.CollectionReference getCollectionReference() throws IllegalStateExceptionReturns theCollectionReference
associated with this instance- Returns:
- the database reference to the collection containing this instance
- Throws:
IllegalStateException
- if the instance is in an illegal stateassertNotIllegalState()
- See Also:
-