public void testChildrenReflection() throws Throwable { final MyElement element = createElement("<a><child/><child-element/><child-element/></a>"); final DomGenericInfo info = element.getGenericInfo(); final DomFixedChildDescription foo = info.getFixedChildDescription("foo"); assertFixedChildDescription(foo, element.getFoo(), "foo"); final DomFixedChildDescription child = info.getFixedChildDescription("child"); assertFixedChildDescription(child, element.getChild(), "child"); final DomFixedChildDescription genericChild = info.getFixedChildDescription("generic-value"); assertGenericChildDescription(genericChild, element.getGenericValue(), "generic-value"); final DomCollectionChildDescription collectionChild = info.getCollectionChildDescription("child-element"); assertEquals(element.getChildElements(), collectionChild.getValues(element)); assertEquals("child-element", collectionChild.getXmlElementName()); assertEquals(MyElement.class, collectionChild.getType()); assertEquals(MyElement.class.getMethod("getChildElements"), collectionChild.getGetterMethod().getMethod()); assertEquals(new HashSet(Arrays.asList(foo, child, collectionChild, genericChild, info.getAttributeChildrenDescriptions().get(0))), new HashSet(info.getChildrenDescriptions()) ); }
public void testChildrenReflection() throws Throwable { final MyElement element = createElement("<a><child/><child-element/><child-element/></a>"); final DomGenericInfo info = element.getGenericInfo(); final DomFixedChildDescription foo = info.getFixedChildDescription("foo"); assertFixedChildDescription(foo, element.getFoo(), "foo"); final DomFixedChildDescription child = info.getFixedChildDescription("child"); assertFixedChildDescription(child, element.getChild(), "child"); final DomFixedChildDescription genericChild = info.getFixedChildDescription("generic-value"); assertGenericChildDescription(genericChild, element.getGenericValue(), "generic-value"); final DomCollectionChildDescription collectionChild = info.getCollectionChildDescription("child-element"); assertEquals(element.getChildElements(), collectionChild.getValues(element)); assertEquals("child-element", collectionChild.getXmlElementName()); assertEquals(MyElement.class, collectionChild.getType()); assertEquals(MyElement.class.getMethod("getChildElements"), collectionChild.getGetterMethod().getMethod()); assertEquals(new HashSet(Arrays.asList(foo, child, collectionChild, genericChild, info.getAttributeChildrenDescriptions().get(0))), new HashSet(info.getChildrenDescriptions())); }
@Override public final DomElement createPathStableCopy() { final DomFixedChildDescription description = getChildDescription(); final DomElement parentCopy = getParent().createStableCopy(); return getManager().createStableValue(new Factory<DomElement>() { @Override public DomElement create() { return parentCopy.isValid() ? description.getValues(parentCopy).get(myIndex) : null; } }); }
public ChildGenericValueColumnInfo(final String name, @NotNull final DomFixedChildDescription description, final TableCellRenderer renderer, final TableCellEditor editor) { super(name, renderer); myEditor = editor; myChildDescription = description; }
private void assertFixedChildDescription(final DomFixedChildDescription description, final DomElement child, final String tagName) { assertEquals(1, description.getCount()); assertEquals(Arrays.asList(child), description.getValues(child.getParent())); assertEquals(tagName, description.getXmlElementName()); assertEquals(MyElement.class, description.getType()); assertEquals(JavaMethod.getMethod(MyElement.class, new JavaMethodSignature("get" + StringUtil.capitalize(tagName))), description.getGetterMethod(0)); }
private static void assertGenericChildDescription(final DomFixedChildDescription description, final DomElement child, final String tagName) { assertEquals(1, description.getCount()); assertEquals(Arrays.asList(child), description.getValues(child.getParent())); assertEquals(tagName, description.getXmlElementName()); assertEquals(GenericDomValue.class, ((ParameterizedType)description.getType()).getRawType()); assertEquals(JavaMethod.getMethod(MyElement.class, new JavaMethodSignature("getGenericValue")), description.getGetterMethod(0)); }
public final DomElement createPathStableCopy() { final DomFixedChildDescription description = getChildDescription(); final DomElement parentCopy = getParent().createStableCopy(); return getManager().createStableValue(new Factory<DomElement>() { public DomElement create() { return parentCopy.isValid() ? description.getValues(parentCopy).get(myIndex) : null; } }); }
private void assertFixedChildDescription(final DomFixedChildDescription description, final DomElement child, final String tagName) throws NoSuchMethodException { assertEquals(1, description.getCount()); assertEquals(Arrays.asList(child), description.getValues(child.getParent())); assertEquals(tagName, description.getXmlElementName()); assertEquals(MyElement.class, description.getType()); assertEquals(JavaMethod.getMethod(MyElement.class, new JavaMethodSignature("get" + StringUtil.capitalize(tagName))), description.getGetterMethod(0)); }
private static void assertGenericChildDescription(final DomFixedChildDescription description, final DomElement child, final String tagName) throws NoSuchMethodException { assertEquals(1, description.getCount()); assertEquals(Arrays.asList(child), description.getValues(child.getParent())); assertEquals(tagName, description.getXmlElementName()); assertEquals(GenericDomValue.class, ((ParameterizedType)description.getType()).getRawType()); assertEquals(JavaMethod.getMethod(MyElement.class, new JavaMethodSignature("getGenericValue")), description.getGetterMethod(0)); }
public ChildGenericValueColumnInfo(final String name, final DomFixedChildDescription description, final TableCellEditor editor) { this(name, description, new DefaultTableCellRenderer(), editor); }
protected final DomFixedChildDescription getChildDescription() { return myChildDescription; }