Redone hewbrew char lookup
This commit is contained in:
parent
887399e49c
commit
577cc68a61
|
@ -61,7 +61,7 @@ public class Gê̄ldGetậl {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (geldDigit != null) {
|
if (geldDigit != null) {
|
||||||
HebrewDigitVowel vowel = HebrewDigitVowel.valueOf(codePoint);
|
HebrewDigitVowel vowel = HebrewDigitVowel.valueOfCharacter(codePoint);
|
||||||
if (!HebrewDigitVowel.NONE.equals(vowel)) {
|
if (!HebrewDigitVowel.NONE.equals(vowel)) {
|
||||||
geldDigit.setVowel(vowel);
|
geldDigit.setVowel(vowel);
|
||||||
result.add(geldDigit);
|
result.add(geldDigit);
|
||||||
|
@ -71,7 +71,7 @@ public class Gê̄ldGetậl {
|
||||||
result.add(geldDigit);
|
result.add(geldDigit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HebrewDigitLetter letter = HebrewDigitLetter.valueOf(codePoint);
|
HebrewDigitLetter letter = HebrewDigitLetter.valueOfCharacter(codePoint);
|
||||||
if (HebrewDigitLetter.NONE.equals(letter)) {
|
if (HebrewDigitLetter.NONE.equals(letter)) {
|
||||||
throw new IllegalArgumentException("Unknown fraction codepoint: 0x"+Integer.toHexString(codePoint));
|
throw new IllegalArgumentException("Unknown fraction codepoint: 0x"+Integer.toHexString(codePoint));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
package love.distributedrebirth.demo4d.fraction4d;
|
package love.distributedrebirth.demo4d.fraction4d;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author willemtsade ©Δ∞ 仙上主天
|
* @author willemtsade ©Δ∞ 仙上主天
|
||||||
|
@ -75,6 +80,9 @@ public enum HebrewDigitLetter {
|
||||||
private final int decimal;
|
private final int decimal;
|
||||||
private final char character;
|
private final char character;
|
||||||
|
|
||||||
|
private static final Map<Character, HebrewDigitLetter> CHAR_MAP = Collections.unmodifiableMap(
|
||||||
|
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getCharacter(), v -> v)));
|
||||||
|
|
||||||
private HebrewDigitLetter(int decimal, char character) {
|
private HebrewDigitLetter(int decimal, char character) {
|
||||||
this.decimal = decimal;
|
this.decimal = decimal;
|
||||||
this.character = character;
|
this.character = character;
|
||||||
|
@ -92,12 +100,7 @@ public enum HebrewDigitLetter {
|
||||||
return values()[index & BITMASK];
|
return values()[index & BITMASK];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HebrewDigitLetter valueOf(char codePoint) {
|
public static HebrewDigitLetter valueOfCharacter(char codePoint) {
|
||||||
for (HebrewDigitLetter vowel:values()) {
|
return CHAR_MAP.getOrDefault(codePoint, HebrewDigitLetter.NONE);
|
||||||
if (vowel.getCharacter() == codePoint) {
|
|
||||||
return vowel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return HebrewDigitLetter.NONE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
package love.distributedrebirth.demo4d.fraction4d;
|
package love.distributedrebirth.demo4d.fraction4d;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author willemtsade ©Δ∞ 仙上主天
|
* @author willemtsade ©Δ∞ 仙上主天
|
||||||
|
@ -28,6 +33,9 @@ public enum HebrewDigitVowel {
|
||||||
private final int fractionOffset;
|
private final int fractionOffset;
|
||||||
private final char character;
|
private final char character;
|
||||||
|
|
||||||
|
private static final Map<Character, HebrewDigitVowel> CHAR_MAP = Collections.unmodifiableMap(
|
||||||
|
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getCharacter(), v -> v)));
|
||||||
|
|
||||||
private HebrewDigitVowel(int fractionOffset, char character) {
|
private HebrewDigitVowel(int fractionOffset, char character) {
|
||||||
this.fractionOffset = fractionOffset;
|
this.fractionOffset = fractionOffset;
|
||||||
this.character = character;
|
this.character = character;
|
||||||
|
@ -45,12 +53,7 @@ public enum HebrewDigitVowel {
|
||||||
return values()[index & BITMASK];
|
return values()[index & BITMASK];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HebrewDigitVowel valueOf(char codePoint) {
|
public static HebrewDigitVowel valueOfCharacter(char codePoint) {
|
||||||
for (HebrewDigitVowel vowel:values()) {
|
return CHAR_MAP.getOrDefault(codePoint, HebrewDigitVowel.NONE);
|
||||||
if (vowel.getCharacter() == codePoint) {
|
|
||||||
return vowel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return HebrewDigitVowel.NONE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue