@Override public ENUM convert(String s, Object hint) { if (HINT_STRICT == hint) { return Enum.valueOf(enumClass, s); } Enum[] enums = enumClass.getEnumConstants(); for (Enum e : enums) { if (Keyword.of(e.name()).equals(Keyword.of(s))) { return (ENUM) e; } } throw new IllegalArgumentException("No enum constant " + enumClass.getCanonicalName() + "." + s); } };
@Override public ENUM convert(String s, Object hint) { if (HINT_STRICT == hint) { return Enum.valueOf(enumClass, s); } Enum[] enums = enumClass.getEnumConstants(); for (Enum e : enums) { if (Keyword.of(e.name()).equals(Keyword.of(s))) { return (ENUM) e; } } throw new IllegalArgumentException("No enum constant " + enumClass.getCanonicalName() + "." + s); } };
/** * Check if two {@link CharSequence}s are keyword identical. * * This method is an alias of {@link #equals(CharSequence, CharSequence)}. * * @param a * the first char sequence * @param b * the second char sequence * @return `true` if `a` and `b` are keyword identical */ public static boolean eq(CharSequence a, CharSequence b) { return of(a).equals(of(b)); }
/** * Check if two {@link CharSequence}s are keyword identical. * * This method is an alias of {@link #equals(CharSequence, CharSequence)}. * * @param a * the first char sequence * @param b * the second char sequence * @return `true` if `a` and `b` are keyword identical */ public static boolean eq(CharSequence a, CharSequence b) { return of(a).equals(of(b)); }
private void parseParamPart(String s) { if ("true".equalsIgnoreCase(s)) { highPrecision = true; } else if ("false".equalsIgnoreCase(s)) { highPrecision = false; } else if (Keyword.of("highPrecision").equals(Keyword.of(s))) { highPrecision = true; } else if (Keyword.of("lowPrecision").equals(Keyword.of(s))) { highPrecision = false; } else if ("hp".equalsIgnoreCase(s)) { highPrecision = true; } else if ("lp".equalsIgnoreCase(s)) { highPrecision = false; } else if (s.startsWith("+")) { s = s.substring(1); delta = Time.parseDuration(s); } else { if (S.isInt(s)) { delta = Integer.parseInt(s); } else if (s.startsWith("-")) { s = s.substring(1); delta = -Time.parseDuration(s); } else { throw new UnexpectedException("Unknown time parameter: " + s); } } }
private void parseParamPart(String s) { if ("true".equalsIgnoreCase(s)) { highPrecision = true; } else if ("false".equalsIgnoreCase(s)) { highPrecision = false; } else if (Keyword.of("highPrecision").equals(Keyword.of(s))) { highPrecision = true; } else if (Keyword.of("lowPrecision").equals(Keyword.of(s))) { highPrecision = false; } else if ("hp".equalsIgnoreCase(s)) { highPrecision = true; } else if ("lp".equalsIgnoreCase(s)) { highPrecision = false; } else if (s.startsWith("+")) { s = s.substring(1); delta = Time.parseDuration(s); } else { if (S.isInt(s)) { delta = Integer.parseInt(s); } else if (s.startsWith("-")) { s = s.substring(1); delta = -Time.parseDuration(s); } else { throw new UnexpectedException("Unknown time parameter: " + s); } } }