| Package | system.comparators |
| Class | public class NullComparator |
| Inheritance | NullComparator Object |
| Implements | Comparator |
Example :
import system.comparators.NullComparator;
var comp1:NullComparator = new NullComparator(null, true) ;
var comp2:NullComparator = new NullComparator(null, false) ;
var n = null ;
var o = {} ;
trace( comp1.compare(n, n) ) ; // 0
trace( comp1.compare(n, o) ) ; // 1
trace( comp1.compare(o, n) ) ; // -1
trace("----") ;
trace( comp2.compare(n, n) ) ; // 0
trace( comp2.compare(n, o) ) ; // -1
trace( comp2.compare(o, n) ) ; // 1
| Property | Defined By | ||
|---|---|---|---|
| nonNullComparator : Comparator = null
Defines the comparator to use when comparing two non-null objects. | NullComparator | ||
| nullsAreHigh : Boolean = false
Defines that null should be compared as higher than a non-null object. | NullComparator | ||
| Method | Defined By | ||
|---|---|---|---|
NullComparator(nonNullComparator:Comparator = null, nullsAreHigh:Boolean = false)
Creates a new NullComparator instance. | NullComparator | ||
compare(o1:*, o2:*, options:* = null):int
Performs a comparison between two objects. | NullComparator | ||
| nonNullComparator | property |
public var nonNullComparator:Comparator = nullDefines the comparator to use when comparing two non-null objects.
| nullsAreHigh | property |
public var nullsAreHigh:Boolean = falseDefines that null should be compared as higher than a non-null object.
| NullComparator | () | Constructor |
public function NullComparator(nonNullComparator:Comparator = null, nullsAreHigh:Boolean = false)Creates a new NullComparator instance.
ParametersnonNullComparator:Comparator (default = null) — the comparator to use when comparing two non-null objects.
| |
nullsAreHigh:Boolean (default = false) — a true value indicates that null should be compared as higher than a non-null object. A false value indicates that null should be compared as lower than a non-null object.
|
| compare | () | method |
public function compare(o1:*, o2:*, options:* = null):intPerforms a comparison between two objects. If both objects are null, a 0 value is returned. If one object is null and the other is not, the result is determined on whether the Comparator was constructed to have nulls as higher or lower than other objects. If neither object is null, an underlying comparator specified in the constructor (or the default) is used to compare the non-null objects. The default Comparator used to compare two non-null objects is the ComparableComparator.
Parameters
o1:* — the first 'null' object to compare.
| |
o2:* — the second 'null' object to compare.
| |
options:* (default = null) |
int —
|
See also