List of usage examples for com.google.common.collect ImmutableSortedMap forEach
default void forEach(BiConsumer<? super K, ? super V> action)
From source file:common.FoundationMigrationModule.java
static Set<Integer> migrate(DSLContext dsl, Time time) { int latestRev = dsl.selectFrom(FOUNDATION_REV).orderBy(FOUNDATION_REV.VERSION.desc()).limit(1) .fetch(FOUNDATION_REV.VERSION).get(0); Set<Integer> publishedTakesToRefresh = new HashSet<>(); ImmutableSortedMap<Integer, FoundationMigration> toMigrate = MIGRATIONS.tailMap(latestRev + 1); toMigrate.forEach((version, migration) -> { dsl.transaction(configuration -> { try (DSLContext updateDocs = DSL.using(configuration)) { List<Integer> needsRefresh = migrate(updateDocs, time, version, migration); publishedTakesToRefresh.addAll(needsRefresh); }/*from w ww . j a va2s . co m*/ }); }); return publishedTakesToRefresh; }
From source file:com.fatboyindustrial.omnium.Maps.java
/** * Transforms the given map by applying a function to each of the keys. * @param input The input map./*from w w w .ja v a2 s . c o m*/ * @param transform The transformation function to apply to the key. * @param <K1> The original key type. * @param <V> The map value type. * @param <K2> The transformed key type. * @return The new map. */ public static <K1 extends Comparable<K1>, V, K2 extends Comparable<K2>> ImmutableSortedMap<K2, V> keyTransform( final ImmutableSortedMap<K1, V> input, final Function<K1, K2> transform) { final ImmutableSortedMap.Builder<K2, V> builder = ImmutableSortedMap.naturalOrder(); input.forEach((key, value) -> builder.put(transform.apply(key), value)); return builder.build(); }