| 1 | package com.github.dakusui.symfonion.compat.json; | |
| 2 | ||
| 3 | import com.google.gson.JsonElement; | |
| 4 | ||
| 5 | import java.io.Serial; | |
| 6 | import java.util.Arrays; | |
| 7 | ||
| 8 | /** | |
| 9 | * Indicates access happens at an index that a JSON array doesn't have. | |
| 10 | */ | |
| 11 | public class JsonIndexOutOfBoundsException extends JsonInvalidPathException { | |
| 12 | ||
| 13 | /** | |
| 14 | * A serial version UID string. | |
| 15 | */ | |
| 16 | @Serial | |
| 17 | private static final long serialVersionUID = -1088233926881743647L; | |
| 18 | ||
| 19 | private final int index; | |
| 20 | ||
| 21 | /** | |
| 22 | * Creates an object of this class. | |
| 23 | * | |
| 24 | * @param base A JSON, where request to `path[index]` is made. | |
| 25 | * @param path A path to an JSON array. | |
| 26 | * @param index An index, where out of bounds access happened. | |
| 27 | */ | |
| 28 | public JsonIndexOutOfBoundsException(JsonElement base, Object[] path, int index) { | |
| 29 | super(base, path); | |
| 30 | this.index = index; | |
| 31 | } | |
| 32 | ||
| 33 | public int getIndex() { | |
| 34 |
1
1. getIndex : replaced int return with 0 for com/github/dakusui/symfonion/compat/json/JsonIndexOutOfBoundsException::getIndex → NO_COVERAGE |
return this.index; |
| 35 | } | |
| 36 | ||
| 37 | @Override | |
| 38 | protected String formatMessage(JsonElement base, Object[] path) { | |
| 39 |
1
1. formatMessage : replaced return value with "" for com/github/dakusui/symfonion/compat/json/JsonIndexOutOfBoundsException::formatMessage → SURVIVED |
return String.format("This element doesn't have path (array out of bounds): %s", Arrays.toString(path)); |
| 40 | } | |
| 41 | } | |
Mutations | ||
| 34 |
1.1 |
|
| 39 |
1.1 |