001/*
002 * Copyright 2006 - 2013
003 *     Stefan Balev     <stefan.balev@graphstream-project.org>
004 *     Julien Baudry    <julien.baudry@graphstream-project.org>
005 *     Antoine Dutot    <antoine.dutot@graphstream-project.org>
006 *     Yoann Pigné      <yoann.pigne@graphstream-project.org>
007 *     Guilhelm Savin   <guilhelm.savin@graphstream-project.org>
008 * 
009 * This file is part of GraphStream <http://graphstream-project.org>.
010 * 
011 * GraphStream is a library whose purpose is to handle static or dynamic
012 * graph, create them from scratch, file or any source and display them.
013 * 
014 * This program is free software distributed under the terms of two licenses, the
015 * CeCILL-C license that fits European law, and the GNU Lesser General Public
016 * License. You can  use, modify and/ or redistribute the software under the terms
017 * of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
018 * URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by
019 * the Free Software Foundation, either version 3 of the License, or (at your
020 * option) any later version.
021 * 
022 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
023 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
024 * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
025 * 
026 * You should have received a copy of the GNU Lesser General Public License
027 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
028 * 
029 * The fact that you are presently reading this means that you have had
030 * knowledge of the CeCILL-C and LGPL licenses and that you accept their terms.
031 */
032package org.graphstream.algorithm;
033
034import java.lang.annotation.Documented;
035import java.lang.annotation.ElementType;
036import java.lang.annotation.Retention;
037import java.lang.annotation.RetentionPolicy;
038import java.lang.annotation.Target;
039
040/**
041 * Annotation allowing to define parameters in algorithm.
042 * 
043 * @author Guilhelm Savin
044 * 
045 */
046@Documented
047@Target(ElementType.FIELD)
048@Retention(RetentionPolicy.RUNTIME)
049public @interface DefineParameter {
050        /**
051         * Name of the parameter.
052         */
053        String name();
054
055        /**
056         * Description of the parameter.
057         */
058        String description() default "";
059
060        /**
061         * Minimum value used for number parameter.
062         */
063        double min() default Double.NaN;
064
065        /**
066         * Maximum value used for number parameter.
067         */
068        double max() default Double.NaN;
069
070        /**
071         * Class of the parameter.
072         */
073        Class<?> type() default Object.class;
074
075        /**
076         * For String parameters, this allows to define a restricted set of values
077         * for the parameter.
078         */
079        String[] strings() default {};
080
081        /**
082         * Defines name of a function to call before setting the value of the
083         * parameter. If argument count of the function is zero, then the function
084         * will not receive argument. Else, if one argument is needed, the function
085         * will receive the value of parameter, if two arguments are needed, the
086         * function will receive the name of the parameter as a String and the
087         * value.
088         */
089        String beforeSet() default "";
090
091        /**
092         * Defines name of a function to call after setting the value of the
093         * parameter. If argument count of the function is zero, then the function
094         * will not receive argument. Else, if one argument is needed, the function
095         * will receive the value of parameter, if two arguments are needed, the
096         * function will receive the name of the parameter as a String and the
097         * value.
098         */
099        String afterSet() default "";
100
101        /**
102         * Defines name of a function to call to set the value of the parameter. If
103         * one argument is needed, the function will receive the value of parameter,
104         * if two arguments are needed, the function will receive the name of the
105         * parameter as a String and the value.
106         */
107        String setter() default "";
108
109        /**
110         * Defines the priority of the parameter. This is not yet implemented.
111         */
112        int priority() default 0;
113
114        /**
115         * Defines if the parameter is optional. This is used to throw a
116         * MissingParameterException during an initialization step to be sure that
117         * core parameters are present.
118         */
119        boolean optional() default true;
120}