public static ResourceList union ( Collection < ResourceList > lists ) { switch ( lists . size ( ) ) { case 0 : return EMPTY ; case 1 : return lists . iterator ( ) . next ( ) ; default : ResourceList r = new ResourceList ( ) ; for ( ResourceList l : lists ) { r . all . addAll ( l . all ) ; for ( Entry < Resource , Integer > e : l . write . entrySet ( ) ) r . write . put ( . getKey ( ) , unbox ( r . write . get ( . getKey ( ) ) ) + e . getValue ( ) ) ; } return r ; } }
Creates union of all resources .