@Test public void testPropertyNameFromGetter() { assertFalse(BeanAnalyzer.propertyNameFromGetter("get").isPresent()); assertFalse(BeanAnalyzer.propertyNameFromGetter("xyz").isPresent()); assertFalse(BeanAnalyzer.propertyNameFromGetter("setXyz").isPresent()); assertFalse(BeanAnalyzer.propertyNameFromGetter("getxyz").isPresent()); assertEquals("x", BeanAnalyzer.propertyNameFromGetter("getX").get()); assertEquals("xyz", BeanAnalyzer.propertyNameFromGetter("getXyz").get()); assertEquals("xyzAbc", BeanAnalyzer.propertyNameFromGetter("getXyzAbc").get()); assertEquals("xyz", BeanAnalyzer.propertyNameFromGetter("isXyz").get()); }
public static Optional<String> propertyNameFromGetter(String maybeGetter) { Matcher matcher = GETTER.matcher(maybeGetter); if (!matcher.find()) { return Optional.empty(); } String raw = matcher.group(2); if (raw.equals("Class")) { return Optional.empty(); } return Optional.of(Character.toLowerCase(raw.charAt(0)) + raw.substring(1)); }
BeanAnalyzer { public static Optional<String> propertyNameFromGetter(String maybeGetter) { Matcher matcher = GETTER.matcher(maybeGetter); if (!matcher.find()) { return Optional.empty(); } String raw = matcher.group(2); if (raw.equals("Class")) { return Optional.empty(); } return Optional.of(Character.toLowerCase(raw.charAt(0)) + raw.substring(1)); } }
BeanAnalyzer { public static Optional<String> propertyNameFromGetter(String maybeGetter) { Matcher matcher = GETTER.matcher(maybeGetter); if (!matcher.find()) { return Optional.empty(); } String raw = matcher.group(2); if (raw.equals("Class")) { return Optional.empty(); } return Optional.of(Character.toLowerCase(raw.charAt(0)) + raw.substring(1)); }  }
BeanAnalyzer { public static Optional<String> propertyNameFromGetter(String maybeGetter) { Matcher matcher = GETTER.matcher(maybeGetter); if (!matcher.find()) { return Optional.empty(); } String raw = matcher.group(2); if (raw.equals("Class")) { return Optional.empty(); } return Optional.of(Character.toLowerCase(raw.charAt(0)) + raw.substring(1)); }  static Stream<PropertyGetter> findGetters(Class<?> type); static Optional<String> propertyNameFromGetter(String maybeGetter); static Stream<PropertySetter> findSetters(Class<?> type); static Optional<String> propertyNameFromSetter(String maybeSetter); }
BeanAnalyzer { public static Optional<String> propertyNameFromGetter(String maybeGetter) { Matcher matcher = GETTER.matcher(maybeGetter); if (!matcher.find()) { return Optional.empty(); } String raw = matcher.group(2); if (raw.equals("Class")) { return Optional.empty(); } return Optional.of(Character.toLowerCase(raw.charAt(0)) + raw.substring(1)); }  static Stream<PropertyGetter> findGetters(Class<?> type); static Optional<String> propertyNameFromGetter(String maybeGetter); static Stream<PropertySetter> findSetters(Class<?> type); static Optional<String> propertyNameFromSetter(String maybeSetter);  }