public T addElement ( T element ) { // make sure that elements are initialized getElements ( ) ; if ( ! containsElement ( this . elements , element ) ) { this . elements . add ( element ) ; element . addChangeListener ( this . elementChangeListener ) ; element . notifyState ( ) ; return element ; } throw new RuntimeException ( element . toString ( ) + " already exists" ) ; }
add a new element throw a RuntimeException if the element already exists