com.google.firebase.database.annotations.NotNull Java Examples
The following examples show how to use
com.google.firebase.database.annotations.NotNull.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DatabasePagingOptions.java From FirebaseUI-Android with Apache License 2.0 | 5 votes |
/** * Sets the Database query to paginate. * * @param query the FirebaseDatabase query. This query should only contain orderByKey(), orderByChild() and * orderByValue() clauses. Any limit will cause an error such as limitToLast() or limitToFirst(). * @param config paging configuration, passed directly to the support paging library. * @param parser the {@link SnapshotParser} to parse {@link DataSnapshot} into model * objects. * @return this, for chaining. */ @NonNull public Builder<T> setQuery(@NonNull Query query, @NonNull PagedList.Config config, @NotNull SnapshotParser<T> parser) { FirebaseDataSource.Factory factory = new FirebaseDataSource.Factory(query); mData = new LivePagedListBuilder<>(factory, config).build(); mParser = parser; return this; }
Example #2
Source File: Repo.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
public void addEventCallback(@NotNull EventRegistration eventRegistration) { List<? extends Event> events; ChildKey front = eventRegistration.getQuerySpec().getPath().getFront(); if (front != null && front.equals(Constants.DOT_INFO)) { events = this.infoSyncTree.addEventRegistration(eventRegistration); } else { events = this.serverSyncTree.addEventRegistration(eventRegistration); } this.postEvents(events); }
Example #3
Source File: Repo.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
public void removeEventCallback(@NotNull EventRegistration eventRegistration) { // These are guaranteed not to raise events, since we're not passing in a cancelError. However, // we can future-proof a little bit by handling the return values anyways. List<Event> events; if (Constants.DOT_INFO.equals(eventRegistration.getQuerySpec().getPath().getFront())) { events = infoSyncTree.removeEventRegistration(eventRegistration); } else { events = serverSyncTree.removeEventRegistration(eventRegistration); } this.postEvents(events); }
Example #4
Source File: SyncPoint.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
/** Add an event callback for the specified query. */ public List<DataEvent> addEventRegistration( @NotNull EventRegistration eventRegistration, WriteTreeRef writesCache, CacheNode serverCache) { QuerySpec query = eventRegistration.getQuerySpec(); View view = this.views.get(query.getParams()); if (view == null) { // TODO: make writesCache take flag for complete server node Node eventCache = writesCache.calcCompleteEventCache( serverCache.isFullyInitialized() ? serverCache.getNode() : null); boolean eventCacheComplete; if (eventCache != null) { eventCacheComplete = true; } else { eventCache = writesCache.calcCompleteEventChildren(serverCache.getNode()); eventCacheComplete = false; } IndexedNode indexed = IndexedNode.from(eventCache, query.getIndex()); ViewCache viewCache = new ViewCache(new CacheNode(indexed, eventCacheComplete, false), serverCache); view = new View(query, viewCache); // If this is a non-default query we need to tell persistence our current view of the data if (!query.loadsAllData()) { Set<ChildKey> allChildren = new HashSet<ChildKey>(); for (NamedNode node : view.getEventCache()) { allChildren.add(node.getName()); } this.persistenceManager.setTrackedQueryKeys(query, allChildren); } this.views.put(query.getParams(), view); } // This is guaranteed to exist now, we just created anything that was missing view.addEventRegistration(eventRegistration); return view.getInitialEvents(eventRegistration); }
Example #5
Source File: SyncPoint.java From firebase-admin-java with Apache License 2.0 | 5 votes |
/** Add an event callback for the specified query. */ public List<DataEvent> addEventRegistration( @NotNull EventRegistration eventRegistration, WriteTreeRef writesCache, CacheNode serverCache) { QuerySpec query = eventRegistration.getQuerySpec(); View view = this.views.get(query.getParams()); if (view == null) { // TODO: make writesCache take flag for complete server node Node eventCache = writesCache.calcCompleteEventCache( serverCache.isFullyInitialized() ? serverCache.getNode() : null); boolean eventCacheComplete; if (eventCache != null) { eventCacheComplete = true; } else { eventCache = writesCache.calcCompleteEventChildren(serverCache.getNode()); eventCacheComplete = false; } IndexedNode indexed = IndexedNode.from(eventCache, query.getIndex()); ViewCache viewCache = new ViewCache(new CacheNode(indexed, eventCacheComplete, false), serverCache); view = new View(query, viewCache); // If this is a non-default query we need to tell persistence our current view of the // data if (!query.loadsAllData()) { Set<ChildKey> allChildren = new HashSet<>(); for (NamedNode node : view.getEventCache()) { allChildren.add(node.getName()); } this.persistenceManager.setTrackedQueryKeys(query, allChildren); } this.views.put(query.getParams(), view); } // This is guaranteed to exist now, we just created anything that was missing view.addEventRegistration(eventRegistration); return view.getInitialEvents(eventRegistration); }
Example #6
Source File: Repo.java From firebase-admin-java with Apache License 2.0 | 5 votes |
public void removeEventCallback(@NotNull EventRegistration eventRegistration) { // These are guaranteed not to raise events, since we're not passing in a cancelError. However, // we can future-proof a little bit by handling the return values anyways. List<Event> events; if (Constants.DOT_INFO.equals(eventRegistration.getQuerySpec().getPath().getFront())) { events = infoSyncTree.removeEventRegistration(eventRegistration); } else { events = serverSyncTree.removeEventRegistration(eventRegistration); } this.postEvents(events); }
Example #7
Source File: Repo.java From firebase-admin-java with Apache License 2.0 | 5 votes |
public void addEventCallback(@NotNull EventRegistration eventRegistration) { List<? extends Event> events; ChildKey front = eventRegistration.getQuerySpec().getPath().getFront(); if (front != null && front.equals(Constants.DOT_INFO)) { events = this.infoSyncTree.addEventRegistration(eventRegistration); } else { events = this.serverSyncTree.addEventRegistration(eventRegistration); } this.postEvents(events); }
Example #8
Source File: ChildEventRegistration.java From firebase-admin-java with Apache License 2.0 | 4 votes |
@NotNull @Override public QuerySpec getQuerySpec() { return spec; }
Example #9
Source File: ChildEventRegistration.java From firebase-admin-java with Apache License 2.0 | 4 votes |
public ChildEventRegistration( @NotNull Repo repo, @NotNull ChildEventListener eventListener, @NotNull QuerySpec spec) { this.repo = repo; this.eventListener = eventListener; this.spec = spec; }
Example #10
Source File: RandomPersistenceTest.java From firebase-admin-java with Apache License 2.0 | 4 votes |
TestEventRegistration(@NotNull QuerySpec query) { this.query = query; }
Example #11
Source File: RandomPersistenceTest.java From firebase-admin-java with Apache License 2.0 | 4 votes |
@NotNull @Override public QuerySpec getQuerySpec() { return query; }
Example #12
Source File: SyncTree.java From firebase-admin-java with Apache License 2.0 | 4 votes |
@NotNull @Override public QuerySpec getQuerySpec() { return spec; }
Example #13
Source File: SyncTree.java From firebase-admin-java with Apache License 2.0 | 4 votes |
public KeepSyncedEventRegistration(@NotNull QuerySpec spec) { this.spec = spec; }
Example #14
Source File: SyncPointTest.java From firebase-admin-java with Apache License 2.0 | 4 votes |
@NotNull @Override public QuerySpec getQuerySpec() { return query; }
Example #15
Source File: SyncPointTest.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
@NotNull @Override public QuerySpec getQuerySpec() { return query; }
Example #16
Source File: SyncTree.java From firebase-admin-java with Apache License 2.0 | 4 votes |
private List<Event> removeEventRegistration( @NotNull final QuerySpec query, @Nullable final EventRegistration eventRegistration, @Nullable final DatabaseError cancelError) { return persistenceManager.runInTransaction( new Callable<List<Event>>() { @Override public List<Event> call() { // Find the syncPoint first. Then deal with whether or not it has matching listeners Path path = query.getPath(); SyncPoint maybeSyncPoint = syncPointTree.get(path); List<Event> cancelEvents = new ArrayList<>(); // A removal on a default query affects all queries at that location. A removal on an // indexed query, even one without other query constraints, does *not* affect all // queries at that location. So this check must be for 'default', and not // loadsAllData(). if (maybeSyncPoint != null && (query.isDefault() || maybeSyncPoint.viewExistsForQuery(query))) { // @type {{removed: !Array.<!fb.api.Query>, events: !Array.<!fb.core.view.Event>}} Pair<List<QuerySpec>, List<Event>> removedAndEvents = maybeSyncPoint.removeEventRegistration(query, eventRegistration, cancelError); if (maybeSyncPoint.isEmpty()) { syncPointTree = syncPointTree.remove(path); } List<QuerySpec> removed = removedAndEvents.getFirst(); cancelEvents = removedAndEvents.getSecond(); // We may have just removed one of many listeners and can short-circuit this whole // process. We may also not have removed a default listener, in which case all of the // descendant listeners should already be properly set up. // // Since indexed queries can shadow if they don't have other query constraints, check // for loadsAllData(), instead of isDefault(). boolean removingDefault = false; for (QuerySpec queryRemoved : removed) { persistenceManager.setQueryInactive(query); removingDefault = removingDefault || queryRemoved.loadsAllData(); } ImmutableTree<SyncPoint> currentTree = syncPointTree; boolean covered = currentTree.getValue() != null && currentTree.getValue().hasCompleteView(); for (ChildKey component : path) { currentTree = currentTree.getChild(component); covered = covered || (currentTree.getValue() != null && currentTree.getValue().hasCompleteView()); if (covered || currentTree.isEmpty()) { break; } } if (removingDefault && !covered) { ImmutableTree<SyncPoint> subtree = syncPointTree.subtree(path); // There are potentially child listeners. Determine what if any listens we need to // send before executing the removal. if (!subtree.isEmpty()) { // We need to fold over our subtree and collect the listeners to send List<View> newViews = collectDistinctViewsForSubTree(subtree); // Ok, we've collected all the listens we need. Set them up. for (View view : newViews) { ListenContainer container = new ListenContainer(view); QuerySpec newQuery = view.getQuery(); listenProvider.startListening( queryForListening(newQuery), container.tag, container, container); } } else { // There's nothing below us, so nothing we need to start listening on } } // If we removed anything and we're not covered by a higher up listen, we need to stop // listening on this query. The above block has us covered in terms of making sure // we're set up on listens lower in the tree. // Also, note that if we have a cancelError, it's already been removed at the provider // level. if (!covered && !removed.isEmpty() && cancelError == null) { // If we removed a default, then we weren't listening on any of the other queries // here. Just cancel the one default. Otherwise, we need to iterate through and // cancel each individual query if (removingDefault) { listenProvider.stopListening(queryForListening(query), null); } else { for (QuerySpec queryToRemove : removed) { Tag tag = tagForQuery(queryToRemove); assert tag != null; listenProvider.stopListening(queryForListening(queryToRemove), tag); } } } // Now, clear all of the tags we're tracking for the removed listens removeTags(removed); } else { // No-op, this listener must've been already removed } return cancelEvents; } }); }
Example #17
Source File: View.java From firebase-admin-java with Apache License 2.0 | 4 votes |
public void addEventRegistration(@NotNull EventRegistration registration) { this.eventRegistrations.add(registration); }
Example #18
Source File: ValueEventRegistration.java From firebase-admin-java with Apache License 2.0 | 4 votes |
@NotNull @Override public QuerySpec getQuerySpec() { return spec; }
Example #19
Source File: ValueEventRegistration.java From firebase-admin-java with Apache License 2.0 | 4 votes |
public ValueEventRegistration( Repo repo, ValueEventListener eventListener, @NotNull QuerySpec spec) { this.repo = repo; this.eventListener = eventListener; this.spec = spec; }
Example #20
Source File: ZombieEventManager.java From firebase-admin-java with Apache License 2.0 | 4 votes |
@NotNull public static ZombieEventManager getInstance() { return defaultInstance; }
Example #21
Source File: ChildEventRegistration.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
public ChildEventRegistration( @NotNull Repo repo, @NotNull ChildEventListener eventListener, @NotNull QuerySpec spec) { this.repo = repo; this.eventListener = eventListener; this.spec = spec; }
Example #22
Source File: ZombieEventManager.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
@NotNull public static ZombieEventManager getInstance() { return defaultInstance; }
Example #23
Source File: ValueEventRegistration.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
public ValueEventRegistration( Repo repo, ValueEventListener eventListener, @NotNull QuerySpec spec) { this.repo = repo; this.eventListener = eventListener; this.spec = spec; }
Example #24
Source File: ValueEventRegistration.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
@NotNull @Override public QuerySpec getQuerySpec() { return spec; }
Example #25
Source File: View.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
public void addEventRegistration(@NotNull EventRegistration registration) { this.eventRegistrations.add(registration); }
Example #26
Source File: SyncTree.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
private List<Event> removeEventRegistration( final @NotNull QuerySpec query, final @Nullable EventRegistration eventRegistration, final @Nullable DatabaseError cancelError) { return persistenceManager.runInTransaction( new Callable<List<Event>>() { @Override public List<Event> call() { // Find the syncPoint first. Then deal with whether or not it has matching listeners Path path = query.getPath(); SyncPoint maybeSyncPoint = syncPointTree.get(path); List<Event> cancelEvents = new ArrayList<Event>(); // A removal on a default query affects all queries at that location. A removal on an // indexed query, even one without other query constraints, does *not* affect all // queries at that location. So this check must be for 'default', and not // loadsAllData(). if (maybeSyncPoint != null && (query.isDefault() || maybeSyncPoint.viewExistsForQuery(query))) { // @type {{removed: !Array.<!fb.api.Query>, events: !Array.<!fb.core.view.Event>}} Pair<List<QuerySpec>, List<Event>> removedAndEvents = maybeSyncPoint.removeEventRegistration(query, eventRegistration, cancelError); if (maybeSyncPoint.isEmpty()) { syncPointTree = syncPointTree.remove(path); } List<QuerySpec> removed = removedAndEvents.getFirst(); cancelEvents = removedAndEvents.getSecond(); // We may have just removed one of many listeners and can short-circuit this whole // process. We may also not have removed a default listener, in which case all of the // descendant listeners should already be properly set up. // // Since indexed queries can shadow if they don't have other query constraints, check // for loadsAllData(), instead of isDefault(). boolean removingDefault = false; for (QuerySpec queryRemoved : removed) { persistenceManager.setQueryInactive(query); removingDefault = removingDefault || queryRemoved.loadsAllData(); } ImmutableTree<SyncPoint> currentTree = syncPointTree; boolean covered = currentTree.getValue() != null && currentTree.getValue().hasCompleteView(); for (ChildKey component : path) { currentTree = currentTree.getChild(component); covered = covered || (currentTree.getValue() != null && currentTree.getValue().hasCompleteView()); if (covered || currentTree.isEmpty()) { break; } } if (removingDefault && !covered) { ImmutableTree<SyncPoint> subtree = syncPointTree.subtree(path); // There are potentially child listeners. Determine what if any listens we need to // send before executing the removal. if (!subtree.isEmpty()) { // We need to fold over our subtree and collect the listeners to send List<View> newViews = collectDistinctViewsForSubTree(subtree); // Ok, we've collected all the listens we need. Set them up. for (View view : newViews) { ListenContainer container = new ListenContainer(view); QuerySpec newQuery = view.getQuery(); listenProvider.startListening( queryForListening(newQuery), container.tag, container, container); } } else { // There's nothing below us, so nothing we need to start listening on } } // If we removed anything and we're not covered by a higher up listen, we need to stop // listening on this query. The above block has us covered in terms of making sure // we're set up on listens lower in the tree. // Also, note that if we have a cancelError, it's already been removed at the provider // level. if (!covered && !removed.isEmpty() && cancelError == null) { // If we removed a default, then we weren't listening on any of the other queries // here. Just cancel the one default. Otherwise, we need to iterate through and // cancel each individual query if (removingDefault) { listenProvider.stopListening(queryForListening(query), null); } else { for (QuerySpec queryToRemove : removed) { Tag tag = tagForQuery(queryToRemove); assert tag != null; listenProvider.stopListening(queryForListening(queryToRemove), tag); } } } // Now, clear all of the tags we're tracking for the removed listens removeTags(removed); } else { // No-op, this listener must've been already removed } return cancelEvents; } }); }
Example #27
Source File: SyncTree.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
public KeepSyncedEventRegistration(@NotNull QuerySpec spec) { this.spec = spec; }
Example #28
Source File: SyncTree.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
@NotNull @Override public QuerySpec getQuerySpec() { return spec; }
Example #29
Source File: EventRegistration.java From firebase-admin-java with Apache License 2.0 | 4 votes |
@NotNull public abstract QuerySpec getQuerySpec();
Example #30
Source File: ChildEventRegistration.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
@NotNull @Override public QuerySpec getQuerySpec() { return spec; }