dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28247
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14086: Added support method
------------------------------------------------------------
revno: 14086
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-02-21 12:45:25 +0100
message:
Added support method
modified:
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java 2013-12-24 15:02:47 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java 2014-02-21 11:45:25 +0000
@@ -209,4 +209,24 @@
}
}
}
+
+ /**
+ * Returns the sub list of the given list avoiding exceptions, starting on
+ * the given start index and returning at maximum the given max number of items.
+ *
+ * @param list the list.
+ * @param start the start index.
+ * @param max the max number of items to return.
+ */
+ public static <T> List<T> subList( List<T> list, int start, int max )
+ {
+ if ( list == null )
+ {
+ return null;
+ }
+
+ int end = start + max;
+
+ return list.subList( Math.max( 0, start ), Math.min( list.size(), end ) );
+ }
}