    001// Licensed under the Apache License, Version 2.0 (the "License");
    002// you may not use this file except in compliance with the License.
    003// You may obtain a copy of the License at
    004//
    005//     http://www.apache.org/licenses/LICENSE-2.0
    006//
    007// Unless required by applicable law or agreed to in writing, software
    008// distributed under the License is distributed on an "AS IS" BASIS,
    009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    010// See the License for the specific language governing permissions and
    011// limitations under the License.
    012
    013package org.apache.tapestry5.ioc.annotations;
    014
    015import java.lang.annotation.Documented;
    016import java.lang.annotation.Retention;
    017import java.lang.annotation.Target;
    018
    019import static java.lang.annotation.ElementType.FIELD;
    020import static java.lang.annotation.ElementType.PARAMETER;
    021import static java.lang.annotation.RetentionPolicy.RUNTIME;
    022import static org.apache.tapestry5.ioc.annotations.AnnotationUseContext.*;
    023
    024/**
    025 * Used to inject a symbol value, via a symbol name. This is used much like {@link
    026 * org.apache.tapestry5.ioc.annotations.Value} annotation, except that symbols are not expanded ... the entire value is
    027 * a symbol name. This allows the annotation to reference a public constant variable.
    028 *
    029 *
    030 * The injected value may be coerced from string to an alternate type (defined by the field or parameter to which
    031 * the @Symbol annotation is attached). For better control, use the {@link IntermediateType} annotation as well, which
    032 * allows the string to be coerced to an alternate type before being coerced a second time to the field or parameter type.
    033 */
    034@Target(
    035        {PARAMETER, FIELD})
    036@Retention(RUNTIME)
    037@Documented
    038@UseWith({COMPONENT, MIXIN, PAGE, SERVICE})
    039public @interface Symbol
    040{
    041    /**
    042     * The name of the symbol to inject.
    043     */
    044    String value();
    045}