private Object newInstance(TypeDescription memberDescription, String propertyName, Node node) { Object newInstance = memberDescription.newInstance(propertyName, node); if (newInstance != null) { constructedObjects.put(node, newInstance); return constructObjectNoCheck(node); } return constructObject(node); }
protected Object newInstance(Class<?> ancestor, Node node, boolean tryDefault) throws InstantiationException { final Class<? extends Object> type = node.getType(); if (typeDefinitions.containsKey(type)) { TypeDescription td = typeDefinitions.get(type); final Object instance = td.newInstance(node); if (instance != null) { return instance; } } if (tryDefault) { /* * Removed <code> have InstantiationException in case of abstract * type */ if (ancestor.isAssignableFrom(type) && !Modifier.isAbstract(type.getModifiers())) { try { java.lang.reflect.Constructor<?> c = type.getDeclaredConstructor(); c.setAccessible(true); return c.newInstance(); } catch (NoSuchMethodException e) { throw new InstantiationException("NoSuchMethodException:" + e.getLocalizedMessage()); } catch (Exception e) { throw new YAMLException(e); } } } throw new InstantiationException(); }
private Object newInstance(TypeDescription memberDescription, String propertyName, Node node) { Object newInstance = memberDescription.newInstance(propertyName, node); if (newInstance != null) { constructedObjects.put(node, newInstance); return constructObjectNoCheck(node); } return constructObject(node); }
protected Object newInstance(Class<?> ancestor, Node node, boolean tryDefault) throws InstantiationException { final Class<? extends Object> type = node.getType(); if (typeDefinitions.containsKey(type)) { TypeDescription td = typeDefinitions.get(type); final Object instance = td.newInstance(node); if (instance != null) { return instance; } } if (tryDefault) { /* * Removed <code> have InstantiationException in case of abstract * type */ if (ancestor.isAssignableFrom(type) && !Modifier.isAbstract(type.getModifiers())) { try { java.lang.reflect.Constructor<?> c = type.getDeclaredConstructor(); c.setAccessible(true); return c.newInstance(); } catch (NoSuchMethodException e) { throw new InstantiationException("NoSuchMethodException:" + e.getLocalizedMessage()); } catch (Exception e) { throw new YAMLException(e); } } } throw new InstantiationException(); }