List of usage examples for org.apache.commons.lang3.exception ExceptionContext addContextValue
ExceptionContext addContextValue(String label, Object value);
From source file:org.force66.cxfutils.reflect.ReflectUtils.java
public static void reflectionAppendContextValues(ExceptionContext context, Object embeddedInfo, String label) { Validate.notNull(context, "Null context not allowed."); Validate.notEmpty(label, "Null or blank label not allowed."); if (embeddedInfo == null) { context.addContextValue(label, embeddedInfo); return;// ww w . j a va 2 s .c o m } List<Field> fieldList = FieldUtils.getAllFieldsList(embeddedInfo.getClass()); Object fieldValue; String fieldLabel; for (Field field : fieldList) { fieldLabel = label + "." + field.getName(); fieldValue = readField(field, embeddedInfo); if (fieldValue instanceof Collection) { reflectionAppendContextValues(context, (Collection) fieldValue, fieldLabel); } else if (field.getType().isPrimitive() || field.getType().getPackage().getName().startsWith("java")) { context.addContextValue(fieldLabel, fieldValue); } else { reflectionAppendContextValues(context, fieldValue, fieldLabel); } } }