View Javadoc

1   package com.atlassian.marketplace.client.model;
2   
3   import java.net.URI;
4   import java.util.Map;
5   
6   import com.atlassian.fugue.Option;
7   import com.atlassian.marketplace.client.api.AddonExternalLinkType;
8   
9   import com.google.common.collect.ImmutableList;
10  
11  import static com.atlassian.fugue.Option.none;
12  import static com.atlassian.fugue.Option.option;
13  import static com.atlassian.marketplace.client.model.Links.WEB_TYPE;
14  
15  /**
16   * Information about an add-on. Includes all the properties of {@link AddonBase}, but adds
17   * further details; to get these details, you will need to query the add-on individually
18   * with {@link com.atlassian.marketplace.client.api.Addons#getByKey}. 
19   * <p>
20   * To construct a new instance of this class in order to create or update an add-on, use
21   * {@link ModelBuilders#addon()}.
22   * 
23   * @see com.atlassian.marketplace.client.api.Addons
24   * @see AddonSummary
25   * @since 2.0.0
26   */
27  public class Addon extends AddonBase
28  {
29      Embedded _embedded;
30      Option<Boolean> enableAtlassianAnswers;
31      Map<String, URI> vendorLinks;
32      @ReadOnly Option<LegacyProperties> legacy;
33      
34      /**
35       * The add-on banner image. This is not displayed on Marketplace, but may appear in UPM.
36       * @see ModelBuilders.AddonBuilder#banner
37       */
38      public Option<ImageInfo> getBanner()
39      {
40          return _embedded.banner;
41      }
42  
43      @Override
44      public Option<ImageInfo> getLogo()
45      {
46          return _embedded.logo;
47      }
48      
49      @Override
50      public Iterable<AddonCategorySummary> getCategories()
51      {
52          return _embedded.categories;
53      }
54  
55      @Override
56      public AddonDistributionSummary getDistribution()
57      {
58          return _embedded.distribution;
59      }
60  
61      @Override
62      public AddonReviewsSummary getReviews()
63      {
64          return _embedded.reviews;
65      }
66  
67      @Override
68      public Option<VendorSummary> getVendor()
69      {
70          return _embedded.vendor;
71      }
72  
73      /**
74       * Details of one of the add-on's versions. This will be present if 1. you have requested
75       * it in an add-on query (see {@link com.atlassian.marketplace.client.api.AddonQuery.Builder#withVersion(boolean)}),
76       * in which case it will be the latest available version that matches whatever criteria you have specified;
77       * or 2. you have constructed it yourself because you are creating a new add-on
78       * (see {@link ModelBuilders.AddonBuilder#version}).
79       */
80      public Option<AddonVersion> getVersion()
81      {
82          return _embedded.version;
83      }
84  
85      /**
86       * The address of a Marketplace page that describes the add-on's support details.
87       */
88      public Option<URI> getSupportDetailsPageUri()
89      {
90          return getLinks().getUri("support", WEB_TYPE);
91      }
92  
93      /**
94       * A description of the add-on that can be longer than {@link AddonBase#getSummary()}
95       * and can include some limited HTML markup. This is no longer supported for new add-on
96       * listings, but may be present for older ones. 
97       */
98      public Option<HtmlString> getDescription()
99      {
100         for (LegacyProperties l: legacy)
101         {
102             return l.description;
103         }
104         return none();
105     }
106     
107     /**
108      * Returns one of the optional vendor-specified external links for the add-on.
109      * @param type specifies which type of link to get
110      * @return the link URI, or {@link Option#none()} if there is no such link
111      */
112     public Option<URI> getExternalLinkUri(AddonExternalLinkType type)
113     {
114         if (type.canSetForNewAddons())
115         {
116             return option(vendorLinks.get(type.getKey()));
117         }
118         else
119         {
120             for (LegacyProperties l: legacy)
121             {
122                 return option(l.vendorLinks.get(type.getKey()));
123             }
124             return none();
125         }
126     }
127     
128     /**
129      * True if Marketplace should provide a link to an Atlassian Answers tag devoted to this add-on.
130      * Can be omitted for private add-ons.
131      */
132     public Option<Boolean> isEnableAtlassianAnswers()
133     {
134         return enableAtlassianAnswers;
135     }
136     
137     static final class Embedded
138     {
139         Option<ImageInfo> banner;
140         Option<ImageInfo> logo;
141         ImmutableList<AddonCategorySummary> categories;
142         AddonDistributionSummary distribution;
143         AddonReviewsSummary reviews;
144         Option<VendorSummary> vendor;
145         Option<AddonVersion> version;
146     }
147 
148     static final class LegacyProperties
149     {
150         Option<HtmlString> description;
151         Map<String, URI> vendorLinks;
152     }
153 }