@SuppressWarnings("rawtypes") @Override protected void finetuneMethodAppearance(Class cls, Method method, MethodAppearanceDecision decision) { try { String methodName = method.getName(); if (!(methodName.equals("add") || methodName.equals("list"))) { decision.setExposeMethodAs(null); } } catch (Exception e) { log.error(e, e); } } }
@Override public void process(MethodAppearanceDecisionInput methodAppearanceDecisionInput, MethodAppearanceDecision methodAppearanceDecision) { Method method = methodAppearanceDecisionInput.getMethod(); // How to define a setter? This is a weak approximation: a method whose name // starts with "set" or returns void. if ( method.getName().startsWith("set") ) { methodAppearanceDecision.setExposeMethodAs(null); } else if ( method.getReturnType().getName().equals("void") ) { methodAppearanceDecision.setExposeMethodAs(null); } else { Class<?> declaringClass = method.getDeclaringClass(); if (declaringClass.equals(java.lang.Object.class)) { methodAppearanceDecision.setExposeMethodAs(null); } else { Package pkg = declaringClass.getPackage(); if (pkg.getName().equals("java.util")) { methodAppearanceDecision.setExposeMethodAs(null); } } } } });