Skip to content

Commit 851a0a7

Browse files
committed
Change copyright.
1 parent 13b144c commit 851a0a7

File tree

21 files changed

+59
-23
lines changed

21 files changed

+59
-23
lines changed

src/main/java/com/github/underscore/Trie.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright 2015-2020 Valentyn Kolesnikov
4+
* Copyright 2015-2021 Valentyn Kolesnikov
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

src/main/java/com/github/underscore/U.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright 2015-2020 Valentyn Kolesnikov
4+
* Copyright 2015-2021 Valentyn Kolesnikov
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -156,7 +156,8 @@ public String apply(Map<K, V> value) {
156156
final String escape = TEMPLATE_SETTINGS.get(ESCAPE);
157157
String result = template;
158158
for (final Map.Entry<K, V> element : value.entrySet()) {
159-
final String value1 = String.valueOf(element.getValue()).replace("\\", "\\\\");
159+
final String value1 = String.valueOf(element.getValue()).replace("\\", "\\\\")
160+
.replace("$", "\\$");
160161
result = java.util.regex.Pattern.compile(interpolate.replace(ALL_SYMBOLS,
161162
S_Q + element.getKey()
162163
+ E_S)).matcher(result).replaceAll(value1);
@@ -317,6 +318,16 @@ public static <T, E> List<T> map(final List<E> list, final Function<? super E, T
317318
return transformed;
318319
}
319320

321+
public static <T, E> List<T> mapMulti(final List<E> list,
322+
final BiConsumer<? super E, ? super Consumer<T>> mapper) {
323+
final List<T> transformed = newArrayListWithExpectedSize(list.size());
324+
for (E element : list) {
325+
Consumer<T> value = t -> transformed.add(t);
326+
mapper.accept(element, value);
327+
}
328+
return transformed;
329+
}
330+
320331
public <F> List<F> map(final Function<? super T, F> func) {
321332
return map(newArrayList(iterable), func);
322333
}
@@ -2745,6 +2756,10 @@ public <F> Chain<F> map(final Function<? super T, F> func) {
27452756
return new Chain<>(U.map(list, func));
27462757
}
27472758

2759+
public <F> Chain<F> mapMulti(final BiConsumer<? super T, ? super Consumer<F>> mapper) {
2760+
return new Chain<>(U.mapMulti(list, mapper));
2761+
}
2762+
27482763
public <F> Chain<F> mapIndexed(final BiFunction<Integer, ? super T, F> func) {
27492764
return new Chain<>(U.mapIndexed(list, func));
27502765
}

src/main/java/com/github/underscore/lodash/Base32.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright 2015-2020 Valentyn Kolesnikov
4+
* Copyright 2015-2021 Valentyn Kolesnikov
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

src/main/java/com/github/underscore/lodash/Json.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright 2015-2020 Valentyn Kolesnikov
4+
* Copyright 2015-2021 Valentyn Kolesnikov
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

src/main/java/com/github/underscore/lodash/U.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright 2015-2020 Valentyn Kolesnikov
4+
* Copyright 2015-2021 Valentyn Kolesnikov
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -184,6 +184,10 @@ public <F> Chain<F> map(final Function<? super T, F> func) {
184184
return new Chain<>(U.map(value(), func));
185185
}
186186

187+
public <F> Chain<F> mapMulti(final BiConsumer<? super T, ? super Consumer<F>> mapper) {
188+
return new Chain<>(U.mapMulti(value(), mapper));
189+
}
190+
187191
public <F> Chain<F> mapIndexed(final BiFunction<Integer, ? super T, F> func) {
188192
return new Chain<>(U.mapIndexed(value(), func));
189193
}

src/main/java/com/github/underscore/lodash/Xml.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright 2015-2020 Valentyn Kolesnikov
4+
* Copyright 2015-2021 Valentyn Kolesnikov
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

src/test/java/com/github/underscore/ArraysTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright 2015-2020 Valentyn Kolesnikov
4+
* Copyright 2015-2021 Valentyn Kolesnikov
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

src/test/java/com/github/underscore/ChainingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright 2015-2020 Valentyn Kolesnikov
4+
* Copyright 2015-2021 Valentyn Kolesnikov
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

src/test/java/com/github/underscore/CollectionsTest.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright 2015-2020 Valentyn Kolesnikov
4+
* Copyright 2015-2021 Valentyn Kolesnikov
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -170,7 +170,23 @@ public void map() {
170170
assertEquals("[3, 6, 9]", result1.toString());
171171
}
172172

173-
/*
173+
@Test
174+
public void mapMulti() {
175+
List<Integer> result = U.mapMulti(asList("Java", "Python", "C#"), (str, consumer) -> {
176+
for (int i = 0; i < str.length(); i++) {
177+
consumer.accept(str.length());
178+
}
179+
});
180+
assertEquals("[4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 2, 2]", result.toString());
181+
List<Object> resultChain = U.chain(asList("Java", "Python", "C#")).mapMulti((str, consumer) -> {
182+
for (int i = 0; i < str.length(); i++) {
183+
consumer.accept(str.length());
184+
}
185+
}).value();
186+
assertEquals("[4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 2, 2]", resultChain.toString());
187+
}
188+
189+
/*
174190
_.map(_.range(3), function(num){ return (num + 1) * 3; });
175191
=> [3, 6, 9]
176192
*/

src/test/java/com/github/underscore/FunctionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright 2015-2020 Valentyn Kolesnikov
4+
* Copyright 2015-2021 Valentyn Kolesnikov
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)