com.day.cq.wcm.models.annotations.injectorspecific.StyleOrValueMapValue Maven / Gradle / Ivy
/*******************************************************************************
*
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2017 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
******************************************************************************/
package com.day.cq.wcm.models.annotations.injectorspecific;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import org.apache.sling.models.annotations.Source;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.spi.injectorspecific.InjectAnnotation;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Annotation to be used on either methods, fields or constructor parameter to let Sling Models
* inject a value from the current {@link com.day.cq.wcm.api.designer.Style} or {@link org.apache.sling.api.resource.ValueMap}.
* Per default, if the value is present in the style and the value map, the value form current value map will be injected
* See {@link StyleOrValueMapValue#preferStyleValues} to change this behaviour.
*/
@Target({ METHOD, FIELD, PARAMETER })
@Retention(RUNTIME)
@InjectAnnotation
@Source("stylevaluemap")
public @interface StyleOrValueMapValue {
/**
* Specifies the name of the value from the current style or value map to take.
* If empty, then the name is derived from the method or field.
* @return {@link String} name of the injector
*/
String name() default "";
/**
* if set to REQUIRED injection is mandatory, if set to OPTIONAL injection is optional, in case of DEFAULT
* the standard annotations ({@link org.apache.sling.models.annotations.Optional}, {@link org.apache.sling.models.annotations.Required}) are used.
* If even those are not available the default injection strategy defined on the {@link org.apache.sling.models.annotations.Model} applies.
* Default value = DEFAULT.
* @return {@link InjectionStrategy} injection strategy
*/
InjectionStrategy injectionStrategy() default InjectionStrategy.DEFAULT;
/**
* If set to {true} the value from the current style will be injected in favor of the value from the current value map.
* @return true
if current style values will be used
*/
boolean preferStyleValues() default false;
}