Java tutorial
//package com.java2s; import com.fasterxml.jackson.databind.introspect.AnnotatedMethod; public class Main { public static String okNameForMutator(AnnotatedMethod am, String prefix) { String name = am.getName(); if (name.startsWith(prefix)) { return manglePropertyName(name.substring(prefix.length())); } return null; } /** * Method called to figure out name of the property, given * corresponding suggested name based on a method or field name. * * @param basename Name of accessor/mutator method, not including prefix * ("get"/"is"/"set") */ protected static String manglePropertyName(String basename) { int len = basename.length(); // First things first: empty basename is no good if (len == 0) { return null; } // otherwise, lower case initial chars StringBuilder sb = null; for (int i = 0; i < len; ++i) { char upper = basename.charAt(i); char lower = Character.toLowerCase(upper); if (upper == lower) { break; } if (sb == null) { sb = new StringBuilder(basename); } sb.setCharAt(i, lower); } return (sb == null) ? basename : sb.toString(); } }