BrightSide Workbench Full Report + Source Code
Notifications.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2017 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.action.queue;
20 
21 import java.util.Collection;
22 import java.util.TreeSet;
23 import org.turro.annotation.ElephantNotification;
24 import org.turro.reflection.Instances;
25 
30 public class Notifications {
31 
32  public static Collection<NotificationCategory> getCategories() {
33  TreeSet<NotificationCategory> set = new TreeSet<>(new NotificationCategoryComparator());
34  for(IElephantNotification notification : Instances.cached().byAnnotation(ElephantNotification.class, IElephantNotification.class)) {
35  set.addAll(notification.getCategories());
36  }
37  return set;
38  }
39 
40  public static Collection<NotificationCategory> getAllCategories() {
41  TreeSet<NotificationCategory> set = new TreeSet<>(new NotificationCategoryComparator());
42  for(IElephantNotification notification : Instances.cached().byAnnotation(ElephantNotification.class, IElephantNotification.class)) {
43  set.addAll(notification.getAllCategories());
44  }
45  return set;
46  }
47 
48  public static NotificationCategory getCategory(String id) {
49  for(IElephantNotification notification : Instances.cached().byAnnotation(ElephantNotification.class, IElephantNotification.class)) {
50  NotificationCategory nc = notification.getCategory(id);
51  if(nc != null) return nc;
52  }
53  return null;
54  }
55 
56  public static void reset() {
57  for(IElephantNotification notification : Instances.cached().byAnnotation(ElephantNotification.class, IElephantNotification.class)) {
58  notification.reset();
59  }
60  }
61 
62  private Notifications() {
63  }
64 
65 }
static NotificationCategory getCategory(String id)
static Collection< NotificationCategory > getCategories()
static Collection< NotificationCategory > getAllCategories()