Tabnine Logo
FlowToMap
Code IndexAdd Tabnine to your IDE (free)

How to use
FlowToMap
in
com.wizzardo.tools.collections.flow.flows

Best Java code snippets using com.wizzardo.tools.collections.flow.flows.FlowToMap (Showing top 9 results out of 315)

origin: com.wizzardo.tools/tools-collections

public <V> FlowToMap<K, V, B> toMap(Mapper<? super B, V> mapper) {
  return then(new FlowToMap<K, V, B>((Map<K, V>) groups, mapper));
}
origin: wizzardo/tools

@Test
public void test_toMap_6() {
  Map<Boolean, List<Integer>> map = Flow.of(1, 2, 3)
      .toMap(new Supplier<Map<Boolean, FlowGroup<Boolean, Integer>>>() {
        @Override
        public Map<Boolean, FlowGroup<Boolean, Integer>> supply() {
          return new TreeMap<Boolean, FlowGroup<Boolean, Integer>>();
        }
      }, new Mapper<Integer, Boolean>() {
        @Override
        public Boolean map(Integer integer) {
          return integer % 2 == 0;
        }
      })
      .get();
  Assert.assertEquals(2, map.size());
  Assert.assertEquals(1, map.get(true).size());
  Assert.assertEquals(Integer.valueOf(2), map.get(true).get(0));
  Assert.assertEquals(2, map.get(false).size());
  Assert.assertEquals(Integer.valueOf(1), map.get(false).get(0));
  Assert.assertEquals(Integer.valueOf(3), map.get(false).get(1));
}
origin: wizzardo/tools

@Test
public void test_toMap() {
  Map<Boolean, List<Integer>> map = Flow.of(1, 2, 3)
      .toMap(new Mapper<Integer, Boolean>() {
        @Override
        public Boolean map(Integer integer) {
          return integer % 2 == 0;
        }
      }, Flow.<Boolean, Integer>flowGroupListMapper())
      .get();
  Assert.assertEquals(2, map.size());
  Assert.assertEquals(1, map.get(true).size());
  Assert.assertEquals(Integer.valueOf(2), map.get(true).get(0));
  Assert.assertEquals(2, map.get(false).size());
  Assert.assertEquals(Integer.valueOf(1), map.get(false).get(0));
  Assert.assertEquals(Integer.valueOf(3), map.get(false).get(1));
}
origin: wizzardo/tools

public <V> FlowToMap<K, V, B> toMap(Mapper<? super B, V> mapper) {
  return then(new FlowToMap<K, V, B>((Map<K, V>) groups, mapper));
}
origin: wizzardo/tools

@Test
public void test_toMap_2() {
  Map<Boolean, List<Integer>> map = Flow.of(1, 2, 3)
      .groupBy(new Mapper<Integer, Boolean>() {
        @Override
        public Boolean map(Integer integer) {
          return integer % 2 == 0;
        }
      })
      .toMap()
      .get();
  Assert.assertEquals(2, map.size());
  Assert.assertEquals(1, map.get(true).size());
  Assert.assertEquals(Integer.valueOf(2), map.get(true).get(0));
  Assert.assertEquals(2, map.get(false).size());
  Assert.assertEquals(Integer.valueOf(1), map.get(false).get(0));
  Assert.assertEquals(Integer.valueOf(3), map.get(false).get(1));
}
origin: wizzardo/tools

@Test
public void test_toMap_4() {
  Map<Boolean, List<String>> map = Flow.of(1, 2, 3)
      .toMap(new Mapper<Integer, Boolean>() {
        @Override
        public Boolean map(Integer integer) {
          return integer % 2 == 0;
        }
      }, new Mapper<FlowGroup<Boolean, Integer>, List<String>>() {
        @Override
        public List<String> map(FlowGroup<Boolean, Integer> group) {
          return group.map(new Mapper<Integer, String>() {
            @Override
            public String map(Integer integer) {
              return integer.toString();
            }
          }).toList().get();
        }
      })
      .get();
  Assert.assertEquals(2, map.size());
  Assert.assertEquals(1, map.get(true).size());
  Assert.assertEquals("2", map.get(true).get(0));
  Assert.assertEquals(2, map.get(false).size());
  Assert.assertEquals("1", map.get(false).get(0));
  Assert.assertEquals("3", map.get(false).get(1));
}
origin: wizzardo/tools

        .get();
}).get();
origin: wizzardo/tools

@Test
public void test_toMap_3() {
  Map<Boolean, List<Integer>> map = Flow.of(1, 2, 3)
      .groupBy(new Mapper<Integer, Boolean>() {
        @Override
        public Boolean map(Integer integer) {
          return integer % 2 == 0;
        }
      })
      .filter(new Filter<FlowGroup<Boolean, Integer>>() {
        @Override
        public boolean allow(FlowGroup<Boolean, Integer> group) {
          return group.getKey();
        }
      })
      .toMap()
      .get();
  Assert.assertEquals(1, map.size());
  Assert.assertEquals(1, map.get(true).size());
  Assert.assertEquals(Integer.valueOf(2), map.get(true).get(0));
}
origin: wizzardo/tools

@Test
public void test_limit_3() {
  Assert.assertEquals("{1=[1], 2=[2], 3=[3]}", Flow.of(1, 2, 3, 4, 5)
      .groupBy(new Mapper<Integer, Integer>() {
        @Override
        public Integer map(Integer integer) {
          return integer;
        }
      })
      .limit(3)
      .toMap()
      .get()
      .toString()
  );
}
com.wizzardo.tools.collections.flow.flowsFlowToMap

Javadoc

Created by wizzardo on 16.04.16.

Most used methods

  • <init>
  • get

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • setRequestProperty (URLConnection)
  • getSharedPreferences (Context)
  • Permission (java.security)
    Legacy security code; do not use.
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now