gw.lang.enhancements.CoreIterableOfComparablesEnhancement.gsx Maven / Gradle / Ivy
package gw.lang.enhancements
uses java.lang.Iterable
uses java.lang.Comparable
uses gw.util.IOrderedList
/*
* Copyright 2014 Guidewire Software, Inc.
*/
enhancement CoreIterableOfComparablesEnhancement : Iterable {
/**
* Returns the minium non-null element in this collection, or null
* if all elements are null or the colleciton is empty.
*/
reified function min() : T {
return this.min( \ e -> e )
}
/**
* Returns the maximum non-null element in this collection, or null if
* all elements are null or the collection is empty.
*/
reified function max() : T {
return this.max( \ e -> e )
}
/**
* Returns a new list of the elements of this collection ordered naturally
*/
reified function order() : IOrderedList {
return this.toList().orderBy( \ c -> c )
}
/**
* Returns a new list of the elements of this collection reverese ordered naturally
*/
reified function orderDescending() : IOrderedList {
return this.toList().orderByDescending( \ c -> c )
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy