public MicroserverEnvironment(Properties propertyFactory) { modulePort = HashMap.empty(); this.properties = propertyFactory; }
public Config() { classes = HashSet.empty(); properties = HashMap.empty(); dataSources = HashMap.empty(); defaultDataSourceName = "db"; propertiesName = "application.properties"; instancePropertiesName = "instance.properties"; serviceTypePropertiesName = "service-type.properties"; allowCircularReferences = false; basePackages = new String[0]; }
private <K, V> PersistentMap<K, V> extractMap(Supplier<Map<K, V>> s) { if (!resetAll) return HashMap.fromMap(s.get()); return HashMap.empty(); }
public void assureModule(Module module) { if (!modulePort.containsKey(module.getContext())) { HashMap<String, ModuleBean> builder = HashMap.empty(); builder = builder.putAll(modulePort); builder = builder.put(module.getContext(), ModuleBean.builder().host(getHost(module)).port(getPort(module)).build()); modulePort = builder; } }
public static <K,V> HashMap<K,V> of(K k,V v){ HashMap<K,V> res = empty(); return res.put(k,v); }
public static <K,V> HashMap<K,V> fromMap(Map<K,V> map){ HashMap<K,V> res = empty(); for(Map.Entry<K,V> next : map.entrySet()){ res = res.put(next.getKey(),next.getValue()); } return res; } public static <K,V> HashMap<K,V> fromMap(PersistentMap<K,V> map){
@Override protected <K, V> ImmutableMap<K, V> empty() { return HashMap.empty(); }
public static <T> Bag<T> empty() { return new Bag<>(HashMap.empty(), 0); }
public static <K,V> HashMap<K,V> of(K k1,V v1,K k2, V v2){ HashMap<K,V> res = empty(); return res.put(k1,v1).put(k2,v2); }
public static <K,V> LinkedMap<K,V> empty(){ return new LinkedMap<>(HashMap.empty(),Vector.empty()); } public static <K,V> LinkedMap<K,V> of(K k,V v){
public static <K,V> HashMap<K,V> fromMap(PersistentMap<K,V> map){ if(map instanceof HashMap){ return (HashMap)map; } HashMap<K,V> res = empty(); for(Tuple2<K,V> next : map){ res = res.put(next._1(),next._2()); } return res; } public static <K,V> HashMap<K,V> of(K k1,V v1,K k2, V v2){
public HashMap<T1,T2> toHashMap(){ return HashMap.<T1,T2>empty().put(_1(),_2()); } public Map<T1,T2> toMap(){
/** * Use classifier function to group elements in this Sequence into a Map * * <pre> * {@code * HashMap<Integer, Vector<Integer>> map1 = of(1, 2, 3, 4).groupBy(i -> i % 2); * assertEquals(Vector.of(2, 4), map1.getOrElse(0,Vector.empty())); * assertEquals(Vector.of(1, 3), map1.getOrElse(1,Vector.empty())); * assertEquals(2, map1.size()); * * } * * </pre> */ @Override default <K> HashMap<K, Vector<T>> groupBy(final Function<? super T, ? extends K> classifier) { return this.foldLeft(HashMap.<K, Vector<T>>empty(), (a, b) -> { K k = classifier.apply(b); Vector<T> s = a.getOrElse(k, Vector.empty()); return a.put(k, s.plus(b)); }); }
public static <K,V> HashMap<K,V> fromStream(Stream<Tuple2<K,V>> stream){ return ReactiveSeq.fromStream(stream).foldLeft(empty(),(m,t2)->m.put(t2._1(),t2._2())); }
/** * <pre> * {@code * PersistentMap<Integer,String> q = Reducers.toPersistentMap() .foldMap(Stream.of(Arrays.asList("hello",1),Arrays.asList("world",2))); * * } * </pre> * @return Reducer for PersistentMap */ public static <K, V> Reducer<PersistentMap<K, V>,Tuple2<K,V>> toPersistentMap() { return Reducer.of(HashMap.empty(), (final PersistentMap<K, V> a) -> b -> a.putAll(b), (in) -> { Tuple2<K, V> w = in; return HashMap.of((K) w._1(), (V) w._2()); }); }
@Test public void equalsTest() { assertThat(empty(),equalTo(cyclops.data.HashMap.empty())); assertThat(this.<Integer,Integer>empty(),equalTo(cyclops.data.TreeMap.empty(Comparator.<Integer>naturalOrder()))); assertThat(this.<Integer,Integer>of(1,2),equalTo(cyclops.data.TreeMap.of(Comparator.<Integer>naturalOrder(),1,2))); assertThat(this.<Integer,Integer>of(1,2),equalTo(cyclops.data.HashMap.of(1,2))); assertThat(this.<Integer,Integer>of(1,2,3,4),equalTo(cyclops.data.TreeMap.of(Comparator.<Integer>naturalOrder(),1,2,3,4))); assertThat(this.<Integer,Integer>of(1,2,3,4),equalTo(cyclops.data.HashMap.of(1,2,3,4))); } @Test
@Override public ImmutableMap<K, V> putAll(PersistentMap<? extends K,? extends V> map) { PersistentMap< K,V> narrow = (PersistentMap<K,V>)map; ImmutableMap<K,V> res = HashMap.empty(); Vector<Tuple2<K,V>> ordering =order; for(Tuple2<K,V> t : narrow){ if(containsKey(t._1())) ordering = ordering.replaceFirst(Tuple.tuple(t._1(),getOrElse(t._1(),null)),t); else ordering =ordering.plus(t); res = res.put(t); } return new LinkedMap<K,V>(res,ordering); }
public static <K,V> HashMap<K,V> fromMap(PersistentMap<K,V> map){ if(map instanceof HashMap){ return (HashMap)map; } HashMap<K,V> res = empty(); for(Tuple2<K,V> next : map){ res = res.put(next._1(),next._2()); } return res; } public static <K,V> HashMap<K,V> of(K k1,V v1,K k2, V v2){