| 1 | package com.github.valid8j.pcond.experimentals.currying.context; | |
| 2 | ||
| 3 | import com.github.valid8j.pcond.internals.InternalUtils; | |
| 4 | ||
| 5 | import java.util.Formattable; | |
| 6 | import java.util.Formatter; | |
| 7 | import java.util.List; | |
| 8 | ||
| 9 | import static java.util.Collections.singletonList; | |
| 10 | ||
| 11 | /** | |
| 12 | * `Context` is a concept to handle multiple values in the `pcond`. | |
| 13 | */ | |
| 14 | public interface CurriedContext extends Formattable { | |
| 15 | /** | |
| 16 | * Returns the number of context values. | |
| 17 | * | |
| 18 | * @return The number of context values. | |
| 19 | */ | |
| 20 | default int size() { | |
| 21 |
1
1. size : replaced int return with 0 for com/github/valid8j/pcond/experimentals/currying/context/CurriedContext::size → KILLED |
return values().size(); |
| 22 | } | |
| 23 | ||
| 24 | /** | |
| 25 | * Returns the context value specified by the index. | |
| 26 | * | |
| 27 | * @param i The index of the context value to be returned. | |
| 28 | * @param <T> Expected type of the returned context value. | |
| 29 | * @return The specified context value. | |
| 30 | */ | |
| 31 | @SuppressWarnings("unchecked") | |
| 32 | default <T> T valueAt(int i) { | |
| 33 |
1
1. valueAt : replaced return value with null for com/github/valid8j/pcond/experimentals/currying/context/CurriedContext::valueAt → KILLED |
return (T) values().get(i); |
| 34 | } | |
| 35 | ||
| 36 | /** | |
| 37 | * Creates a new context with an appended value. | |
| 38 | * | |
| 39 | * @param o A value to appended | |
| 40 | * @return A new context with the appended value. | |
| 41 | */ | |
| 42 | default CurriedContext append(Object o) { | |
| 43 |
1
1. append : replaced return value with null for com/github/valid8j/pcond/experimentals/currying/context/CurriedContext::append → KILLED |
return new CurriedContext() { |
| 44 | @Override | |
| 45 | public List<Object> values() { | |
| 46 |
1
1. values : replaced return value with Collections.emptyList for com/github/valid8j/pcond/experimentals/currying/context/CurriedContext$1::values → KILLED |
return InternalUtils.append(CurriedContext.this.values(), o); |
| 47 | } | |
| 48 | ||
| 49 | @Override | |
| 50 | public String toString() { | |
| 51 |
1
1. toString : replaced return value with "" for com/github/valid8j/pcond/experimentals/currying/context/CurriedContext$1::toString → KILLED |
return PrivateUtils.variableBundleToString(this); |
| 52 | } | |
| 53 | }; | |
| 54 | } | |
| 55 | ||
| 56 | @Override | |
| 57 | default void formatTo(Formatter formatter, int flags, int width, int precision) { | |
| 58 | formatter.format("%s", PrivateUtils.variableBundleToString(this)); | |
| 59 | } | |
| 60 | ||
| 61 | /** | |
| 62 | * Returns context values. | |
| 63 | * | |
| 64 | * @return context values. | |
| 65 | */ | |
| 66 | List<Object> values(); | |
| 67 | ||
| 68 | /** | |
| 69 | * Creates a new context which has the given value as its only context value. | |
| 70 | * | |
| 71 | * @param o The value for which a new context is created. | |
| 72 | * @return A new context. | |
| 73 | */ | |
| 74 | static CurriedContext from(Object o) { | |
| 75 |
1
1. from : replaced return value with null for com/github/valid8j/pcond/experimentals/currying/context/CurriedContext::from → KILLED |
return new CurriedContext() { |
| 76 | @Override | |
| 77 | public List<Object> values() { | |
| 78 |
1
1. values : replaced return value with Collections.emptyList for com/github/valid8j/pcond/experimentals/currying/context/CurriedContext$2::values → KILLED |
return singletonList(o); |
| 79 | } | |
| 80 | ||
| 81 | @Override | |
| 82 | public String toString() { | |
| 83 |
1
1. toString : replaced return value with "" for com/github/valid8j/pcond/experimentals/currying/context/CurriedContext$2::toString → NO_COVERAGE |
return PrivateUtils.variableBundleToString(this); |
| 84 | } | |
| 85 | ||
| 86 | }; | |
| 87 | } | |
| 88 | ||
| 89 | enum PrivateUtils { | |
| 90 | ; | |
| 91 | ||
| 92 | static String variableBundleToString(CurriedContext curriedContext) { | |
| 93 |
1
1. variableBundleToString : replaced return value with "" for com/github/valid8j/pcond/experimentals/currying/context/CurriedContext$PrivateUtils::variableBundleToString → KILLED |
return "variables:" + curriedContext.values(); |
| 94 | } | |
| 95 | } | |
| 96 | } | |
Mutations | ||
| 21 |
1.1 |
|
| 33 |
1.1 |
|
| 43 |
1.1 |
|
| 46 |
1.1 |
|
| 51 |
1.1 |
|
| 75 |
1.1 |
|
| 78 |
1.1 |
|
| 83 |
1.1 |
|
| 93 |
1.1 |