1 /* 2 * This file is part of hyphenType. hyphenType is free software: you can 3 * redistribute it and/or modify it under the terms of the GNU General Public 4 * License as published by the Free Software Foundation, either version 3 of the 5 * License, or (at your option) any later version. hyphenType is distributed in 6 * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 7 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 8 * the GNU General Public License for more details. You should have received a 9 * copy of the GNU General Public License along with hyphenType. If not, see 10 * <http://www.gnu.org/licenses/>. 11 */ 12 package org.hyphenType.datastructure.annotations; 13 14 import java.lang.annotation.ElementType; 15 import java.lang.annotation.Retention; 16 import java.lang.annotation.RetentionPolicy; 17 import java.lang.annotation.Target; 18 19 /** 20 * @author Aurelio Akira M. Matsui 21 */ 22 @Retention(RetentionPolicy.RUNTIME) 23 @Target(ElementType.METHOD) 24 public @interface OptionArgument { 25 26 String name() default ""; 27 28 String option(); 29 30 31 /** 32 * The index of this option argument. Each option argument 33 * should have a <strong>unique</strong> index. Indexes should 34 * be a sequence in the form 0, 1, ...<br> 35 * <br> 36 * This property has 0 as the default value to keep the code 37 * clean when there is only one argument.<br> 38 * <br> 39 * But it is not advisable to omit the index when using more than 40 * one option argument since it is harder to read. This is a 41 * counter example:<br> 42 * <code><pre> 43 * @OptionArgument(option="a") 44 * String arg1(); 45 * 46 * @OptionArgument(option="a", index=1) 47 * String arg2(); 48 * </pre></code> 49 * The following is more readable:<br> 50 * <code><pre> 51 * @OptionArgument(option="a", index=0) 52 * String arg1(); 53 * 54 * @OptionArgument(option="a", index=1) 55 * String arg2(); 56 * </pre></code> 57 * 58 * @return The index of this option argument. 59 */ 60 int index() default 0; 61 62 /** 63 * Regular expression that a string should match in order to be accepted as 64 * this argument. Default value will accept anything that does not start 65 * with a single or a double hyphen. When you write a regex, you can refer 66 * to the single hyphen as \h and the double hyphen as \H. Therefore, the 67 * default regex is "[^\Q\h\E&^\Q\H\E].*".<br/> 68 * <br/> 69 * Note that single and double hyphens are, respectively, the strings "-" 70 * and "--", but these strings can be changed through the properties 71 * {@link ArgumentsObject#singleHyphen()} and 72 * {@link ArgumentsObject#doubleHyphen()}. 73 */ 74 String regex() default "[^\\Q\\h\\E&^\\Q\\H\\E].*"; 75 76 InputChannel[] channels() default InputChannel.ARGUMENT; 77 78 boolean mandatory() default false; 79 80 String description() default ""; 81 }