private void collectSingleImport( String importValue, Map<String, Object> resources, Object owner) { try { int token = importValue.lastIndexOf('.'); String className = importValue.substring(0, token); Class<?> clazz = GwtReflectionUtils.getClass(className); String fieldName = importValue.substring(token + 1); Object objectToImport = GwtReflectionUtils.getStaticFieldValue(clazz, fieldName); // register static field value in UiResourcesManager inner map resources.put(fieldName, objectToImport); } catch (Exception e) { throw new GwtTestUiBinderException( "Error while trying to import ui field '" + importValue + "'", e); } }
private void collectMultipleImports( String importValue, Map<String, Object> resources, Object owner) { try { String className = importValue.substring(0, importValue.lastIndexOf('.')); Class<?> clazz = GwtReflectionUtils.getClass(className); // this code handles classes and enums fine for (Field field : GwtReflectionUtils.getFields(clazz)) { if (Modifier.isStatic(field.getModifiers()) && !Modifier.isPrivate(field.getModifiers()) && !Modifier.isProtected(field.getModifiers())) { // register static field value in UiResourcesManager inner map Object value = GwtReflectionUtils.getStaticFieldValue(clazz, field.getName()); resources.put(field.getName(), value); } } } catch (Exception e) { throw new GwtTestUiBinderException( "Error while trying to import multiple ui fields '" + importValue + "'", e); } }