Predicate
This commit is contained in:
39
src/org/eidecker/oca8lernen/general/PredicateTest.java
Normal file
39
src/org/eidecker/oca8lernen/general/PredicateTest.java
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package org.eidecker.oca8lernen.general;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class PredicateTest {
|
||||||
|
|
||||||
|
Predicate<String> isEmpty = (String s) -> s.length() == 0;
|
||||||
|
|
||||||
|
Predicate<String> isNotEmpty = s -> {return true;};
|
||||||
|
|
||||||
|
Predicate<String> isEmptyKomisch = new IsEmpty();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPredicates() {
|
||||||
|
assertFalse(applyPredicate("Hallo", isEmpty));
|
||||||
|
|
||||||
|
assertTrue(applyPredicate("", isEmpty));
|
||||||
|
|
||||||
|
assertTrue(applyPredicate("", isEmptyKomisch));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean applyPredicate(String s, Predicate<String> tester) {
|
||||||
|
return tester.test(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class IsEmpty implements Predicate<String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean test(String s) {
|
||||||
|
return s.length() == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -68,8 +68,8 @@ public class PrimitiveUndWrapperTest {
|
|||||||
System.out.println("double");
|
System.out.println("double");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String... args) {
|
public static void main(String... args) throws Exception {
|
||||||
new PrimitiveUndWrapperTest().stringConcat();
|
new PrimitiveUndWrapperTest().stringConcat(); // Auch main muss Exceptions deklarieren
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -93,8 +93,7 @@ class Ober {
|
|||||||
class Unter extends Ober {
|
class Unter extends Ober {
|
||||||
@Override
|
@Override
|
||||||
HeaderList getList() {
|
HeaderList getList() {
|
||||||
new Character()
|
super.getList().size();
|
||||||
super.getList().size()
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user