Holger's
Java API

com.antelmann.util
Class RandomFilter

java.lang.Object
  extended by com.antelmann.util.RandomFilter
All Implemented Interfaces:
CascadingFilter<Object>, Filter<Object>

public class RandomFilter
extends Object
implements CascadingFilter<Object>

a special filter that randomly accepts Objects based on given odds.

Since:
07.05.2014, 21:01:56
Author:
holger

Field Summary
 
Fields inherited from interface com.antelmann.util.Filter
EXCLUDE_ALL_FILTER, INCLUDE_ALL_FILTER
 
Constructor Summary
RandomFilter(double odds)
           
 
Method Summary
 boolean accept(Object entry)
          returns true only if the given entry is accepted by this filter
 Filter<Object> getInnerFilter()
           
 double getOdds()
           
 void setInnerFilter(Filter<Object> filter)
           
 void setOdds(double odds)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomFilter

public RandomFilter(double odds)
Method Detail

accept

public boolean accept(Object entry)
Description copied from interface: Filter
returns true only if the given entry is accepted by this filter

Specified by:
accept in interface Filter<Object>

setOdds

public final void setOdds(double odds)
Parameters:
odds - a number between 0 and 1 where 0 won't accept any entry, 1 will accept every entry and .5 will accept any given entry with a chance of 50:50

getOdds

public final double getOdds()

getInnerFilter

public final Filter<Object> getInnerFilter()
Specified by:
getInnerFilter in interface CascadingFilter<Object>

setInnerFilter

public void setInnerFilter(Filter<Object> filter)
Specified by:
setInnerFilter in interface CascadingFilter<Object>


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads