SOURCECODE

How to... define a UserFilter


Description:
Once you have a huge amount of registered Users in your application, you may want to display only a certain amount of them. This can be accomplished by the UserFilter
UserFilter is an interface, but don't worry, there's not much to implement. You only have to define the method match(User u), which shall return true when the User matches the creteria you want him to be displayed for.

ToDo's:
  1. Create a new class which implements UserFilter
  2. Implement the method match(User u)

In this expamle the UserFilter returns all Users who have the Capability called "Ofiice" granted.



SourceCode

import users.*;
import users.swing.*;

 1
public class MyUserFilter implements UserFilter {

    //just call the constructor of UserFilter here
    public MyUserFilter () {
        super();
    }

     2
    public boolean match(User u) {
        return u.getCapability("Office").isGranted();
    }
}