}
if( persistName == null || persistName.isEmpty() )
{
persistName = fieldName;
}
final InfoNode node = InfoNode.createCompoundNode( fieldName, persistName, clazz );
// set the entry, key, and value persistence names to the default value of the annotation. if the
// map field is annotated, then we over write the default values with the annotated values.
// does the class have a @PersistMap( keyPersistName = "xxxx", valuePersistName = "yyyy", entryPeristName = "zzzz" )
String entryPersistName = PersistMap.ENTRY_PERSIST_NAME;
String keyPersistName = PersistMap.KEY_PERSIST_NAME;
String valuePersistName = PersistMap.VALUE_PERSIST_NAME;
try
{
final Field field = ReflectionUtils.getDeclaredField( containingClass, fieldName );
final PersistMap mapAnnotation = field.getAnnotation( PersistMap.class );
if( mapAnnotation != null )
{
if( !mapAnnotation.entryPersistName().isEmpty() )
{
entryPersistName = mapAnnotation.entryPersistName();
}
if( !mapAnnotation.keyPersistName().isEmpty() )
{
keyPersistName = mapAnnotation.keyPersistName();
}
if( !mapAnnotation.valuePersistName().isEmpty() )
{
valuePersistName = mapAnnotation.valuePersistName();
}
}
}
catch( ReflectiveOperationException e )
{
final StringBuffer message = new StringBuffer();
message.append( "Field not found in containing class:" + Constants.NEW_LINE );
message.append( " Containing class: " + containingClass.getName() + Constants.NEW_LINE );
message.append( " Field name: " + fieldName + Constants.NEW_LINE );
LOGGER.debug( message.toString() );
}
// run through the Map entries, recursively calling createNode(...) to create
// the appropriate node which to add to the newly created compound node.
for( Map.Entry< ?, ? > entry : ((Map< ?, ? >)object).entrySet() )
{
// create the map entry node
final InfoNode entryNode = InfoNode.createCompoundNode( "", entryPersistName, entry.getClass() );
// create the key node and add it to the entry node
entryNode.addChild( createNode( clazz, entry.getKey(), keyPersistName ) );
// create the value node and add it to the entry node
entryNode.addChild( createNode( clazz, entry.getValue(), valuePersistName ) );
// add the entry node to the info node representing the map
node.addChild( entryNode );
}