public static < E , B extends MutableBag < E > > UnmodifiableBag < E > of ( B bag ) { if ( bag == null ) { throw new IllegalArgumentException ( "cannot create an UnmodifiableBag for null" ) ; } return new UnmodifiableBag < E > ( bag ) ; }
This method will take a MutableBag and wrap it directly in a UnmodifiableBag .