SkinFactory { public GNodeSkin createNodeSkin(final GNode node) { if (node == null) { return null; } else if (node.getType() == null) { return new DefaultNodeSkin(node); } final Class<? extends GNodeSkin> skinClass = nodeSkins.get(node.getType()); if (skinClass == null) { return new DefaultNodeSkin(node); } else { try { final Constructor<? extends GNodeSkin> constructor = skinClass.getConstructor(GNode.class); return constructor.newInstance(node); } catch (final ReflectiveOperationException e) { LOGGER.error(LogMessages.CANNOT_INSTANTIATE_SKIN, skinClass.getName()); return new DefaultNodeSkin(node); } } }  void setNodeSkin(final String type, final Class<? extends GNodeSkin> skin); void setConnectorSkin(final String type, final Class<? extends GConnectorSkin> skin); void setConnectionSkin(final String type, final Class<? extends GConnectionSkin> skin); void setJointSkin(final String type, final Class<? extends GJointSkin> skin); void setTailSkin(final String type, final Class<? extends GTailSkin> skin); GNodeSkin createNodeSkin(final GNode node); GConnectorSkin createConnectorSkin(final GConnector connector); GConnectionSkin createConnectionSkin(final GConnection connection); GJointSkin createJointSkin(final GJoint joint); GTailSkin createTailSkin(final GConnector connector);  }
@Test public void testCreateNodeSkin() { NODE.setType(null); assertNull(skinFactory.createNodeSkin(null)); assertTrue(skinFactory.createNodeSkin(NODE) instanceof DefaultNodeSkin); NODE.setType(NODE_TYPE); assertTrue(skinFactory.createNodeSkin(NODE) instanceof DefaultNodeSkin); skinFactory.setNodeSkin(NODE_TYPE, CustomNodeSkin.class); assertTrue(skinFactory.createNodeSkin(NODE) instanceof CustomNodeSkin); }