View Javadoc
1   /*
2    * Copyright 2016 Function1. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package tools.gsf.facade.assetapi.asset;
18  
19  
20  import java.lang.annotation.ElementType;
21  import java.lang.annotation.Retention;
22  import java.lang.annotation.RetentionPolicy;
23  import java.lang.annotation.Target;
24  
25  /**
26   * Annotation to read the current asset from the ICS context along with the specified attribute values,
27   * then inject the resulting object onto the annotated field. 
28   *
29   * Usage:
30   * 
31   *         "@CurrentAsset(attributes={"title", "body", "headline"}) TemplateAsset currentTemplateAsset;"
32   *
33   *         or
34   *         
35   *         "@CurrentAsset(attributes={"title", "body", "headline"}) ScatteredAsset currentScatteredAsset;"
36   *
37   *         or
38   *         
39   *         "@CurrentAsset(attributes={"title", "body", "headline"}) AssetData currentAssetData;"
40   *
41   * VERY IMPORTANT: in Groovy, arrays are enclosed inside [], not {}. Using {} will throw a compilation error.
42   *
43   * @author Tony Field
44   * @since 2016-08-24
45   */
46  @Retention(RetentionPolicy.RUNTIME)
47  @Target(ElementType.FIELD)
48  public @interface CurrentAsset {
49  
50      String[] attributes() default {"name"};
51  
52  }