| 1 | package com.github.dakusui.osynth.core.utils; | |
| 2 | ||
| 3 | import com.github.dakusui.osynth.core.MethodHandlerEntry; | |
| 4 | import com.github.dakusui.osynth.core.SynthesizedObject; | |
| 5 | ||
| 6 | import java.lang.annotation.Annotation; | |
| 7 | import java.lang.reflect.Method; | |
| 8 | import java.util.*; | |
| 9 | import java.util.function.Function; | |
| 10 | import java.util.function.Predicate; | |
| 11 | ||
| 12 | import static com.github.dakusui.pcond.core.refl.MethodQuery.instanceMethod; | |
| 13 | import static com.github.dakusui.pcond.forms.Functions.call; | |
| 14 | import static com.github.dakusui.pcond.forms.Functions.parameter; | |
| 15 | import static com.github.dakusui.pcond.forms.Predicates.callp; | |
| 16 | import static com.github.dakusui.pcond.forms.Printables.function; | |
| 17 | import static com.github.dakusui.pcond.forms.Printables.predicate; | |
| 18 | ||
| 19 | public enum AssertionUtils { | |
| 20 | ; | |
| 21 | ||
| 22 | public static Function<Class<?>, Method> classGetMethod(String name, Class<?>[] parameterTypes) { | |
| 23 |
1
1. classGetMethod : replaced return value with null for com/github/dakusui/osynth/core/utils/AssertionUtils::classGetMethod → KILLED |
return call(instanceMethod(parameter(), "getMethod", name, parameterTypes)); |
| 24 | } | |
| 25 | ||
| 26 | public static Function<SynthesizedObject.Descriptor, Object> descriptorFallbackObject() { | |
| 27 |
1
1. descriptorFallbackObject : replaced return value with null for com/github/dakusui/osynth/core/utils/AssertionUtils::descriptorFallbackObject → KILLED |
return call(instanceMethod(parameter(), "fallbackObject")); |
| 28 | } | |
| 29 | ||
| 30 | public static Function<SynthesizedObject.Descriptor, List<MethodHandlerEntry>> descriptorMethodHandlerEntries() { | |
| 31 |
1
1. descriptorMethodHandlerEntries : replaced return value with null for com/github/dakusui/osynth/core/utils/AssertionUtils::descriptorMethodHandlerEntries → KILLED |
return call(instanceMethod(parameter(), "methodHandlerEntries")); |
| 32 | } | |
| 33 | ||
| 34 | public static Function<SynthesizedObject.Descriptor, List<Class<?>>> descriptorInterfaces() { | |
| 35 |
1
1. descriptorInterfaces : replaced return value with null for com/github/dakusui/osynth/core/utils/AssertionUtils::descriptorInterfaces → KILLED |
return call(instanceMethod(parameter(), "interfaces")); |
| 36 | } | |
| 37 | ||
| 38 | public static Predicate<Method> methodIsAnnotationPresent(Class<? extends Annotation> annotation) { | |
| 39 |
1
1. methodIsAnnotationPresent : replaced return value with null for com/github/dakusui/osynth/core/utils/AssertionUtils::methodIsAnnotationPresent → KILLED |
return callp(instanceMethod(parameter(), "isAnnotationPresent", annotation)); |
| 40 | } | |
| 41 | ||
| 42 | public static <E> Function<Collection<E>, List<E>> collectionDuplicatedElements() { | |
| 43 |
1
1. collectionDuplicatedElements : replaced return value with null for com/github/dakusui/osynth/core/utils/AssertionUtils::collectionDuplicatedElements → KILLED |
return function("duplicatedElements", AssertionUtils::duplicatedElementsIn); |
| 44 | } | |
| 45 | ||
| 46 | public static <E> List<E> duplicatedElementsIn(Collection<E> collection) { | |
| 47 | HashSet<E> appeared = new HashSet<>(); | |
| 48 | LinkedHashSet<E> duplication = new LinkedHashSet<>(); | |
| 49 |
1
1. duplicatedElementsIn : removed call to java/util/Collection::forEach → KILLED |
collection.forEach(each -> { |
| 50 |
1
1. lambda$duplicatedElementsIn$0 : negated conditional → KILLED |
if (!appeared.contains(each)) |
| 51 | appeared.add(each); | |
| 52 | else { | |
| 53 | duplication.add(each); | |
| 54 | } | |
| 55 | }); | |
| 56 |
1
1. duplicatedElementsIn : replaced return value with Collections.emptyList for com/github/dakusui/osynth/core/utils/AssertionUtils::duplicatedElementsIn → KILLED |
return new ArrayList<>(duplication); |
| 57 | } | |
| 58 | ||
| 59 | public static <T> Predicate<Class<T>> classIsInterface() { | |
| 60 |
1
1. classIsInterface : replaced return value with null for com/github/dakusui/osynth/core/utils/AssertionUtils::classIsInterface → KILLED |
return predicate("isInterface", Class::isInterface); |
| 61 | } | |
| 62 | } | |
Mutations | ||
| 23 |
1.1 |
|
| 27 |
1.1 |
|
| 31 |
1.1 |
|
| 35 |
1.1 |
|
| 39 |
1.1 |
|
| 43 |
1.1 |
|
| 49 |
1.1 |
|
| 50 |
1.1 |
|
| 56 |
1.1 |
|
| 60 |
1.1 |