summaryrefslogtreecommitdiffstats
path: root/args4j/args4j/src/org/kohsuke/args4j/spi/AnnotationImpl.java
blob: bd1a2eca1ff0de9b74e6a1c49ea1a6c2b3d7e2d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package org.kohsuke.args4j.spi;

import java.lang.annotation.Annotation;


/**
 * Base class for the @Option and @Argument implementation classes.
 * @author Jan Materne
 */
public abstract class AnnotationImpl implements Annotation {
    private final Class<? extends Annotation> annotationType;

    protected AnnotationImpl(Class<? extends Annotation> annotationType) {
        this.annotationType = annotationType;
    }

    protected AnnotationImpl(Class<? extends Annotation> annotationType, ConfigElement ce) throws ClassNotFoundException {
        this(annotationType);

		aliases = ce.aliases != null ? ce.aliases : new String[0];
		if (ce.handler != null) {
			handler = (Class<? extends OptionHandler>) Class.forName(ce.handler);
		} else {
			handler = OptionHandler.class;
		}
		metaVar = ce.metavar != null ? ce.metavar : "";
		multiValued = ce.multiValued;
		required = ce.required;
		usage = ce.usage != null ? ce.usage : "";
	}

	public String[] aliases;
	public String[] aliases() {
		return aliases;
	}
	public Class<? extends OptionHandler> handler;
	public Class<? extends OptionHandler> handler() {
		return handler;
	}
	public String metaVar;
	public String metaVar() {
		return metaVar;
	}
	public boolean multiValued;
	public boolean multiValued() {
		return multiValued;
	}
	public boolean required;
	public boolean required() {
		return required;
	}
	public String usage;
	public String usage() {
		return usage;
	}
	public Class<? extends Annotation> annotationType() {
		return annotationType;
	}
	public int index;
	public int index() {
		return index;
	}
}