source: FCSSimpleEndpoint/trunk/src/main/java/eu/clarin/sru/server/fcs/utils/AbstractEndpointDescriptionBase.java @ 6935

Last change on this file since 6935 was 6935, checked in by Oliver Schonefeld, 8 years ago
  • update/add copyright
  • fix typo in class name
  • minor changes
  • Property svn:eol-style set to native
File size: 3.6 KB
Line 
1/**
2 * This software is copyright (c) 2013-2016 by
3 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
4 * This is free software. You can redistribute it
5 * and/or modify it under the terms described in
6 * the GNU General Public License v3 of which you
7 * should have received a copy. Otherwise you can download
8 * it from
9 *
10 *   http://www.gnu.org/licenses/gpl-3.0.txt
11 *
12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
13 *
14 * @license http://www.gnu.org/licenses/gpl-3.0.txt
15 *  GNU General Public License v3
16 */
17package eu.clarin.sru.server.fcs.utils;
18
19import java.net.URI;
20import java.util.Collections;
21import java.util.List;
22
23import eu.clarin.sru.server.fcs.DataView;
24import eu.clarin.sru.server.fcs.EndpointDescription;
25import eu.clarin.sru.server.fcs.Layer;
26
27
28/**
29 * An abstract base class for implementing endpoint descriptions. It already
30 * implements the methods required for capabilities and supported data views.
31 *
32 * @see EndpointDescription
33 *
34 */
35public abstract class AbstractEndpointDescriptionBase implements EndpointDescription {
36    protected final List<URI> capabilities;
37    protected final List<DataView> supportedDataViews;
38    protected final List<Layer> supportedLayers;
39
40
41    /**
42     * Constructor.
43     *
44     * @param capabilities
45     *            a list of capabilities supported by this endpoint
46     * @param supportedDataViews
47     *            a list of data views that are supported by this endpoint
48     */
49    protected AbstractEndpointDescriptionBase(List<URI> capabilities,
50            List<DataView> supportedDataViews, List<Layer> supportedLayers) {
51        if (capabilities == null) {
52            throw new NullPointerException("capabilities == null");
53        }
54        if (capabilities.isEmpty()) {
55            throw new IllegalArgumentException("capabilities are empty");
56        }
57        for (URI capability : capabilities) {
58            if (capability == null) {
59                throw new IllegalArgumentException(
60                        "capabilities must not contain a 'null' item");
61            }
62        }
63        this.capabilities = Collections.unmodifiableList(capabilities);
64
65        if (supportedDataViews == null) {
66            throw new NullPointerException("supportedDataViews == null");
67        }
68        if (supportedDataViews.isEmpty()) {
69            throw new IllegalArgumentException("supportedDataViews are empty");
70        }
71        for (DataView supportedDataView : supportedDataViews) {
72            if (supportedDataView == null) {
73                throw new IllegalArgumentException(
74                        "supportedDataViews must not contain a 'null' item");
75            }
76        }
77        this.supportedDataViews =
78                Collections.unmodifiableList(supportedDataViews);
79
80        if ((supportedLayers != null) && !supportedLayers.isEmpty()) {
81            for (Layer layer : supportedLayers) {
82                if (layer == null) {
83                    throw new IllegalArgumentException(
84                            "supportedLayers must not contain a 'null' item");
85                }
86            }
87            this.supportedLayers =
88                    Collections.unmodifiableList(supportedLayers);
89        } else {
90            this.supportedLayers = null;
91        }
92    }
93
94
95    @Override
96    public List<URI> getCapabilities() {
97        return capabilities;
98    }
99
100
101    @Override
102    public List<DataView> getSupportedDataViews() {
103        return supportedDataViews;
104    }
105
106
107    @Override
108    public List<Layer> getSupportedLayers() {
109        return supportedLayers;
110    }
111
112} // abstract class EndpointDescriptionBase
Note: See TracBrowser for help on using the repository browser.