List of usage examples for java.beans BeanInfo getPropertyDescriptors
PropertyDescriptor[] getPropertyDescriptors();
From source file:org.jaxygen.converters.properties.PropertiesToBeanConverter.java
private static void fillBeanArrayField(final String name, Object value, Object bean, BeanInfo beanInfo, String[] path, final String fieldName, int bracketStart, int len) throws IllegalAccessException, InvocationTargetException, IntrospectionException, InstantiationException, IllegalArgumentException, WrongProperyIndex { final String indexStr = fieldName.substring(bracketStart + 1, len - 1); final String propertyName = fieldName.substring(0, bracketStart); int index = Integer.parseInt(indexStr); String childName = ""; int firstDot = name.indexOf("."); if (firstDot > 0) { childName = name.substring(firstDot + 1); }/* w ww . j a va2 s . c o m*/ for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { if (pd.getName().equals(propertyName)) { Method writter = pd.getWriteMethod(); Method reader = pd.getReadMethod(); if (writter != null && reader != null) { Object array = reader.invoke(bean); if (pd.getPropertyType().isArray()) { if (array == null) { array = Array.newInstance(pd.getPropertyType().getComponentType(), index + 1); writter.invoke(bean, array); } if (Array.getLength(array) < (index + 1)) { array = resizeArray(array, index + 1); writter.invoke(bean, array); } if (path.length == 1) { Object valueObject = parsePropertyToValue(value, array.getClass().getComponentType()); Array.set(array, index, valueObject); } else { Object valueObject = fillBeanValueByName(childName, value, array.getClass().getComponentType(), Array.get(array, index)); Array.set(array, index, valueObject); } } else if (pd.getPropertyType().equals(List.class)) { if (array == null) { array = pd.getPropertyType().newInstance(); writter.invoke(bean, array); } Class<?> genericClass = array.getClass().getTypeParameters()[0].getClass(); if (path.length == 1) { Object valueObject = parsePropertyToValue(value, genericClass); Array.set(array, index, valueObject); } else { Object valueObject = fillBeanValueByName(childName, value, genericClass, null); Array.set(array, index, valueObject); } } } } } }
From source file:com.fengduo.bee.commons.core.lang.CollectionUtils.java
public static <M> void merge(M original, M destination, List<String> ignore) throws Exception { BeanInfo beanInfo = Introspector.getBeanInfo(original.getClass()); // Iterate over all the attributes for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) { // Only copy writable attributes if (descriptor.getWriteMethod() != null) { Object originalValue = descriptor.getReadMethod().invoke(original); String attributeName = descriptor.getName(); // ignore this values,do'not merge if (ignore != null && !ignore.isEmpty() && ignore.contains(attributeName)) { continue; }//from w w w .ja v a 2 s. c om Object defaultValue = descriptor.getReadMethod().invoke(destination); // Only copy values values where the destination values is null if (originalValue == null) { descriptor.getWriteMethod().invoke(original, defaultValue); } if (defaultValue instanceof Number && originalValue instanceof Number) { descriptor.getWriteMethod().invoke(original, MathUtils.add((Number) originalValue, (Number) defaultValue)); } } } }
From source file:org.jaxygen.converters.properties.PropertiesToBeanConverter.java
/** * Fill the field in bean by the value pointed by the name. Name format name=<(KEY([N])?)+> where KEY bean property name, N index in table (if bean field is * List of java array)./*from w ww .j a v a 2s . c om*/ * * @param name * @param value * @param beanClass * @param baseBean * @param conversionReport * @return * @throws IntrospectionException * @throws IllegalArgumentException * @throws IllegalAccessException * @throws InvocationTargetException * @throws InstantiationException * @throws WrongProperyIndex */ private static Object fillBeanValueByName(final String name, Object value, Class<?> beanClass, Object baseBean) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException, WrongProperyIndex { // parse name x.y[i].z[n].v Object bean = baseBean; if (bean == null) { bean = beanClass.newInstance(); } Class<?> c = beanClass; BeanInfo beanInfo = Introspector.getBeanInfo(c, Object.class); final String childName = name.substring(name.indexOf(".") + 1); String path[] = name.split("\\."); final String fieldName = path[0]; // parse arrays [n] if (fieldName.endsWith("]")) { int bracketStart = fieldName.indexOf("["); int len = fieldName.length(); if (bracketStart > 0) { fillBeanArrayField(name, value, bean, beanInfo, path, fieldName, bracketStart, len); } else { throw new WrongProperyIndex(name); } } else { // parse non arrays for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { if (pd.getName().equals(fieldName)) { Method writter = pd.getWriteMethod(); Method reader = pd.getReadMethod(); if (writter != null && reader != null) { Class<?> valueType = reader.getReturnType(); if (path.length == 1) { Object valueObject = parsePropertyToValue(value, valueType); writter.invoke(bean, valueObject); } else { Object childBean = reader.invoke(bean); Object valueObject = fillBeanValueByName(childName, value, valueType, childBean); writter.invoke(bean, valueObject); } } } } } // Object bean = c.newInstance(); return bean; }
From source file:com.swingtech.commons.util.ClassUtil.java
public static List getPropertyDescriptorsFromClass(final Class pClass, final String filterRegEx) { BeanInfo vBeanInfo = null; PropertyDescriptor[] vPropDescList = null; PropertyDescriptor vPropDesc = null; String vPropName = null;//from w w w . j a v a 2 s . com final Vector vPropertyNameList = new Vector(); try { vBeanInfo = Introspector.getBeanInfo(pClass); } catch (final IntrospectionException e) { logger.warn("Utility.getPropertyNamesFromClass. Error trying to use Introspector", e); return null; } vPropDescList = vBeanInfo.getPropertyDescriptors(); for (int i = 0; i < vPropDescList.length; i++) { vPropDesc = vPropDescList[i]; vPropName = vPropDesc.getName(); if (Utility.isNullOrEmpty(filterRegEx) || vPropName.matches(filterRegEx)) { vPropertyNameList.add(vPropDesc); } } if (vPropertyNameList.isEmpty()) { return null; } return vPropertyNameList; }
From source file:com.swingtech.commons.util.ClassUtil.java
/** * @param pClass/* w ww .ja v a2 s .c o m*/ * @param filterRegEx * @return */ public static List getPropertyNamesFromClass(final Class pClass, final String filterRegEx) { BeanInfo vBeanInfo = null; PropertyDescriptor vPropDescList[] = null; PropertyDescriptor vPropDesc = null; String vPropName = null; final Vector vPropertyNameList = new Vector(); try { vBeanInfo = Introspector.getBeanInfo(pClass); } catch (final IntrospectionException e) { logger.warn("Utility.getPropertyNamesFromClass. Error trying to use Introspector", e); return null; } vPropDescList = vBeanInfo.getPropertyDescriptors(); for (int i = 0; i < vPropDescList.length; i++) { vPropDesc = vPropDescList[i]; vPropName = vPropDesc.getName(); if (Utility.isNullOrEmpty(filterRegEx) || vPropName.matches(filterRegEx)) { vPropertyNameList.add(vPropName); } } if (vPropertyNameList.isEmpty()) { return null; } return vPropertyNameList; }
From source file:net.audumla.concurrent.TemplatedExecuter.java
protected void mergeProperties(Object source, Object destination) throws IntrospectionException { BeanInfo info = Introspector.getBeanInfo(source.getClass()); for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) { try {/*from w w w. j a va2 s . c o m*/ // get the property value from the destination object. Object destvalue = BeanUtils.getProperty(destination, descriptor.getName()); // only copy the value if the destination has not been set. This will therefore only work on non primitive types if (destvalue == null) { Object sourceValue = descriptor.getReadMethod().invoke(source); // Only copy values values where the destination values is null if (sourceValue != null) { BeanUtils.copyProperty(destination, descriptor.getName(), sourceValue); } } } catch (Exception ignored) { } } }
From source file:com.impetus.kundera.metadata.processor.AbstractEntityFieldProcessor.java
/** * Populates @Id accesser methods like, getId and setId of clazz to * metadata./*from w w w . ja va 2 s . c om*/ * * @param metadata * the metadata * @param clazz * the clazz * @param f * the f */ protected final void populateIdAccessorMethods(EntityMetadata metadata, Class<?> clazz, Field f) { try { BeanInfo info = Introspector.getBeanInfo(clazz); for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) { if (descriptor.getName().equals(f.getName())) { metadata.setReadIdentifierMethod(descriptor.getReadMethod()); metadata.setWriteIdentifierMethod(descriptor.getWriteMethod()); return; } } } catch (IntrospectionException e) { throw new RuntimeException(e); } }
From source file:stroom.util.AbstractCommandLineTool.java
public void init(final String[] args) throws Exception { map = new HeaderMap(); validArguments = new ArrayList<String>(); map.loadArgs(args);/*from ww w .j a v a 2s .c om*/ final BeanInfo beanInfo = Introspector.getBeanInfo(this.getClass()); for (final PropertyDescriptor field : beanInfo.getPropertyDescriptors()) { if (field.getWriteMethod() != null) { if (field.getName().length() > maxPropLength) { maxPropLength = field.getName().length(); } if (map.containsKey(field.getName())) { validArguments.add(field.getName()); field.getWriteMethod().invoke(this, getAsType(field)); } } } checkArgs(); }
From source file:com.industrieit.ohr.OHRJavassister.java
public static Class ohr(Class cll) { try {//from w w w. j ava2 s.com //System.out.println("++++++++++ "+cll.getName()); /*if (cll.getName().startsWith("ohr.")) { throw new RuntimeException(cll.getName()); }*/ if (processed2.containsKey(cll)) { return processed2.get(cll); } HashSet<Long> handleOffsets = new HashSet<Long>(); String cnam = cll.getName(); if (!cnam.startsWith("ohr.")) { cnam = "ohr." + cll.getName(); //cnam=cnam.substring(4); } Class cl = Class.forName(cnam.substring(4)); int clnumber = incrementClsCounter(); List<Integer> owned = new ArrayList<Integer>(); //remove the old implementation if its around from another process String fname = "target/classes/" + cnam.replace(".", "/") + ".class"; System.out.println("deleted" + fname + " " + (new File(fname).delete())); if (!Modifier.isAbstract(cl.getModifiers())) { throw new RuntimeException("not an abstract class " + cl.getName()); } System.out.println("processing ohr " + cnam); CtClass bc = getDefault().getCtClass(cl.getName()); CtClass cc = getDefault().makeClass(cnam, bc); StringBuilder initBuilder = new StringBuilder(); initBuilder.append("public void internalInit() {\n"); StringBuilder constructBuilder = new StringBuilder(); constructBuilder.append("{"); String intname = OHRBase.class.getName(); System.out.println("intername is " + intname); CtClass ci = getDefault().getCtClass(intname); CtClass extern = getDefault().getCtClass(Externalizable.class.getName()); //cc.addInterface(ci); cc.setInterfaces(new CtClass[] { ci, extern }); cc.setSuperclass(bc); //add base implmenetation methods and properties setBaseMixinsPre(cc, false); //first long for id and other stuff long offset = 8; BeanInfo bi = Introspector.getBeanInfo(cl); PropertyDescriptor[] pds = bi.getPropertyDescriptors(); for (int co = 0; co < propertyOrdering.length; co++) { Class cprop = propertyOrdering[co]; for (int i = 0; i < pds.length; i++) { // Get property name String propName = pds[i].getName(); if (propName.equals("class")) { continue; } String typ = pds[i].getPropertyType().getName(); Class type = pds[i].getPropertyType(); //if (propName.startsWith("fath")) //PL.pl("[[[[["+type+" "+propName+" "+cprop); if (cprop == Object.class) { //handle refs only if (type.isPrimitive()) { continue; } if (type == String.class) { continue; } if (type == CharSequence.class) { continue; } if (type == OHRLongArray.class) { continue; } if (type == OHRIntArray.class) { continue; } if (type == OHRShortArray.class) { continue; } if (type == OHRByteArray.class) { continue; } if (type == OHRBooleanArray.class) { continue; } if (type == OHRDoubleArray.class) { continue; } if (type == OHRFloatArray.class) { continue; } } else if (cprop != type) { //PL.pl("skipping "+type+" "+cprop); continue; } //PL.pl("[[[[[ " + type + " - " + propName + " - " + cprop); //System.out.println("--prop--" + propName); String rname = pds[i].getReadMethod().getName(); String wname = null; if (pds[i].getWriteMethod() != null) { wname = pds[i].getWriteMethod().getName(); } boolean reifread = isMethodReifAnnotated(pds[i].getReadMethod()); boolean reifwrite = isMethodReifAnnotated(pds[i].getWriteMethod()); String wcons = getConsistencyAsString(pds[i].getWriteMethod()); String rcons = getConsistencyAsString(pds[i].getReadMethod()); System.out.println("TYPE " + pds[i].getPropertyType().getName() + " " + pds[i].getPropertyType().getInterfaces()); if (pds[i].getPropertyType() == String.class && isInlineString(pds[i])) { //NOTE - only for inline strings - normal strings are handled as extrefs like any other object System.out.println("ITS An inline string!!!!"); int length = pds[i].getWriteMethod().getAnnotation(InlineStringReify.class).length(); boolean trim = pds[i].getWriteMethod().getAnnotation(InlineStringReify.class) .trimOverflow(); boolean ascii = pds[i].getWriteMethod().getAnnotation(InlineStringReify.class).asciiOnly(); String wmeth = "public void " + wname + "(" + typ + " o) { ohwritestr" + wcons + "(" + offset + "l,o," + length + "," + trim + "," + ascii + "); }"; //add setter CtMethod wmethod = CtNewMethod.make(wmeth, cc); cc.addMethod(wmethod); System.out.println(wmeth); String rmeth = "public " + typ + " " + rname + "() { return (" + typ + ") ohreadstr" + rcons + "(" + offset + "l," + ascii + "); }"; //add setter CtMethod rmethod = CtNewMethod.make(rmeth, cc); //rmethod.getMethodInfo().addAttribute(attr); cc.addMethod(rmethod); System.out.println(rmeth); int bytesperchar = ascii ? 1 : 2; //pad to 16 bits int ll = 4 + length * bytesperchar; if (ll % 2 != 0) { ll++; } offset += ll; //lebgth marker as well as unicode 16 encoded characters } else if (pds[i].getPropertyType() == CharSequence.class && isInlineString(pds[i])) { //NOTE - only for inline strings - normal strings are handled as extrefs like any other object System.out.println("ITS An inline charsequence!!!!"); int length = pds[i].getWriteMethod().getAnnotation(InlineStringReify.class).length(); boolean trim = pds[i].getWriteMethod().getAnnotation(InlineStringReify.class) .trimOverflow(); boolean ascii = pds[i].getWriteMethod().getAnnotation(InlineStringReify.class).asciiOnly(); String wmeth = "public void " + wname + "(" + typ + " o) { ohwritestr" + wcons + "(" + offset + "l,o," + length + "," + trim + "," + ascii + "); }"; //add setter CtMethod wmethod = CtNewMethod.make(wmeth, cc); cc.addMethod(wmethod); System.out.println(wmeth); String rmeth = "public " + typ + " " + rname + "() { return (" + typ + ") ohreadcs" + rcons + "(" + offset + "l," + ascii + "); }"; //add setter CtMethod rmethod = CtNewMethod.make(rmeth, cc); //rmethod.getMethodInfo().addAttribute(attr); cc.addMethod(rmethod); System.out.println(rmeth); int bytesperchar = ascii ? 1 : 2; //pad to 8 byte boundary! int ll = (int) Math.ceil((4.0 + length * bytesperchar) / 8) * 8; offset += ll; //lebgth marker as well as unicode 16 encoded characters } else if ((pds[i].getPropertyType() == OHRLongArray.class || pds[i].getPropertyType() == OHRIntArray.class || pds[i].getPropertyType() == OHRShortArray.class || pds[i].getPropertyType() == OHRByteArray.class || pds[i].getPropertyType() == OHRFloatArray.class || pds[i].getPropertyType() == OHRDoubleArray.class || pds[i].getPropertyType() == OHRBooleanArray.class) && pds[i].getReadMethod().isAnnotationPresent(InlineArrayReify.class)) { int bitsperitem = 0; String cldef = null; Class at = pds[i].getPropertyType(); boolean unchecked = pds[i].getReadMethod().isAnnotationPresent(UncheckedBoundsXXX.class); if (at == OHRLongArray.class) { bitsperitem = 8 * 8; cldef = LongInlineOHRArray.class.getName(); } else if (at == OHRIntArray.class) { bitsperitem = 4 * 8; //cldef=IntInlineOHRArrayCop.class.getName(); if (unchecked) { cldef = IntInlineOHRArrayUnchecked.class.getName(); } else { cldef = IntInlineOHRArray.class.getName(); } } if (at == OHRDoubleArray.class) { bitsperitem = 8 * 8; cldef = DoubleInlineOHRArray.class.getName(); } if (at == OHRFloatArray.class) { bitsperitem = 4 * 8; cldef = FloatInlineOHRArray.class.getName(); } if (at == OHRShortArray.class) { bitsperitem = 2 * 8; cldef = ShortInlineOHRArray.class.getName(); } if (at == OHRByteArray.class) { bitsperitem = 1 * 8; cldef = ByteInlineOHRArray.class.getName(); } if (at == OHRBooleanArray.class) { bitsperitem = 1; cldef = BooleanInlineOHRArray.class.getName(); } //NOTE - only for inline strings - normal strings are handled as extrefs like any other object System.out.println("ITS An inline array!!!!"); int length = pds[i].getReadMethod().getAnnotation(InlineArrayReify.class).length(); long bytealloc = OHRInlineArrayHandler.getGenericArrayAllocationSize(bitsperitem, length); //PL.pl("byte allocation for logn array length "+length+" "+bytealloc); CtClass ctc = getDefault().getCtClass(cldef); String varname = "var" + i; CtField cf = new CtField(ctc, varname, cc); cf.setModifiers(Modifier.PRIVATE); cc.addField(cf); //add data to constructor initBuilder.append( "com.industrieit.ohr.OHRInlineArrayHandler.initialiseInlineGenericArray(this.basePtr+" + offset + "l," + length + "l," + bitsperitem + ");\n"); constructBuilder.append(varname + "=new " + cldef + "(this," + offset + "l);\n"); //+ "//this.basePtr"+offset+"l);"); //String wmeth = "public void " + wname + "(" + typ + " o) { throw new java.lang.RuntimeException(\"not supported\"); }"; //add setter //CtMethod wmethod = CtNewMethod.make(wmeth, cc); //cc.addMethod(wmethod); //System.out.println(wmeth); String rmeth = "public " + typ + " " + rname + "() { return " + varname + "; }"; //add setter CtMethod rmethod = CtNewMethod.make(rmeth, cc); //rmethod.getMethodInfo().addAttribute(attr); cc.addMethod(rmethod); System.out.println("||||||||" + rmeth + "|||||||||"); offset += bytealloc; } else if (pds[i].getPropertyType().isPrimitive()) { //PL.pl("ITS A PRIMITIVE!"); int vv = 0; if (cprop == long.class) { vv = 8; } if (cprop == double.class) { vv = 8; } if (cprop == int.class) { vv = 4; } if (cprop == float.class) { vv = 4; } if (cprop == short.class) { vv = 2; } if (cprop == byte.class) { vv = 1; } System.out.println( "for " + pds[i].getName() + " typ is " + pds[i].getPropertyType().getName()); String wmeth = "public void " + wname + "(" + typ + " o) { ohwrite" + wcons + "(" + offset + "l,o); }"; //add setter //ConstPool constpool = cc.getClassFile().getConstPool(); if (reifwrite) { CtMethod wmethod = CtNewMethod.make(wmeth, cc); cc.addMethod(wmethod); System.out.println("&&&&&&&" + wmeth); } String rmeth = "public " + typ + " " + rname + "() { return (" + typ + ") ohread" + typ + rcons + "(" + offset + "l); }"; //add setter //rmethod.getMethodInfo().addAttribute(attr); if (reifread) { CtMethod rmethod = CtNewMethod.make(rmeth, cc); cc.addMethod(rmethod); System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&" + rmeth + vv); } offset += vv; } else { System.out.println("ITS AN ASSUMED REIFY!!!"); if (pds[i].getWriteMethod().isAnnotationPresent(Owned.class)) { owned.add(i); } //CtClass tc = getDefault().getCtClass(pds[i].getPropertyType().getName()); CtClass tc = getDefault().getCtClass(OHRBase.class.getName()); //String fnam="ohrt"+i; //CtField f = new CtField(tc, fnam, cc); //f.setModifiers(Modifier.PROTECTED); //cc.addField(f); //store by reify //handleOffsets.add(offset); String wmeth = "public void " + wname + "(" + typ + " o) { ohwritere" + wcons + "(" + offset + "l,o); }"; //add setter CtMethod wmethod = CtNewMethod.make(wmeth, cc); if (reifwrite) { cc.addMethod(wmethod); } System.out.println(wmeth); //String rmeth = "public " + typ + " " + rname + "() { return (" + typ + ") ohreadre(" + offset + "l," + typ + ".class); }"; String rmeth = "public " + typ + " " + rname + "() { return (" + typ + ") ohreadre" + rcons + "(" + offset + "l); };"; //add setter CtMethod rmethod = CtNewMethod.make(rmeth, cc); //rmethod.getMethodInfo().addAttribute(attr); if (reifread) { cc.addMethod(rmethod); } System.out.println(rmeth); handleOffsets.add(offset); offset += 8; } /* if (!isReif(type)) { PL.pl(""+pds[i].getName()+" is a non reified handle!!!!"); //store by handle handleOffsets.add(offset); String wmeth = "public void " + wname + "(" + typ + " o) { ohwritehand(" + offset + "l,o); }"; //add setter CtMethod wmethod = CtNewMethod.make(wmeth, cc); if (reifwrite) { cc.addMethod(wmethod); } System.out.println(wmeth); String rmeth = "public " + typ + " " + rname + "() { return (" + typ + ") ohreadhand(" + offset + "l); }"; //add setter CtMethod rmethod = CtNewMethod.make(rmeth, cc); //rmethod.getMethodInfo().addAttribute(attr); if (reifread) { cc.addMethod(rmethod); } System.out.println(rmeth); }*/ } //PL.pl("offset is "+offset); } //offset+=8; //ok create the get handleoffsets method //print out total byts allocated //PL.pl("%%%%%%%%%% TOTAL BYTES = " + offset); StringBuilder sb = new StringBuilder(); sb.append("public long[] handleOffsets() { "); sb.append("long a[] = new long[").append(handleOffsets.size()).append("];"); int c = 0; for (long l : handleOffsets) { sb.append("a[").append(c).append("]=").append(l).append("l;"); c++; } sb.append("return a; }"); System.out.println(sb.toString()); CtMethod om = CtNewMethod.make(sb.toString(), cc); cc.addMethod(om); String sizem = "public long gsize() { return " + (offset) + "l; }"; //PL.pl(sizem); CtMethod sm = CtNewMethod.make(sizem, cc); cc.addMethod(sm); //add clsid CtMethod cmid = CtNewMethod.make("public int ohclassId() { return " + clnumber + "; }", cc); cc.addMethod(cmid); setBaseMixinsPost(cc, false, owned, pds, constructBuilder, initBuilder); cc.writeFile("target/classes"); /*for (Method me : cc.toClass().getDeclaredMethods()) { //test print, ok //System.out.println(me.getName()); }*/ Class ppp = Class.forName(cnam); Field f = ppp.getDeclaredField("u"); f.setAccessible(true); f.set(ppp.newInstance(), USafe.getUnsafe()); //synchronized (mutex) //{ processed2.put(cl, ppp); processed2.put(ppp, ppp); cls[clnumber] = ppp; return ppp; //} } catch (Exception e) { throw new RuntimeException(e); } }
From source file:stroom.util.AbstractCommandLineTool.java
private void doTraceArguments(final PrintStream printStream) throws Exception { final BeanInfo beanInfo = Introspector.getBeanInfo(this.getClass()); for (final PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { // Only do properties with getters if (pd.getWriteMethod() != null) { // Simple getter ? String suffix = " (default)"; if (map.containsKey(pd.getName())) { suffix = " (arg)"; }//ww w .j av a 2 s. c o m String value = ""; if (pd.getReadMethod() != null && pd.getReadMethod().getParameterTypes().length == 0) { value = String.valueOf(pd.getReadMethod().invoke(this)); } else { // No simple getter Field field = null; try { field = this.getClass().getDeclaredField(pd.getName()); } catch (final NoSuchFieldException nsfex) { // Ignore } if (field != null) { field.setAccessible(true); value = String.valueOf(field.get(this)); } else { value = "?"; } } printStream.println(StringUtils.rightPad(pd.getName(), maxPropLength) + " = " + value + suffix); } } }