Holger's Java API

## com.antelmann.util
Class MethodFilter<T>

    java.lang.Object
      com.antelmann.util.MethodFilter<T>

All Implemented Interfaces:
  Filter<T>

    public class MethodFilter<T>

extends Object
implements Filter<T>

a special filter that can filter objects based on the return values of methods that take no parameters and return something but void.

Since:
  26. März 2007, 20:22
Author:
  Holger Antelmann

Field Summary

Fields inherited from interface com.antelmann.util.Filter
`EXCLUDE_ALL_FILTER, INCLUDE_ALL_FILTER`

Constructor Summary
`MethodFilter(Class<T> type, Map<String,Object> restrictions)` constructs a MethodFilter based on some type and a given map of restrictions.

Method Summary
`boolean` `accept(T entry)` returns true only if the given entry is accepted by this filter
`static String[]` `getUsableMethodNames(Class<?> c)` lists all method names of the given class that take no parameters and return something but void - and are therefore usable as a restriction.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MethodFilter

    public MethodFilter(Class<T> type,
                        Map<String,Object> restrictions)
                 throws IllegalArgumentException

  constructs a MethodFilter based on some type and a given map of restrictions.

  Parameters:
    `restrictions` - maps method names to their allowed return values. the method names must be methods without parameters that return something but void. The mapped values are compared for equals; in addition, special supported restriction values are Range and Object[] values, unless the return value of the method is just that.
  Throws:
    `IllegalArgumentException`
  See Also:
    `Range`

Method Detail

### accept

    public boolean accept(T entry)

  Description copied from interface: `Filter`
  returns true only if the given entry is accepted by this filter

  Specified by:
    `accept` in interface `Filter<T>`

### getUsableMethodNames

    public static String[] getUsableMethodNames(Class<?> c)

  lists all method names of the given class that take no parameters and return something but void - and are therefore usable as a restriction. If comparableReturnValuesOnly is true, the return values of the methods must also implement Comparable.

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