Class FilteringCollection

FilteringCollection is an extension of Collection which provides possibilities to

  • _filter_the elements to return a new FilteringCollectionwith a filtered set of elements
  • _sort_the elements to return a new FilteringCollectionwith a defined sort order
  • _transform_the elements to return a new FilteringCollectioncontaining related elements
  • _provide a map_of the elements against a predefined key

Usage - In the current version each FilteringCollection provides a set of predefined qualifier constants which can be passed into the select(Object) method used to filter the elements. Generally qualifiers have the prefix QUALIFIER_. A second method sort(Object) is used to create a new instance with a different element ordering, which takes an orderB< constant. Generally orderBys have the prefix ORDERBY_: examples are ShippingOrder.ORDERBY_ITEMID, ShippingOrder.ORDERBY_ITEMPOSITION, and ORDERBY_REVERSE can be used to provide a FilteringCollection with the reverse ordering. An example with method ShippingOrder.getItems():

`

var allItems : FilteringCollection = shippingOrder.items;

var productItems : FilteringCollection = allItems.select(ShippingOrder.QUALIFIER_PRODUCTITEMS);

var serviceItems : FilteringCollection = allItems.select(ShippingOrder.QUALIFIER_SERVICEITEMS);

var byPosition : FilteringCollection = productItems.sort(ShippingOrder.ORDERBY_ITEMPOSITION);

var revByPosition: FilteringCollection = byPosition.sort(FilteringCollection.ORDERBY_REVERSE);

var mapByItemID : Map = allItems.asMap(); `

Constant Summary 

ConstantDescription
ORDERBY_REVERSE: ObjectPass this orderBy with the sort(Object) method to obtain a new FilteringCollection with the reversed sort order.

Constructor Summary 

This class does not have a constructor, so you cannot create it directly.

Method Summary 

MethodDescription
asMap()Returns a Map containing the elements of this FilteringCollection against a predefined key.
select(Object)Select a new FilteringCollection instance by passing a predefined qualifier as an argument to this method.
sort(Object)Select a new FilteringCollection instance by passing a predefined orderBy as an argument to this method.

Methods inherited from class Collection 

add, add1, addAll, clear, contains, containsAll, getLength, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray

Methods inherited from class Object 

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

Constant Details 

ORDERBY_REVERSE 

ORDERBY_REVERSE: Object

Pass this orderBy with the sort(Object) method to obtain a new FilteringCollection with the reversed sort order. Only use on a FilteringCollection which has been previously sorted.


Method Details 

asMap() 

asMap(): Map

Returns a Map containing the elements of this FilteringCollection against a predefined key. The key used is documented in the method returning the FilteringCollection and is typically the ItemID assigned to an element in the collection.

Returns:


select(Object) 

select(qualifier: Object): FilteringCollection

Select a new FilteringCollection instance by passing a predefined qualifier as an argument to this method. See FilteringCollection.

Parameters:

  • qualifier - possible qualifiers are documented in the method returning the FilteringCollection

Returns:


sort(Object) 

sort(orderBy: Object): FilteringCollection

Select a new FilteringCollection instance by passing a predefined orderBy as an argument to this method. See FilteringCollection.

Parameters:

Returns:


DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!