| 1 | package com.roxoft.lib; | |
| 2 | ||
| 3 | import java.util.Arrays; | |
| 4 | ||
| 5 | public final class Analyse { | |
| 6 | /** The value to be analysed. */ | |
| 7 | private final String value; | |
| 8 | ||
| 9 | private Analyse(final String input) { | |
| 10 | this.value = input; | |
| 11 | } | |
| 12 | ||
| 13 | /** | |
| 14 | * @param input the value to be analysed. | |
| 15 | * @return a new {@link Analyse} object for running analysis. | |
| 16 | */ | |
| 17 | public static Analyse string(final String input) { | |
| 18 |
1
1. string : replaced return value with null for com/roxoft/lib/Analyse::string → KILLED |
return new Analyse(input); |
| 19 | } | |
| 20 | ||
| 21 | /** | |
| 22 | * @param numberOfRepetitions a number of expected repeitions of a given character. | |
| 23 | * @param repeatingCharacter a character expected to repeat a given number of times. | |
| 24 | * @return true if given character repeats given number of times, false otherwise. | |
| 25 | */ | |
| 26 | public boolean startsWith(final int numberOfRepetitions, final char repeatingCharacter) { | |
| 27 |
2
1. startsWith : changed conditional boundary → SURVIVED 2. startsWith : negated conditional → KILLED |
if (value.length() < numberOfRepetitions) { |
| 28 |
1
1. startsWith : replaced boolean return with true for com/roxoft/lib/Analyse::startsWith → KILLED |
return false; |
| 29 | } | |
| 30 | ||
| 31 | char[] charArray = new char[numberOfRepetitions]; | |
| 32 |
1
1. startsWith : removed call to java/util/Arrays::fill → KILLED |
Arrays.fill(charArray, repeatingCharacter); |
| 33 | final String prefix = new String(charArray); | |
| 34 | ||
| 35 |
2
1. startsWith : replaced boolean return with false for com/roxoft/lib/Analyse::startsWith → KILLED 2. startsWith : replaced boolean return with true for com/roxoft/lib/Analyse::startsWith → KILLED |
return value.startsWith(prefix); |
| 36 | } | |
| 37 | } | |
Mutations | ||
| 18 |
1.1 |
|
| 27 |
1.1 2.2 |
|
| 28 |
1.1 |
|
| 32 |
1.1 |
|
| 35 |
1.1 2.2 |