com.atlassian.plugins.rest.common.expand.parameter
Interface Indexes


public interface Indexes

Represents indexes as used in expand parameters. The size of the whole collection is required on most of this class methods as it can handle indexes specified as:

where i and j are positive integers.


Method Summary
 boolean contains(int index, int size)
          Checks whether a given index is contained within this collection of indexes
 java.util.SortedSet<java.lang.Integer> getIndexes(int size)
          Gets a sorted set of all indexes, negative indexes having been translated into their positive counter part.
 int getMaxIndex(int size)
          Gets the maximum index in the range, given the total size of the collection to consider.
 int getMinIndex(int size)
          Gets the minimum index in the range, given the total size of the collection to consider.
 boolean isRange()
          Tells whether this represents a contiguous range.
 

Method Detail

isRange

boolean isRange()
Tells whether this represents a contiguous range. If not a range it is a single index, and getMinIndex(int) and getMaxIndex(int) will return the same value.

Returns:
true if this is a range.

getMinIndex

int getMinIndex(int size)
Gets the minimum index in the range, given the total size of the collection to consider.

Parameters:
size - the size of the collection to consider.
Returns:
the min index, -1 if the min index is out of bounds.

getMaxIndex

int getMaxIndex(int size)
Gets the maximum index in the range, given the total size of the collection to consider.

Parameters:
size - the size of the collection to consider.
Returns:
the max index, -1 if the max index is out of bounds.

contains

boolean contains(int index,
                 int size)
Checks whether a given index is contained within this collection of indexes

Parameters:
index - the index to look for.
size - the size of the overall collection to consider.
Returns:
true if it does contain the given index, false otherwise.

getIndexes

java.util.SortedSet<java.lang.Integer> getIndexes(int size)
Gets a sorted set of all indexes, negative indexes having been translated into their positive counter part.

Parameters:
size - the size of the overall collection to consider.
Returns:
a set of positive indexes.


Copyright © 2014 Atlassian. All Rights Reserved.