com.antelmann.util
Class RandomFilter
java.lang.Object
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
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RandomFilter
public RandomFilter(double odds)
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