/** * Returns the getter method according to the java beans specification for a * given property. * * @param clazz the class in which the method should be searched * @param property the name of the property for which the getter is requested * @return the <tt>Method</tt> which is used to get the value * @throws IllegalArgumentException if the getter cannot be obtained */ @Nonnull @SuppressWarnings("squid:S1141") @Explain("A nested catch block seems to be the most readable solution here") public static Method getter(@Nonnull Class<?> clazz, @Nonnull String property) { try { try { return clazz.getMethod("get" + toFirstUpper(property)); } catch (NoSuchMethodException e) { Exceptions.ignore(e); return getterAsIs(clazz, property); } } catch (Exception e) { throw new IllegalArgumentException(Strings.apply("get-Method for Field %s not found: %s", property, e.getMessage()), e); } }