mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Instantiate decreeNode with Decree
This commit is contained in:
parent
c6fa0ddde3
commit
0cd25be408
@ -29,10 +29,14 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
public class DecreeNode {
|
public class DecreeNode {
|
||||||
private final Method method;
|
private final Method method;
|
||||||
|
private final Decree decree;
|
||||||
|
|
||||||
public DecreeNode(Method method)
|
public DecreeNode(Method method) throws DecreeInstanceException {
|
||||||
{
|
|
||||||
this.method = method;
|
this.method = method;
|
||||||
|
this.decree = method.getDeclaredAnnotation(Decree.class);
|
||||||
|
if (decree == null){
|
||||||
|
throw new DecreeInstanceException("Cannot instantiate DecreeNode on method not annotated by @Decree");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,32 +61,28 @@ public class DecreeNode {
|
|||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
Decree p = method.getDeclaredAnnotation(Decree.class);
|
return decree.name().equals(Decree.METHOD_NAME) ? method.getName() : decree.name();
|
||||||
return p == null || p.name().equals(Decree.METHOD_NAME) ? method.getName() : p.name();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DecreeOrigin getOrigin()
|
public DecreeOrigin getOrigin()
|
||||||
{
|
{
|
||||||
Decree p = method.getDeclaredAnnotation(Decree.class);
|
return decree.origin();
|
||||||
return p == null ? DecreeOrigin.BOTH : p.origin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
Decree p = method.getDeclaredAnnotation(Decree.class);
|
return decree.description().isEmpty() ? Decree.DEFAULT_DESCRIPTION : decree.description();
|
||||||
return p != null ? p.description() : Decree.DEFAULT_DESCRIPTION;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<String> getAliases()
|
public KList<String> getAliases()
|
||||||
{
|
{
|
||||||
Decree p = method.getDeclaredAnnotation(Decree.class);
|
|
||||||
KList<String> d = new KList<>();
|
KList<String> d = new KList<>();
|
||||||
|
|
||||||
if (p == null || Arrays.equals(p.aliases(), new String[]{Decree.NO_ALIASES})){
|
if (Arrays.equals(decree.aliases(), new String[]{Decree.NO_ALIASES})){
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String i : p.aliases())
|
for(String i : decree.aliases())
|
||||||
{
|
{
|
||||||
if(i.isEmpty())
|
if(i.isEmpty())
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user