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      /**
20       * The value to expect when expansion is performed.
21       */
22      public static final ImmutableList<String> SELF_EXPANDING_STRINGS = ImmutableList.of("one", "two");
23  
24      /**
25       * An expandable field. Will get expanded by the framework if requested.
26       */
27      @XmlAttribute
28      private List<String> selfExpanding = Lists.newArrayList();
29  
30      /**
31       * This expander takes care of populating the selfExpanding field when requested.
32       */
33      @Expandable ("selfExpanding")
34      @XmlTransient
35      private SelfExpanding selfExpandingExpander = new SelfExpanding()
36      {
37          public void expand()
38          {
39              selfExpanding = Lists.newArrayList(SELF_EXPANDING_STRINGS);
40          }
41      };
42  
43      public Expand()
44      {
45          // empty
46      }
47  
48      public List<String> getSelfExpanding()
49      {
50          return selfExpanding;
51      }
52  }