1 | package com.github.valid8j.metamor; | |
2 | ||
3 | import java.util.ArrayList; | |
4 | import java.util.Iterator; | |
5 | import java.util.List; | |
6 | import java.util.stream.Stream; | |
7 | import java.util.stream.StreamSupport; | |
8 | ||
9 | import static java.util.Collections.unmodifiableList; | |
10 | import static java.util.Objects.requireNonNull; | |
11 | ||
12 | public interface Dataset<E> extends Iterable<E> { | |
13 | String name(); | |
14 | ||
15 | E get(int i); | |
16 | ||
17 | int size(); | |
18 | ||
19 | default E last() { | |
20 |
2
1. last : replaced return value with null for com/github/valid8j/metamor/Dataset::last → SURVIVED 2. last : Replaced integer subtraction with addition → KILLED |
return this.get(this.size() - 1); |
21 | } | |
22 | ||
23 | default Stream<E> stream() { | |
24 |
1
1. stream : replaced return value with Stream.empty for com/github/valid8j/metamor/Dataset::stream → KILLED |
return StreamSupport.stream(this.spliterator(), false); |
25 | } | |
26 | ||
27 | abstract class Base<E> implements Dataset<E> { | |
28 | private final String name; | |
29 | ||
30 | Base(String name) { | |
31 | this.name = requireNonNull(name); | |
32 | } | |
33 | ||
34 | public String name() { | |
35 |
1
1. name : replaced return value with "" for com/github/valid8j/metamor/Dataset$Base::name → SURVIVED |
return this.name; |
36 | } | |
37 | } | |
38 | ||
39 | interface OnGoing<E> extends Dataset<E> { | |
40 | OnGoing<E> add(E value); | |
41 | ||
42 | Dataset<E> close(); | |
43 | ||
44 | class Impl<E> extends Base<E> implements OnGoing<E> { | |
45 | final List<E> content; | |
46 | ||
47 | public Impl(String name) { | |
48 | super(name); | |
49 | this.content = new ArrayList<>(); | |
50 | } | |
51 | ||
52 | public Impl(String name, Dataset<E> content) { | |
53 | this(name); | |
54 |
2
1. <init> : changed conditional boundary → KILLED 2. <init> : negated conditional → KILLED |
for (int i = 0; i < content.size(); i++) |
55 | this.add(content.get(i)); | |
56 | } | |
57 | ||
58 | @Override | |
59 | public E get(int i) { | |
60 |
1
1. get : replaced return value with null for com/github/valid8j/metamor/Dataset$OnGoing$Impl::get → KILLED |
return this.content.get(i); |
61 | } | |
62 | ||
63 | @Override | |
64 | public int size() { | |
65 |
1
1. size : replaced int return with 0 for com/github/valid8j/metamor/Dataset$OnGoing$Impl::size → KILLED |
return this.content.size(); |
66 | } | |
67 | ||
68 | @Override | |
69 | public OnGoing<E> add(E value) { | |
70 | this.content.add(value); | |
71 |
1
1. add : replaced return value with null for com/github/valid8j/metamor/Dataset$OnGoing$Impl::add → SURVIVED |
return this; |
72 | } | |
73 | ||
74 | @Override | |
75 | public Dataset<E> close() { | |
76 |
1
1. close : replaced return value with null for com/github/valid8j/metamor/Dataset$OnGoing$Impl::close → KILLED |
return new Closed.Impl<>(this.name(), this.content); |
77 | } | |
78 | ||
79 | @Override | |
80 | public Iterator<E> iterator() { | |
81 |
1
1. iterator : replaced return value with null for com/github/valid8j/metamor/Dataset$OnGoing$Impl::iterator → NO_COVERAGE |
return this.content.iterator(); |
82 | } | |
83 | ||
84 | @Override | |
85 | public String toString() { | |
86 |
1
1. toString : negated conditional → NO_COVERAGE |
if (this.size() == 0) |
87 |
1
1. toString : replaced return value with "" for com/github/valid8j/metamor/Dataset$OnGoing$Impl::toString → NO_COVERAGE |
return this.name() + ":(empty)"; |
88 |
1
1. toString : replaced return value with "" for com/github/valid8j/metamor/Dataset$OnGoing$Impl::toString → NO_COVERAGE |
return this.name() + ":" + last(); |
89 | } | |
90 | } | |
91 | } | |
92 | ||
93 | interface Closed<E> extends Dataset<E> { | |
94 | class Impl<E> extends Base<E> implements Closed<E> { | |
95 | final List<E> content; | |
96 | ||
97 | public Impl(String name, List<E> content) { | |
98 | super(name); | |
99 | this.content = unmodifiableList(content); | |
100 | } | |
101 | ||
102 | @Override | |
103 | public E get(int i) { | |
104 |
1
1. get : replaced return value with null for com/github/valid8j/metamor/Dataset$Closed$Impl::get → KILLED |
return this.content.get(i); |
105 | } | |
106 | ||
107 | @Override | |
108 | public int size() { | |
109 |
1
1. size : replaced int return with 0 for com/github/valid8j/metamor/Dataset$Closed$Impl::size → SURVIVED |
return this.content.size(); |
110 | } | |
111 | ||
112 | @Override | |
113 | public Iterator<E> iterator() { | |
114 |
1
1. iterator : replaced return value with null for com/github/valid8j/metamor/Dataset$Closed$Impl::iterator → KILLED |
return this.content.iterator(); |
115 | } | |
116 | ||
117 | @Override | |
118 | public String toString() { | |
119 |
1
1. toString : replaced return value with "" for com/github/valid8j/metamor/Dataset$Closed$Impl::toString → SURVIVED |
return this.name() + ":" + this.content; |
120 | } | |
121 | } | |
122 | } | |
123 | } | |
Mutations | ||
20 |
1.1 2.2 |
|
24 |
1.1 |
|
35 |
1.1 |
|
54 |
1.1 2.2 |
|
60 |
1.1 |
|
65 |
1.1 |
|
71 |
1.1 |
|
76 |
1.1 |
|
81 |
1.1 |
|
86 |
1.1 |
|
87 |
1.1 |
|
88 |
1.1 |
|
104 |
1.1 |
|
109 |
1.1 |
|
114 |
1.1 |
|
119 |
1.1 |