1 | package eu.clarin.sru.server.fcs.utils; |
---|
2 | |
---|
3 | import java.net.URI; |
---|
4 | import java.util.Collections; |
---|
5 | import java.util.List; |
---|
6 | |
---|
7 | import eu.clarin.sru.server.fcs.DataView; |
---|
8 | import eu.clarin.sru.server.fcs.EndpointDescription; |
---|
9 | |
---|
10 | |
---|
11 | /** |
---|
12 | * An abstract base class for implementing endpoint descriptions. It already |
---|
13 | * implements the methods required for capabilities and supported dataviews. |
---|
14 | * |
---|
15 | * @see EndpointDescription |
---|
16 | * |
---|
17 | */ |
---|
18 | public abstract class AbstractEndpointDescriptionBase implements EndpointDescription { |
---|
19 | protected final List<URI> capabilities; |
---|
20 | protected final List<DataView> supportedDataViews; |
---|
21 | |
---|
22 | /** |
---|
23 | * Constructor. |
---|
24 | * |
---|
25 | * @param capabilities |
---|
26 | * a list of capabilities supported by this endpoint |
---|
27 | * @param supportedDataViews |
---|
28 | * a list of data views that are supported by this endpoint |
---|
29 | */ |
---|
30 | protected AbstractEndpointDescriptionBase(List<URI> capabilities, |
---|
31 | List<DataView> supportedDataViews) { |
---|
32 | if (capabilities == null) { |
---|
33 | throw new NullPointerException("capabilities == null"); |
---|
34 | } |
---|
35 | if (capabilities.isEmpty()) { |
---|
36 | throw new IllegalArgumentException("capabilities are empty"); |
---|
37 | } |
---|
38 | this.capabilities = Collections.unmodifiableList(capabilities); |
---|
39 | |
---|
40 | if (supportedDataViews == null) { |
---|
41 | throw new NullPointerException("supportedDataViews == null"); |
---|
42 | } |
---|
43 | if (supportedDataViews.isEmpty()) { |
---|
44 | throw new IllegalArgumentException("supportedDataViews are empty"); |
---|
45 | } |
---|
46 | this.supportedDataViews = |
---|
47 | Collections.unmodifiableList(supportedDataViews); |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | @Override |
---|
52 | public List<URI> getCapabilities() { |
---|
53 | return capabilities; |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | @Override |
---|
58 | public List<DataView> getSupportedDataViews() { |
---|
59 | return supportedDataViews; |
---|
60 | } |
---|
61 | |
---|
62 | } // abstract class EndpointDescriptionBase |
---|