public T getUniqueByProperty(String property, Object value, boolean enforceType) throws NonUniqueResultException { Iterable<T> results = findAllByProperty(property, value, enforceType); T result = null; for (WindupVertexFrame item : results) { // There can be other types using the same property name. if (!type.isInstance(item)) continue; if (result != null) { throw new NonUniqueResultException("Expected unique value, but returned non-unique: " + property + " Conflicting models:" + NL + "\t" + StringUtils.join(item.getClass().getInterfaces(), ", ") + NL + "\t\t" + item.toPrettyString() + NL + "\t" + StringUtils.join(result.getClass().getInterfaces(), ", ") + NL + "\t\t" + result.toPrettyString()); } result = (T) item; } return result; }
public T getUniqueByProperty(String property, Object value, boolean enforceType) throws NonUniqueResultException { Iterable<T> results = findAllByProperty(property, value, enforceType); T result = null; for (WindupVertexFrame item : results) { // There can be other types using the same property name. if (!type.isInstance(item)) continue; if (result != null) { throw new NonUniqueResultException("Expected unique value, but returned non-unique: " + property + " Conflicting models:" + NL + "\t" + StringUtils.join(item.getClass().getInterfaces(), ", ") + NL + "\t\t" + item.toPrettyString() + NL + "\t" + StringUtils.join(result.getClass().getInterfaces(), ", ") + NL + "\t\t" + result.toPrettyString()); } result = (T) item; } return result; }
/** * Returns the ReportModel with given name. */ @SuppressWarnings("unchecked") public <T extends ReportModel> T getReportByName(String name, Class<T> clazz) { WindupVertexFrame model = this.getUniqueByProperty(ReportModel.REPORT_NAME, name); try { return (T) model; } catch (ClassCastException ex) { throw new WindupException("The vertex is not of expected frame type " + clazz.getName() + ": " + model.toPrettyString()); } }
/** * Returns the ReportModel with given name. */ @SuppressWarnings("unchecked") public <T extends ReportModel> T getReportByName(String name, Class<T> clazz) { WindupVertexFrame model = this.getUniqueByProperty(ReportModel.REPORT_NAME, name); try { return (T) model; } catch (ClassCastException ex) { throw new WindupException("The vertex is not of expected frame type " + clazz.getName() + ": " + model.toPrettyString()); } }
private XmlFileModel getXmlFileModelFromVertex(WindupVertexFrame vertexFrame) { final XmlFileModel xml; if (vertexFrame instanceof FileReferenceModel) { xml = (XmlFileModel) ((FileReferenceModel) vertexFrame).getFile(); } else if (vertexFrame instanceof XmlFileModel) { xml = (XmlFileModel) vertexFrame; } else { throw new WindupException("XmlFile was called on the wrong graph type ( " + vertexFrame.toPrettyString() + ")"); } return xml; }
+ System.lineSeparator()+" Old: %s" + System.lineSeparator()+" New: %s" + "%s", frame.toPrettyString(), last, frame, paramValueStoreOverwritten ? "" : System.lineSeparator()+"Further incidents will be logged at FINER level as it may occur millions of times.")); paramValueStoreOverwritten = true;
+ System.lineSeparator()+" Old: %s" + System.lineSeparator()+" New: %s" + "%s", frame.toPrettyString(), last, frame, paramValueStoreOverwritten ? "" : System.lineSeparator()+"Further incidents will be logged at FINER level as it may occur millions of times.")); paramValueStoreOverwritten = true;
LOG.warning(payload.toPrettyString()); return;
LOG.warning(payload.toPrettyString()); return;
throw new WindupException("XmlFile was called on the wrong graph type ( " + iterated.toPrettyString() + ")");
throw new WindupException("Failed when iterating " + frame.toPrettyString() + ", due to: " + e.getMessage(), e);
throw new WindupException("Failed when iterating " + frame.toPrettyString() + ", due to: " + e.getMessage(), e);