1 19 package org.netbeans.lib.jmi.query; 20 21 import java.util.Comparator ; 22 23 28 public class ValueFilter extends FilterQuery { 29 30 private final Object VALUE; 31 private final Comparator COMPARATOR; 32 33 35 public ValueFilter( Query query, Object value ) { 36 this( query, value, null ); 37 } 38 39 41 public ValueFilter( Query query, Object value, Comparator comparator ) { 42 super( query ); 43 this.VALUE = value; 44 this.COMPARATOR = comparator; 45 } 46 47 protected boolean accept( Object object ) { 48 if ( COMPARATOR != null ) { 49 return COMPARATOR.compare( VALUE, object ) == 0; 50 } 51 52 else { 53 if ( VALUE == null ) { 54 if ( object == null ) { 55 return true; 56 } 57 else { 58 return false; 59 } 60 } 61 else { 62 return VALUE.equals( object ); 63 } 64 } 65 } 66 67 } 68 | Popular Tags |