BrightSide Workbench Full Report + Source Code
NotificationCategory.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.EnumSet;
22 import java.util.Set;
23 import org.turro.plugin.contacts.IContact;
24 
29 public class NotificationCategory {
30 
31  private final String idCategory, category, description;
32  private final EnumSet<QueuePeriod> allowedPeriods;
33  private final boolean unique, publishable;
34  private final QueuePeriod defaultPeriod;
35  private final IElephantNotification notification;
36  private final NotificationRole role;
37  private final NotificationConstraintSet constraints;
38 
39  public NotificationCategory(String idCategory, String category,
40  String description, EnumSet<QueuePeriod> allowedPeriods,
41  boolean unique, QueuePeriod defaultPeriod,
42  IElephantNotification notification, NotificationRole role,
43  Set<NotificationConstraint> constraints, boolean publishable) {
44  this.idCategory = idCategory;
45  this.category = category;
46  this.description = description;
47  this.allowedPeriods = allowedPeriods;
48  this.unique = unique;
49  this.defaultPeriod = defaultPeriod;
50  this.notification = notification;
51  this.role = role;
52  this.constraints = new NotificationConstraintSet(constraints);
53  this.publishable = publishable;
54  }
55 
56  public String getIdCategory() {
57  return idCategory;
58  }
59 
60  public String getCategory() {
61  return category;
62  }
63 
64  public String getDescription() {
65  return description;
66  }
67 
68  public EnumSet<QueuePeriod> getAllowedPeriods() {
69  return allowedPeriods;
70  }
71 
72  public boolean isUnique() {
73  return unique;
74  }
75 
77  return defaultPeriod;
78  }
79 
81  return notification;
82  }
83 
85  return role;
86  }
87 
88  public boolean isPublishable() {
89  return publishable;
90  }
91 
93  return constraints;
94  }
95 
96  public boolean isValid(IContact contact) {
97  return contact != null && contact.isValid() && contact.isWebUser();
98  }
99 
100  public boolean strongBond(ConstraintKeys keys) {
101  return constraints.strongBond(keys);
102  }
103 
104  public boolean wideBond(ConstraintKeys keys) {
105  return (constraints.isEmpty() && !isPublishable()) ? false : constraints.wideBond(keys);
106  }
107 
108 }
NotificationCategory(String idCategory, String category, String description, EnumSet< QueuePeriod > allowedPeriods, boolean unique, QueuePeriod defaultPeriod, IElephantNotification notification, NotificationRole role, Set< NotificationConstraint > constraints, boolean publishable)