public static Map createMapUsingProperty(Object[] array, String fieldName) throws ApplicationException { if (array == null) { return null; } try { Map result = new HashMap(); for (int i = 0; i < array.length; i++) { Object current = array[i]; if (current != null) { Object key = BeanUtils.invokeGetter(current, fieldName); result.put(key, current); } } return result; } catch (Throwable th) { LOG.log(Level.SEVERE, th.getMessage(), th); throw new ApplicationException( "An error occurred while creating a map using property " + fieldName + ":" + th.getMessage()); } }