View Javadoc

1   package com.atlassian.plugins.rest.expand;
2   
3   import com.atlassian.plugins.rest.common.expand.Expandable;
4   import com.atlassian.plugins.rest.common.expand.SelfExpanding;
5   import com.google.common.collect.ImmutableList;
6   import com.google.common.collect.Lists;
7   
8   import java.util.List;
9   import javax.xml.bind.annotation.XmlAttribute;
10  import javax.xml.bind.annotation.XmlRootElement;
11  import javax.xml.bind.annotation.XmlTransient;
12  
13  /**
14   * Representation bean used to test expando stuff.
15   */
16  @XmlRootElement(name = "expand")
17  public class Expand {
18      /**
19       * The value to expect when expansion is performed.
20       */
21      public static final ImmutableList<String> SELF_EXPANDING_STRINGS = ImmutableList.of("one", "two");
22  
23      /**
24       * An expandable field. Will get expanded by the framework if requested.
25       */
26      @XmlAttribute
27      private List<String> selfExpanding = Lists.newArrayList();
28  
29      /**
30       * This expander takes care of populating the selfExpanding field when requested.
31       */
32      @Expandable("selfExpanding")
33      @XmlTransient
34      private SelfExpanding selfExpandingExpander = new SelfExpanding() {
35          public void expand() {
36              selfExpanding = Lists.newArrayList(SELF_EXPANDING_STRINGS);
37          }
38      };
39  
40      public Expand() {
41          // empty
42      }
43  
44      public List<String> getSelfExpanding() {
45          return selfExpanding;
46      }
47  }