Merge branch 'Jalview-JS/jim/JAL-3253-JAL-3418' into Jalview-JS/JAL-3253-applet
[jalview.git] / srcjar / intervalstore / api / IntervalStoreI.java
1 /*
2 BSD 3-Clause License
3
4 Copyright (c) 2018, Mungo Carstairs
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10 * Redistributions of source code must retain the above copyright notice, this
11   list of conditions and the following disclaimer.
12
13 * Redistributions in binary form must reproduce the above copyright notice,
14   this list of conditions and the following disclaimer in the documentation
15   and/or other materials provided with the distribution.
16
17 * Neither the name of the copyright holder nor the names of its
18   contributors may be used to endorse or promote products derived from
19   this software without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 package intervalstore.api;
33
34 import java.util.Collection;
35 import java.util.List;
36
37 import intervalstore.impl.NCList;
38
39 public interface IntervalStoreI<T extends IntervalI> extends Collection<T>
40 {
41
42   /**
43    * Returns a (possibly empty) list of items whose extent overlaps the given
44    * range
45    * 
46    * @param from
47    *          start of overlap range (inclusive)
48    * @param to
49    *          end of overlap range (inclusive)
50    * @return
51    */
52   List<T> findOverlaps(long from, long to);
53
54   /**
55    * Returns a string representation of the data where containment is shown by
56    * indentation on new lines
57    * 
58    * @return
59    */
60   String prettyPrint();
61
62   /**
63    * Answers true if the data held satisfy the rules of construction of an
64    * IntervalStore, else false.
65    * 
66    * @return
67    */
68   boolean isValid();
69
70   /**
71    * Answers the level of nesting of intervals in the store, as
72    * <ul>
73    * <li>0 if the store is empty</li>
74    * <li>1 if all intervals are 'top level' (non nested)</li>
75    * <li>else 1 plus the depth of the enclosed NCList</li>
76    * </ul>
77    * 
78    * @return
79    * @see NCList#getDepth()
80    */
81   int getDepth();
82
83 }