*/
public class Reaction {
+ /** The name of this reaction. */
+ private final String name;
+
/** The query to run. */
private final Query query;
/**
* Creates a new reaction.
*
+ * @param name
+ * The name of the reaction
* @param query
* The query to run
* @param trigger
* @param action
* The action to perform
*/
- public Reaction(Query query, Trigger trigger, Action action) {
- this(query, Collections.<Filter> emptyList(), trigger, action);
+ public Reaction(String name, Query query, Trigger trigger, Action action) {
+ this(name, query, Collections.<Filter> emptyList(), trigger, action);
}
/**
* Creates a new reaction.
*
+ * @param name
+ * The name of the reaction
* @param query
* The query to run
* @param filters
* @param action
* The action to perform
*/
- public Reaction(Query query, List<Filter> filters, Trigger trigger, Action action) {
+ public Reaction(String name, Query query, List<Filter> filters, Trigger trigger, Action action) {
+ this.name = name;
this.query = query;
this.filters.addAll(filters);
this.trigger = trigger;
//
/**
+ * Returns the name of this reaction. This name is solely used for display
+ * purposes and does not need to be unique.
+ *
+ * @return The name of this reaction
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
* Returns the query to run.
*
* @return The query to run
@JsonProperty
private boolean enabled;
+ /** The name of the chain. */
+ @JsonProperty
+ private String name;
+
/** The query of the chain. */
@JsonProperty
private Part query;
}
/**
+ * Returns the name of the chain.
+ *
+ * @return The name of the chain
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
* Returns the query of this chain.
*
* @return The query of this chain
@Override
public int hashCode() {
int hashCode = 0;
+ hashCode ^= name.hashCode();
hashCode ^= query.hashCode();
for (Part filter : filters) {
hashCode ^= filter.hashCode();
return false;
}
Chain chain = (Chain) object;
+ if (!name.equals(chain.name)) {
+ return false;
+ }
if (!query.equals(chain.query)) {
return false;
}
/* create action. */
Action action = createObject(chain.action().name(), "net.pterodactylus.reactor.actions", extractParameters(chain.action().parameters()));
- return new Reaction(query, filters, trigger, action).setUpdateInterval(TimeUnit.SECONDS.toMillis(chain.updateInterval()));
+ return new Reaction(chain.name(), query, filters, trigger, action).setUpdateInterval(TimeUnit.SECONDS.toMillis(chain.updateInterval()));
}
//