[rules-users] property change listener for collections

Andreas Langegger al at jku.at
Mon Feb 25 10:19:23 EST 2008


hello,

when I have a bean and I want to use a property change listener for  
collection members, how can I tell the listener the old state of the  
collection?

This is the code for simple fields from the docs:

public void setState(final String newState) {
     String oldState = this.state;
     this.state = newState;
     this.changes.firePropertyChange( "state",
                                       oldState,
                                       newState );
}

and now I want to hook in the firePropertyChange for the following  
method which adds some elements to a set:

protected Set<Var> knownVariables = new HashSet<Var>();
public void addKnownVariable(String var) {
     this.knownVariables.add(var);	
     changes.firePropertyChange("knownVariables", OLDSTATE??!,  
knownVariables);
}

Will I have to copy the whole collection, switch the complete field  
collection object that I can supply the "old state"?

thanks,
Andy



More information about the rules-users mailing list