/** * Stores the exception which holds information if, and where, the Windup stopped (typically on an external request). * If windup was stopped, this must be called. */ public void setWindupStopException(WindupStopException windupStopException) { if (this.windupStopException != null) throw new WindupException("Trying to set the stop exception while it was already set." + " The cause contains the original one.", this.windupStopException); this.windupStopException = windupStopException; }
private void validateWrappedCondition(Object wrappedCondition) { if(! (wrappedCondition instanceof GraphCondition)) { throw new WindupException("The <" + ELEMENT_NAME + "> element must wrap GraphConditions only." ); } }
/** * Stores the exception which holds information if, and where, the Windup stopped (typically on an external request). * If windup was stopped, this must be called. */ public void setWindupStopException(WindupStopException windupStopException) { if (this.windupStopException != null) throw new WindupException("Trying to set the stop exception while it was already set." + " The cause contains the original one.", this.windupStopException); this.windupStopException = windupStopException; }
private void validateWrappedCondition(Object wrappedCondition) { if(! (wrappedCondition instanceof GraphCondition)) { throw new WindupException("The <" + ELEMENT_NAME + "> element must wrap GraphConditions only." ); } }
private void validateAttributes(String size) throws WindupException{ if(!Pattern.matches("[0-9]+",size)) { throw new WindupException("The <" + ELEMENT_NAME + "> element's '" +IterableFilterHandler.SIZE_ATTRIBUTE + " attribute is not a valid number." ); } }
private void validateChildren(List<Element> children) throws WindupException{ if(children.size() != 1) { throw new WindupException("The <" + ELEMENT_NAME + "> element must have exactly 1 child." ); } } }
private void validateChildren(List<Element> children) { if(children.size() != 1) { throw new WindupException("The <" + ELEMENT_NAME + "> element must have exactly 1 child." ); } } }
private Object setAndWarnIfDifferent(String what, Object existing, Object newOne) { if (existing == null) return newOne; if (existing.equals(newOne) || newOne == null) return existing; throw new WindupException(String.format("Trait '%s' was expected to be new or same as previously seen, but were:" + "\n Existing: %s" + "\n New: %s", what, existing, newOne)); } }
@SuppressWarnings("unchecked") private Class<? extends WindupVertexFrame> cast(Class<? extends WindupFrame> typeAsWindupFrame) { if (!WindupVertexFrame.class.isAssignableFrom(typeAsWindupFrame)) throw new WindupException("Only types that are a subclass of " + WindupVertexFrame.class.getCanonicalName() + " are supported by the " + ELEMENT_NAME + " element!"); return (Class<? extends WindupVertexFrame>) typeAsWindupFrame; } }
@SuppressWarnings("unchecked") private Class<? extends WindupVertexFrame> cast(Class<? extends WindupFrame> typeAsWindupFrame) { if (!WindupVertexFrame.class.isAssignableFrom(typeAsWindupFrame)) throw new WindupException("Only types that are a subclass of " + WindupVertexFrame.class.getCanonicalName() + " are supported by the " + ELEMENT_NAME + " element!"); return (Class<? extends WindupVertexFrame>) typeAsWindupFrame; } }
protected Path castToPath(Object file) { if (file instanceof File) return ((File) file).toPath(); else if (file instanceof Path) return (Path) file; else throw new WindupException("Unrecognized type: " + file.getClass().getCanonicalName()); }
protected Path castToPath(Object file) { if (file instanceof File) return ((File) file).toPath(); else if (file instanceof Path) return (Path) file; else throw new WindupException("Unrecognized type: " + file.getClass().getCanonicalName()); }
public Tag getTag(String tagName) { Tag tag = findTag(tagName); if (null == tag) throw new WindupException("Tag does not exist: " + tagName); return tag; }
public Tag getTag(String tagName) { Tag tag = findTag(tagName); if (null == tag) throw new WindupException("Tag does not exist: " + tagName); return tag; }
@Override public AnnotationLiteralCondition processElement(ParserContext handlerManager, Element element) throws ConfigurationException { String pattern = element.getAttribute(PATTERN); if (StringUtils.isBlank(pattern)) throw new WindupException(ANNOTATION_LITERAL + " element requires a " + PATTERN + " attribute!"); return new AnnotationLiteralCondition(pattern); } }
private static void handleAdder(Vertex vertex, Method method, Object[] args, SetInProperties ann) { if (args == null || args.length == 0) throw new WindupException("Method must take at least one String argument: " + method.getName()); String prefix = preparePrefix(ann); for (Object arg : args) { if (!(arg instanceof String)) throw new WindupException("The arguments of the add*() method " + method.getName() + " must be String, but was: " + arg.getClass()); vertex.property(prefix + arg, SET_VERTEX_PROP_VALUE); } }
@Nullable @Override public Iterable<FileModel> apply(WindupVertexFrame windupVertexFrame) { if (!(windupVertexFrame instanceof ToFileModelTransformable)) { throw new WindupException("ToFileModel may work only with the objects that implements ToFileModelTransformable interface"); } return ((ToFileModelTransformable) windupVertexFrame).transformToFileModel(); } });
@Override public AnnotationLiteralCondition processElement(ParserContext handlerManager, Element element) throws ConfigurationException { String pattern = element.getAttribute(PATTERN); if (StringUtils.isBlank(pattern)) throw new WindupException(ANNOTATION_LITERAL + " element requires a " + PATTERN + " attribute!"); return new AnnotationLiteralCondition(pattern); } }
@Override public <E> DynamicType.Builder<E> processMethod(final DynamicType.Builder<E> builder, final Method method, final Annotation annotation) { String methodName = method.getName(); if (methodName.startsWith("get")) return createInterceptor(builder, method); else if (methodName.startsWith("set")) return createInterceptor(builder, method); throw new WindupException("Only get* and set* method names are supported for @" + MapInAdjacentProperties.class.getSimpleName()); }
@Override public <E> DynamicType.Builder<E> processMethod(final DynamicType.Builder<E> builder, final Method method, final Annotation annotation) { String methodName = method.getName(); if (methodName.startsWith("get")) return createInterceptor(builder, method); else if (methodName.startsWith("set")) return createInterceptor(builder, method); throw new WindupException("Only get* and set* method names are supported for @" + MapInAdjacentProperties.class.getSimpleName()); }