projects
/
rhynodge.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
90db6d6
)
Add display name to chains and reactions.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Mon, 7 Jan 2013 09:20:31 +0000
(10:20 +0100)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Mon, 7 Jan 2013 09:20:31 +0000
(10:20 +0100)
src/main/java/net/pterodactylus/reactor/Reaction.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/reactor/loader/Chain.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/reactor/loader/ReactionLoader.java
patch
|
blob
|
history
src/main/resources/chains/kickasstorrents-example.json
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/reactor/Reaction.java
b/src/main/java/net/pterodactylus/reactor/Reaction.java
index
59fad8f
..
65a637b
100644
(file)
--- a/
src/main/java/net/pterodactylus/reactor/Reaction.java
+++ b/
src/main/java/net/pterodactylus/reactor/Reaction.java
@@
-30,6
+30,9
@@
import com.google.common.collect.Lists;
*/
public class Reaction {
*/
public class Reaction {
+ /** The name of this reaction. */
+ private final String name;
+
/** The query to run. */
private final Query query;
/** The query to run. */
private final Query query;
@@
-48,6
+51,8
@@
public class Reaction {
/**
* Creates a new reaction.
*
/**
* Creates a new reaction.
*
+ * @param name
+ * The name of the reaction
* @param query
* The query to run
* @param trigger
* @param query
* The query to run
* @param trigger
@@
-55,13
+60,15
@@
public class Reaction {
* @param action
* The action to perform
*/
* @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.
*
}
/**
* Creates a new reaction.
*
+ * @param name
+ * The name of the reaction
* @param query
* The query to run
* @param filters
* @param query
* The query to run
* @param filters
@@
-71,7
+78,8
@@
public class Reaction {
* @param action
* The action to perform
*/
* @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;
this.query = query;
this.filters.addAll(filters);
this.trigger = trigger;
@@
-83,6
+91,16
@@
public class Reaction {
//
/**
//
/**
+ * 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
* Returns the query to run.
*
* @return The query to run
diff --git
a/src/main/java/net/pterodactylus/reactor/loader/Chain.java
b/src/main/java/net/pterodactylus/reactor/loader/Chain.java
index
c367da0
..
8c98e50
100644
(file)
--- a/
src/main/java/net/pterodactylus/reactor/loader/Chain.java
+++ b/
src/main/java/net/pterodactylus/reactor/loader/Chain.java
@@
-168,6
+168,10
@@
public class Chain {
@JsonProperty
private boolean enabled;
@JsonProperty
private boolean enabled;
+ /** The name of the chain. */
+ @JsonProperty
+ private String name;
+
/** The query of the chain. */
@JsonProperty
private Part query;
/** The query of the chain. */
@JsonProperty
private Part query;
@@
-198,6
+202,15
@@
public class Chain {
}
/**
}
/**
+ * 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
* Returns the query of this chain.
*
* @return The query of this chain
@@
-252,6
+265,7
@@
public class Chain {
@Override
public int hashCode() {
int hashCode = 0;
@Override
public int hashCode() {
int hashCode = 0;
+ hashCode ^= name.hashCode();
hashCode ^= query.hashCode();
for (Part filter : filters) {
hashCode ^= filter.hashCode();
hashCode ^= query.hashCode();
for (Part filter : filters) {
hashCode ^= filter.hashCode();
@@
-271,6
+285,9
@@
public class Chain {
return false;
}
Chain chain = (Chain) object;
return false;
}
Chain chain = (Chain) object;
+ if (!name.equals(chain.name)) {
+ return false;
+ }
if (!query.equals(chain.query)) {
return false;
}
if (!query.equals(chain.query)) {
return false;
}
diff --git
a/src/main/java/net/pterodactylus/reactor/loader/ReactionLoader.java
b/src/main/java/net/pterodactylus/reactor/loader/ReactionLoader.java
index
7016edb
..
a2c29aa
100644
(file)
--- a/
src/main/java/net/pterodactylus/reactor/loader/ReactionLoader.java
+++ b/
src/main/java/net/pterodactylus/reactor/loader/ReactionLoader.java
@@
-70,7
+70,7
@@
public class ReactionLoader {
/* create action. */
Action action = createObject(chain.action().name(), "net.pterodactylus.reactor.actions", extractParameters(chain.action().parameters()));
/* 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()));
}
//
}
//
diff --git
a/src/main/resources/chains/kickasstorrents-example.json
b/src/main/resources/chains/kickasstorrents-example.json
index
1473458
..
71125d7
100644
(file)
--- a/
src/main/resources/chains/kickasstorrents-example.json
+++ b/
src/main/resources/chains/kickasstorrents-example.json
@@
-1,5
+1,6
@@
{
"enabled": false,
{
"enabled": false,
+ "name": "Example Reaction",
"query":
{
"query":
{