AbstractObjectChecker.java

1
package com.github.valid8j.pcond.core.fluent;
2
3
import com.github.valid8j.pcond.core.refl.MethodQuery;
4
import com.github.valid8j.pcond.forms.Functions;
5
import com.github.valid8j.pcond.forms.Predicates;
6
7
/**
8
 * // @formatter:off
9
 * An interface that defines to check a target object.
10
 * // @formatter:on
11
 */
12
public interface AbstractObjectChecker<
13
    V extends Checker<V, T, R>,
14
    T,
15
    R> extends
16
    Checker<V, T, R> {
17
  /**
18
   * Adds a predicate to this checker object to check if the target object is NOT `null`.
19
   *
20
   * @return The updated checker object.
21
   */
22
  default V notNull() {
23 1 1. notNull : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::notNull → KILLED
    return this.checkWithPredicate(Predicates.isNotNull());
24
  }
25
26
  /**
27
   * Adds a predicate to this checker object to check if the target object IS `null`.
28
   *
29
   * @return The updated checker object.
30
   */
31
  default V nullValue() {
32 1 1. nullValue : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::nullValue → KILLED
    return this.checkWithPredicate(Predicates.isNull());
33
  }
34
35
  /**
36
   * Adds a predicate to this checker object to check the target object with the argument for `anotherObject` if they
37
   * are "equal", using `equalTo` method.
38
   *
39
   * @param anotherObject An object with which the target object of this checker should be checked.
40
   * @return The updated checker object.
41
   */
42
  default V equalTo(Object anotherObject) {
43 1 1. equalTo : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::equalTo → KILLED
    return this.checkWithPredicate(Predicates.isEqualTo(anotherObject));
44
  }
45
46
  /**
47
   * Adds a predicate to this checker object to check the target object and the argument for `anotherObject` if they
48
   * are referencing the same object.
49
   *
50
   * @param anotherObject An object with which the target object of this checker should be checked.
51
   * @return The updated checker object.
52
   */
53
  default V sameReferenceAs(Object anotherObject) {
54 1 1. sameReferenceAs : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::sameReferenceAs → KILLED
    return this.checkWithPredicate(Predicates.isSameReferenceAs(anotherObject));
55
  }
56
57
  /**
58
   * Adds a predicate to this checker object to check if the target object is an instance of `Class klass`.
59
   *
60
   * @param klass A class to check if the target object is an instance of.
61
   * @return The updated checker object.
62
   */
63
  default V instanceOf(Class<?> klass) {
64 1 1. instanceOf : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::instanceOf → KILLED
    return this.checkWithPredicate(Predicates.isInstanceOf(klass));
65
  }
66
67
  /**
68
   * Adds a predicate to this checker object to check if the target object returns `true` if a method specified by
69
   * `methodName` and `args` is invoked.
70
   * The method to be invoked is chosen by {@link MethodQuery#instanceMethod(Object, String, Object[])}.
71
   *
72
   * @param methodName A nme of method to be invoked.
73
   * @param args       Arguments to be passed by the method.
74
   * @return The updated object.
75
   * @see MethodQuery#instanceMethod(Object, String, Object[])
76
   */
77
  default V invoke(String methodName, Object... args) {
78 1 1. invoke : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::invoke → KILLED
    return this.checkWithPredicate(Predicates.callp(MethodQuery.instanceMethod(Functions.parameter(), methodName, args)));
79
  }
80
81
  /**
82
   * Checks if a static method specified by `klass`, `methodName`, and `args`.
83
   * The method to be invoked is chosen by {@link MethodQuery#classMethod(Class, String, Object[])}.
84
   * To specify the target object as an argument, you can use the value returned from {@link Functions#parameter()}.
85
   *
86
   * @param klass      A class to which the static method to be invoked belongs.
87
   * @param methodName The name of the method to be invoked.
88
   * @param args       Arguments to be passed to the method to be invoked.
89
   * @see MethodQuery#classMethod(Class, String, Object[])
90
   */
91
  default V invokeStatic(Class<?> klass, String methodName, Object... args) {
92 1 1. invokeStatic : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::invokeStatic → KILLED
    return this.checkWithPredicate(Predicates.callp(MethodQuery.classMethod(klass, methodName, args)));
93
  }
94
}

Mutations

23

1.1
Location : notNull
Killed by : com.github.valid8j.ut.styles.FluentStyleDbCTest$ForEnsuresTest.test_postcondition(com.github.valid8j.ut.styles.FluentStyleDbCTest$ForEnsuresTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::notNull → KILLED

32

1.1
Location : nullValue
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[4: Given::When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::nullValue → KILLED

43

1.1
Location : equalTo
Killed by : com.github.valid8j.ut.styles.FluentStyleTestAssertionTest$ForTestAssertionsTest.boolean_assertThatTest_passed(com.github.valid8j.ut.styles.FluentStyleTestAssertionTest$ForTestAssertionsTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::equalTo → KILLED

54

1.1
Location : sameReferenceAs
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[4: Given::When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::sameReferenceAs → KILLED

64

1.1
Location : instanceOf
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[4: Given::When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::instanceOf → KILLED

78

1.1
Location : invoke
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[4: Given::When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::invoke → KILLED

92

1.1
Location : invokeStatic
Killed by : com.github.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[4: Given::When::Then:greaterThanOrEqualTo(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThanOrEqualTo(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectChecker::invokeStatic → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3