An enum holding tones.
| 15 | * An enum holding tones. |
| 16 | */ |
| 17 | public enum Tone { |
| 18 | G(0x1, true), |
| 19 | A(0x3, true), |
| 20 | B(0x5, false), |
| 21 | C(0x6, true), |
| 22 | D(0x8, true), |
| 23 | E(0xA, false), |
| 24 | F(0xB, true); |
| 25 | |
| 26 | private final boolean sharpable; |
| 27 | private final byte id; |
| 28 | |
| 29 | private static final Map<Byte, Note.Tone> BY_DATA = Maps.newHashMap(); |
| 30 | /** The number of tones including sharped tones. */ |
| 31 | public static final byte TONES_COUNT = 12; |
| 32 | |
| 33 | private Tone(int id, boolean sharpable) { |
| 34 | this.id = (byte) (id % TONES_COUNT); |
| 35 | this.sharpable = sharpable; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Returns the not sharped id of this tone. |
| 40 | * |
| 41 | * @return the not sharped id of this tone. |
| 42 | * @apiNote Internal Use Only |
| 43 | */ |
| 44 | @org.jetbrains.annotations.ApiStatus.Internal // Paper |
| 45 | public byte getId() { |
| 46 | return getId(false); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Returns the id of this tone. These method allows to return the |
| 51 | * sharped id of the tone. If the tone couldn't be sharped it always |
| 52 | * return the not sharped id of this tone. |
| 53 | * |
| 54 | * @param sharped Set to true to return the sharped id. |
| 55 | * @return the id of this tone. |
| 56 | * @apiNote Internal Use Only |
| 57 | */ |
| 58 | @org.jetbrains.annotations.ApiStatus.Internal // Paper |
| 59 | public byte getId(boolean sharped) { |
| 60 | byte id = (byte) (sharped && sharpable ? this.id + 1 : this.id); |
| 61 | |
| 62 | return (byte) (id % TONES_COUNT); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Returns if this tone could be sharped. |
| 67 | * |
| 68 | * @return if this tone could be sharped. |
| 69 | */ |
| 70 | public boolean isSharpable() { |
| 71 | return sharpable; |
| 72 | } |
| 73 | |
| 74 | /** |
nothing calls this directly
no test coverage detected