MethodSignature.java

1
package com.github.dakusui.osynth.core;
2
3
import java.lang.reflect.Method;
4
import java.util.Arrays;
5
import java.util.Objects;
6
7
import static java.util.stream.Collectors.joining;
8
9
public interface MethodSignature {
10
  static MethodSignature create(String name, Class<?>... parameterTypes) {
11 1 1. create : replaced return value with null for com/github/dakusui/osynth/core/MethodSignature::create → KILLED
    return new Impl(name, parameterTypes);
12
  }
13
14
  static MethodSignature create(Method method) {
15 1 1. create : replaced return value with null for com/github/dakusui/osynth/core/MethodSignature::create → KILLED
    return create(method.getName(), method.getParameterTypes());
16
  }
17
18
  static String formatSignature(String methodName, Class<?>[] parameterTypess) {
19 1 1. formatSignature : replaced return value with "" for com/github/dakusui/osynth/core/MethodSignature::formatSignature → KILLED
    return String.format("%s(%s)", methodName, Arrays.stream(parameterTypess).map(Class::getSimpleName).collect(joining(",")));
20
  }
21
22
  String name();
23
24
  Class<?>[] parameterTypes();
25
26
  class Impl implements MethodSignature {
27
28
    private final String     name;
29
    private final Class<?>[] parameterTypes;
30
31
    public Impl(String name, Class<?>[] parameterTypes) {
32
      this.name = name;
33
      this.parameterTypes = parameterTypes;
34
    }
35
36
    @Override
37
    public String name() {
38 1 1. name : replaced return value with "" for com/github/dakusui/osynth/core/MethodSignature$Impl::name → KILLED
      return this.name;
39
    }
40
41
    @Override
42
    public Class<?>[] parameterTypes() {
43 1 1. parameterTypes : replaced return value with null for com/github/dakusui/osynth/core/MethodSignature$Impl::parameterTypes → KILLED
      return Arrays.copyOf(this.parameterTypes, this.parameterTypes.length);
44
    }
45
46
    @Override
47
    public int hashCode() {
48 1 1. hashCode : replaced int return with 0 for com/github/dakusui/osynth/core/MethodSignature$Impl::hashCode → SURVIVED
      return this.name.hashCode();
49
    }
50
51
    @Override
52
    public boolean equals(Object anotherObject) {
53 1 1. equals : negated conditional → KILLED
      if (!(anotherObject instanceof MethodSignature))
54 1 1. equals : replaced boolean return with true for com/github/dakusui/osynth/core/MethodSignature$Impl::equals → KILLED
        return false;
55
      MethodSignature another = (MethodSignature) anotherObject;
56 3 1. equals : negated conditional → KILLED
2. equals : negated conditional → KILLED
3. equals : replaced boolean return with true for com/github/dakusui/osynth/core/MethodSignature$Impl::equals → KILLED
      return Objects.equals(this.name(), another.name()) && Arrays.equals(this.parameterTypes(), another.parameterTypes());
57
    }
58
59
    @Override
60
    public String toString() {
61 1 1. toString : replaced return value with "" for com/github/dakusui/osynth/core/MethodSignature$Impl::toString → KILLED
      return formatSignature(this.name, this.parameterTypes);
62
    }
63
  }
64
}

Mutations

11

1.1
Location : create
Killed by : com.github.dakusui.osynth.ut.core.MethodSignatureTest.nonMethodSignatureInstance(com.github.dakusui.osynth.ut.core.MethodSignatureTest)
replaced return value with null for com/github/dakusui/osynth/core/MethodSignature::create → KILLED

15

1.1
Location : create
Killed by : com.github.dakusui.osynth.ut.ValidationTest.givenValidationLeftDefault$whenOneReservedMethodTriedOverridden$thenExceptionThrown(com.github.dakusui.osynth.ut.ValidationTest)
replaced return value with null for com/github/dakusui/osynth/core/MethodSignature::create → KILLED

19

1.1
Location : formatSignature
Killed by : com.github.dakusui.osynth.ut.core.utils.MethodUtilsTest.testGetMethodFromClass$whenMethodNotFound$thenUnsupportedOperationExceptionRethrown(com.github.dakusui.osynth.ut.core.utils.MethodUtilsTest)
replaced return value with "" for com/github/dakusui/osynth/core/MethodSignature::formatSignature → KILLED

38

1.1
Location : name
Killed by : com.github.dakusui.osynth.ut.core.MethodSignatureTest.differentNameMethodSignatures(com.github.dakusui.osynth.ut.core.MethodSignatureTest)
replaced return value with "" for com/github/dakusui/osynth/core/MethodSignature$Impl::name → KILLED

43

1.1
Location : parameterTypes
Killed by : com.github.dakusui.osynth.ut.core.MethodSignatureTest.overloadedMethodSignature(com.github.dakusui.osynth.ut.core.MethodSignatureTest)
replaced return value with null for com/github/dakusui/osynth/core/MethodSignature$Impl::parameterTypes → KILLED

48

1.1
Location : hashCode
Killed by : none
replaced int return with 0 for com/github/dakusui/osynth/core/MethodSignature$Impl::hashCode → SURVIVED

53

1.1
Location : equals
Killed by : com.github.dakusui.osynth.ut.core.MethodSignatureTest.nonMethodSignatureInstance(com.github.dakusui.osynth.ut.core.MethodSignatureTest)
negated conditional → KILLED

54

1.1
Location : equals
Killed by : com.github.dakusui.osynth.ut.core.MethodSignatureTest.nonMethodSignatureInstance(com.github.dakusui.osynth.ut.core.MethodSignatureTest)
replaced boolean return with true for com/github/dakusui/osynth/core/MethodSignature$Impl::equals → KILLED

56

1.1
Location : equals
Killed by : com.github.dakusui.osynth.ut.core.MethodSignatureTest.sameReferencesEqual(com.github.dakusui.osynth.ut.core.MethodSignatureTest)
negated conditional → KILLED

2.2
Location : equals
Killed by : com.github.dakusui.osynth.ut.core.MethodSignatureTest.sameReferencesEqual(com.github.dakusui.osynth.ut.core.MethodSignatureTest)
negated conditional → KILLED

3.3
Location : equals
Killed by : com.github.dakusui.osynth.ut.core.MethodSignatureTest.differentNameMethodSignatures(com.github.dakusui.osynth.ut.core.MethodSignatureTest)
replaced boolean return with true for com/github/dakusui/osynth/core/MethodSignature$Impl::equals → KILLED

61

1.1
Location : toString
Killed by : com.github.dakusui.osynth.ut.core.utils.MethodUtilsTest.testGetMethodFromClass$whenMethodNotFound$thenUnsupportedOperationExceptionRethrown(com.github.dakusui.osynth.ut.core.utils.MethodUtilsTest)
replaced return value with "" for com/github/dakusui/osynth/core/MethodSignature$Impl::toString → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3