package cz.moneta.test.harness.support.web;

import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Select annotation is used for pick {@link #value()} from select (list of values) by String or int or long text parameter.
 * String parameter is used for identify element by its text and int is used for searching by select value.<br>
 * String/int parameter type is mandatory. IllegalStateException is thrown if not added.<br>
 * This annotation does not support dynamic path construction.<br>
 *
 * <u>Example:</u>
 * <pre>
 *         {@literal @}Select (SOME_VALUE)
 *          SomePage selectSomeValue(String text);
 *    </pre>
 * <u>Example2:</u>
 * <pre>
 *         {@literal @}Select (SOME_VALUE)
 *          SomePage selectSomeValue(int selectValue);
 *    </pre>
 * <u>Example3:</u>
 * <pre>
 *         {@literal @}Select (SOME_VALUE)
 *           SomePage selectSomeValue(long selectValue);
 *    </pre>
 * {@link #by()} could be used for other then default type of element search.<br>
 * <u>Example4:</u><br>
 * <pre>
 *         {@literal @}Select {
 *               value = SOME_XPATH,
 *               by = Lookup.XPATH,
 *          )
 *          SomePage selectSomeValue(String text);
 *    </pre>
 * {@link #selectByOrder()} set true when you need select option by its order in select tag. Int parameter must
 * be added in method.<br>
 * <u>Example5:</u><br>
 * <pre>
 *          selectSomeValue(1); //this will select first option in select with identificator 'SOME_VALUE'
 *
 *         {@literal @}Select {
 *               value = SOME_VALUE,
 *               selectByOptionOrder = true,
 *          )
 *          SomePage selectSomeValue(int optionOrder);
 *    </pre>
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(Selects.class)
public @interface Select {
    /**
     * Value for element identification.
     */
    String value();

    /**
     * Type of element identification which will be used for element search. XPATH, ID or DEFAULT can be used.
     *
     * @see Lookup
     */
    Lookup by() default Lookup.DEFAULT;

    /**
     * Wait for element show after select. Use {@literal @}{@link Wait} annotation. Tool is not waiting for any element by default.
     */
    Wait andWait() default @Wait;

    /**
     * Select option in select by its order if set true. This annotation needs int parameter in method.
     */
    boolean selectByOrder() default false;
}
