Skip to content

Commit d05017c

Browse files
committed
feat: Drop Enumeration support for Signal.
1 parent a9ae19e commit d05017c

File tree

6 files changed

+5
-108
lines changed

6 files changed

+5
-108
lines changed

src/main/java/kiss/I.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ private static Disposable load(URL source, String pattern, ClassLoader loader) {
11051105

11061106
if (file.isFile()) {
11071107
// from jar file
1108-
names = I.signal(new ZipFile(file).entries()).map(entry -> entry.getName().replace('/', '.'));
1108+
names = I.signal(new ZipFile(file).entries()::asIterator).map(entry -> entry.getName().replace('/', '.'));
11091109
} else {
11101110
// from class directory
11111111
int prefix = file.getPath().length() + 1;
@@ -1950,16 +1950,6 @@ public static <V> Signal<V> signal(Iterable<V> values) {
19501950
return I.<V> signal().startWith(values);
19511951
}
19521952

1953-
/**
1954-
* Signal the specified values.
1955-
*
1956-
* @param values A list of values to emit.
1957-
* @return The {@link Signal} to emit sequencial values.
1958-
*/
1959-
public static <V> Signal<V> signal(Enumeration<V> values) {
1960-
return I.<V> signal().startWith(values);
1961-
}
1962-
19631953
/**
19641954
* {@link Signal} the specified values.
19651955
*

src/main/java/kiss/Signal.java

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
package kiss;
1111

1212
import static java.lang.Boolean.*;
13-
import static java.util.concurrent.TimeUnit.NANOSECONDS;
13+
import static java.util.concurrent.TimeUnit.*;
1414

1515
import java.lang.reflect.UndeclaredThrowableException;
1616
import java.time.Duration;
@@ -20,7 +20,6 @@
2020
import java.util.Collection;
2121
import java.util.Comparator;
2222
import java.util.Deque;
23-
import java.util.Enumeration;
2423
import java.util.HashSet;
2524
import java.util.Iterator;
2625
import java.util.LinkedList;
@@ -1538,21 +1537,6 @@ public final <R> Signal<R> flatArray(WiseFunction<V, R[]> function) {
15381537
return flatMap(v -> I.signal(function.apply(v)));
15391538
}
15401539

1541-
/**
1542-
* Returns an {@link Signal} that emits items based on applying a function that you supply to
1543-
* each item emitted by the source {@link Signal}, where that function returns an {@link Signal}
1544-
* , and then merging those resulting {@link Signal} and emitting the results of this merger.
1545-
*
1546-
* @param function A function that, when applied to an item emitted by the source {@link Signal}
1547-
* , returns an {@link Signal}.
1548-
* @return An {@link Signal} that emits the result of applying the transformation function to
1549-
* each item emitted by the source {@link Signal} and merging the results of the
1550-
* {@link Signal} obtained from this transformation.
1551-
*/
1552-
public final <R> Signal<R> flatEnum(WiseFunction<V, ? extends Enumeration<R>> function) {
1553-
return flatMap(I.wiseF(function.andThen(I::signal)));
1554-
}
1555-
15561540
/**
15571541
* Returns an {@link Signal} that emits items based on applying a function that you supply to
15581542
* each item emitted by the source {@link Signal}, where that function returns an {@link Signal}
@@ -2760,31 +2744,6 @@ public final Signal<V> startWith(Supplier<V> value) {
27602744
});
27612745
}
27622746

2763-
/**
2764-
* <p>
2765-
* Emit a specified sequence of items before beginning to emit the items from the source
2766-
* {@link Signal}.
2767-
* </p>
2768-
* <p>
2769-
* If you want an {@link Signal} to emit a specific sequence of items before it begins emitting
2770-
* the items normally expected from it, apply the StartWith operator to it.
2771-
* </p>
2772-
* <p>
2773-
* If, on the other hand, you want to append a sequence of items to the end of those normally
2774-
* emitted by an {@link Signal}, you want the {@link #sequenceMap(WiseFunction)} operator.
2775-
* </p>
2776-
*
2777-
* @param values The values that contains the items you want to emit first.
2778-
* @return {ChainableAPI}
2779-
*/
2780-
public final Signal<V> startWith(Enumeration<V> values) {
2781-
// ignore invalid parameter
2782-
if (values == null) {
2783-
return this;
2784-
}
2785-
return startWith(values::asIterator);
2786-
}
2787-
27882747
/**
27892748
* <p>
27902749
* Emit a specified sequence of items before beginning to emit the items from the source

src/test/java/kiss/scan/Classcan.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static <T> Signal<Class<T>> find(Class<T> superClass) {
5050
* @return list of subclasses
5151
*/
5252
public static <T> Signal<Class<T>> find(Class<T> type, ClassLoader loader) {
53-
return I.signal("META-INF/services/" + type.getName()).flatEnum(loader::getResources).flatIterable(url -> {
53+
return I.signal("META-INF/services/" + type.getName()).flatIterable(e -> loader.getResources(e)::asIterator).flatIterable(url -> {
5454
List<String> lines = new ArrayList();
5555

5656
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"))) {

src/test/java/kiss/signal/FlatMapTest.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
package kiss.signal;
1111

12-
import static org.junit.jupiter.api.Assertions.assertThrows;
12+
import static org.junit.jupiter.api.Assertions.*;
1313

1414
import java.util.Arrays;
1515

@@ -123,21 +123,6 @@ void detail() {
123123
assert another.isDisposed();
124124
}
125125

126-
@Test
127-
void enumeration() {
128-
monitor(() -> signal(10, 20).flatEnum(v -> enume(v, v + 1)));
129-
130-
assert main.value(10, 11, 20, 21);
131-
assert main.isCompleted();
132-
}
133-
134-
@Test
135-
void enumerationNull() {
136-
assertThrows(NullPointerException.class, () -> {
137-
monitor(() -> signal(1, 2).flatEnum(null));
138-
});
139-
}
140-
141126
@Test
142127
void array() {
143128
monitor(String.class, signal -> signal.flatArray(v -> v.split("")));

src/test/java/kiss/signal/SignalTester.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
package kiss.signal;
1111

12-
import static java.util.stream.Collectors.toList;
12+
import static java.util.stream.Collectors.*;
1313

1414
import java.util.ArrayList;
1515
import java.util.Collections;
@@ -267,16 +267,6 @@ protected <T> Signal<T> signal(Iterable<T> values) {
267267
return I.signal(values);
268268
}
269269

270-
/**
271-
* Shorthand method of {@link I#signal(Enumeration)}
272-
*
273-
* @param values
274-
* @return
275-
*/
276-
protected <T> Signal<T> signal(Enumeration<T> values) {
277-
return I.signal(values);
278-
}
279-
280270
/**
281271
* Shorthand method of {@link I#signal(Supplier)}
282272
*

src/test/java/kiss/signal/StartWithTest.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
*/
1010
package kiss.signal;
1111

12-
import java.util.Enumeration;
13-
1412
import org.junit.jupiter.api.Assertions;
1513
import org.junit.jupiter.api.Test;
1614

@@ -76,31 +74,6 @@ void iterableNull() {
7674
assert main.isDisposed();
7775
}
7876

79-
@Test
80-
void enumerable() {
81-
monitor(1, () -> signal(3, 4).startWith(enume(0, 1, 2)));
82-
assert main.value(0, 1, 2, 3, 4);
83-
assert main.isCompleted();
84-
assert main.isDisposed();
85-
}
86-
87-
@Test
88-
void enumerableError() {
89-
monitor(() -> signal(1, 2).startWith(errorEnumeration()));
90-
assert main.value();
91-
assert main.isError();
92-
assert main.isNotCompleted();
93-
assert main.isDisposed();
94-
}
95-
96-
@Test
97-
void enumerableNull() {
98-
monitor(() -> signal(1, 2).startWith((Enumeration) null));
99-
assert main.value(1, 2);
100-
assert main.isCompleted();
101-
assert main.isDisposed();
102-
}
103-
10477
@Test
10578
void signal() {
10679
monitor(signal -> signal.startWith(other.signal()));

0 commit comments

Comments
 (0)