| 1 | package com.github.dakusui.symfonion.song; | |
| 2 | ||
| 3 | import com.github.dakusui.json.JsonUtils; | |
| 4 | import com.github.dakusui.symfonion.exceptions.SymfonionException; | |
| 5 | import com.google.gson.JsonElement; | |
| 6 | import com.google.gson.JsonObject; | |
| 7 | ||
| 8 | import java.util.HashMap; | |
| 9 | import java.util.Iterator; | |
| 10 | import java.util.Map; | |
| 11 | ||
| 12 | import static com.github.dakusui.symfonion.exceptions.ExceptionThrower.noteNotDefinedException; | |
| 13 | ||
| 14 | ||
| 15 | public class NoteMap { | |
| 16 | public static final NoteMap defaultNoteMap = new NoteMap(Keyword.$normal.name()); | |
| 17 | public static final NoteMap defaultPercussionMap = new NoteMap(Keyword.$percussion.name()); | |
| 18 | protected Map<String, Integer> map = new HashMap<>(); | |
| 19 | private String name; | |
| 20 | static { | |
| 21 | defaultNoteMap.map.put("C", 60); | |
| 22 | defaultNoteMap.map.put("D", 62); | |
| 23 | defaultNoteMap.map.put("E", 64); | |
| 24 | defaultNoteMap.map.put("F", 65); | |
| 25 | defaultNoteMap.map.put("G", 67); | |
| 26 | defaultNoteMap.map.put("A", 69); | |
| 27 | defaultNoteMap.map.put("B", 71); | |
| 28 | defaultPercussionMap.map.put("B", 36); | |
| 29 | defaultPercussionMap.map.put("S", 38); | |
| 30 | defaultPercussionMap.map.put("C", 49); | |
| 31 | defaultPercussionMap.map.put("O", 46); | |
| 32 | defaultPercussionMap.map.put("H", 42); | |
| 33 | defaultPercussionMap.map.put("T", 47); | |
| 34 | } | |
| 35 | public NoteMap(String name) { | |
| 36 | this.name = name; | |
| 37 | } | |
| 38 | public NoteMap(final JsonObject json) { | |
| 39 | Iterator<String> i = JsonUtils.keyIterator(json); | |
| 40 |
1
1. <init> : negated conditional → NO_COVERAGE |
while (i.hasNext()) { |
| 41 | String cur = i.next(); | |
| 42 | int v = json.get(cur).getAsInt(); | |
| 43 | this.map.put(cur, v); | |
| 44 | } | |
| 45 | } | |
| 46 | | |
| 47 | public int note(String notename, JsonElement problemCausingJsonNode) throws SymfonionException { | |
| 48 |
1
1. note : negated conditional → KILLED |
if ("r".equals(notename)) { |
| 49 |
1
1. note : replaced int return with 0 for com/github/dakusui/symfonion/song/NoteMap::note → NO_COVERAGE |
return -1; |
| 50 | } | |
| 51 |
1
1. note : negated conditional → KILLED |
if (!this.map.containsKey(notename)) { |
| 52 | throw noteNotDefinedException(problemCausingJsonNode, notename, this.name); | |
| 53 | } | |
| 54 |
1
1. note : replaced int return with 0 for com/github/dakusui/symfonion/song/NoteMap::note → KILLED |
return this.map.get(notename); |
| 55 | } | |
| 56 | | |
| 57 | public String name() { | |
| 58 |
1
1. name : replaced return value with "" for com/github/dakusui/symfonion/song/NoteMap::name → NO_COVERAGE |
return this.name; |
| 59 | } | |
| 60 | } | |
Mutations | ||
| 40 |
1.1 |
|
| 48 |
1.1 |
|
| 49 |
1.1 |
|
| 51 |
1.1 |
|
| 54 |
1.1 |
|
| 58 |
1.1 |