// the meta-data returned by this method is merged and potentially customized by a // ConfigPreProcessor private Annotation getFinalMetaDataFromNode( ViewConfigNode viewConfigNode, Annotation annotation) { Class<? extends Annotation> targetType = annotation.annotationType(); // skip @View and @Folder, because they get created dynamically to support their optional usage // the dynamic generation depends on the level and if it is a synthetic information if (View.class.equals(targetType) || Folder.class.equals(targetType)) { return annotation; } // skip aggregated meta-data, because it can't be replaced // (there is no info available about the instance which replaced the original one // which might be equivalent to the annotation passed to this method) ViewMetaData viewMetaData = annotation.annotationType().getAnnotation(ViewMetaData.class); if (viewMetaData == null) { return annotation; } Aggregated aggregated = viewMetaData.annotationType().getAnnotation(Aggregated.class); if (aggregated == null || aggregated.value()) { return annotation; } for (Annotation nodeMetaData : viewConfigNode.getMetaData()) { if (targetType.equals(nodeMetaData.annotationType())) { return nodeMetaData; } } return annotation; }
@Test public void testSimpleMetaDataTreeWithMetaData() { this.viewConfigExtension.addPageDefinition(SimplePageConfig002.class); ViewConfigNode node = this.viewConfigExtension.findNode(SimplePageConfig002.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); Assert.assertNull(node.getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(0, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(1, node.getMetaData().size()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); }