/** * Adds a new param to the Javadoc. * * @param paramName Name of parameter. * @param paramDocs Documentation for parameter. * @return This builder for method chaining. */ public DocumentationBuilder param(String paramName, String paramDocs) { this.params.add(Pair.of(paramName, paramDocs)); return this; }
public static <LeftT, RightT> Pair<LeftT, RightT> of(LeftT left, RightT right) { return new Pair<>(left, right); } }
private void appendAsyncThrows(StringBuilder str) { str.append("<br/>").append(LF).append( asyncThrows.stream() .map(t -> t.apply((exName, exDocs) -> String.format("<li>%s %s</li>", exName, exDocs))) .collect(Collectors.joining(LF, ASYNC_THROWS_PREFIX + LF + "<ul>" + LF, LF + "</ul>"))); }
if (state.profiles.get(state.currentProfileBeingRead).containsKey(property.left())) { log.warn(() -> "Warning: Duplicate property '" + property.left() + "' detected on line " + state.currentLineNumber + ". The later one in the file will be used."); state.currentPropertyBeingRead = property.left(); state.ignoringCurrentProperty = false; state.validatingContinuationsAsSubProperties = property.right().equals(""); state.profiles.get(state.currentProfileBeingRead).put(property.left(), property.right());
@Override public SdkHttpFullResponse execute(Pair<SdkHttpFullRequest, SdkHttpFullResponse> input, RequestExecutionContext context) throws Exception { context.interceptorChain().beforeUnmarshalling(context.executionContext().interceptorContext(), context.executionAttributes()); InterruptMonitor.checkInterrupted(input.right()); return input.right(); } }
if (state.profiles.get(state.currentProfileBeingRead).containsKey(property.left())) { log.warn(() -> "Warning: Duplicate property '" + property.left() + "' detected on line " + state.currentLineNumber + ". The later one in the file will be used."); state.currentPropertyBeingRead = property.left(); state.ignoringCurrentProperty = false; state.validatingContinuationsAsSubProperties = property.right().equals(""); state.profiles.get(state.currentProfileBeingRead).put(property.left(), property.right());
/** * Adds a new param to the Javadoc. * * @param paramName Name of parameter. * @param paramDocs Documentation for parameter. * @return This builder for method chaining. */ public DocumentationBuilder param(String paramName, String paramDocs) { this.params.add(Pair.of(paramName, paramDocs)); return this; }
@SuppressWarnings("unchecked") private T unmarshallResponse(SdkHttpFullResponse response) throws Exception { SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response XML."); Pair<T, Map<String, String>> result = unmarshaller.unmarshall(pojoSupplier.apply(response), response); SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Done parsing service response."); AwsResponseMetadata responseMetadata = generateResponseMetadata(response, result.right()); return (T) result.left().toBuilder().responseMetadata(responseMetadata).build(); }
private void appendAsyncThrows(StringBuilder str) { str.append("<br/>").append(LF).append( asyncThrows.stream() .map(t -> t.apply((exName, exDocs) -> String.format("<li>%s %s</li>", exName, exDocs))) .collect(Collectors.joining(LF, ASYNC_THROWS_PREFIX + LF + "<ul>" + LF, LF + "</ul>"))); }
public static <LeftT, RightT> Pair<LeftT, RightT> of(LeftT left, RightT right) { return new Pair<>(left, right); } }
/** * Adds an arbitrary tag with values to the Javadoc. This will be added in between the throws and see sections * of the Javadoc. * * @param tagName Name of tag to add. * @param tagValues List of values associated with the same. * @return This builder for method chaining. */ public DocumentationBuilder tag(String tagName, String... tagValues) { tags.add(Pair.of(tagName, Arrays.asList(tagValues))); return this; }
@SuppressWarnings("unchecked") private T unmarshallResponse(SdkHttpFullResponse response) throws Exception { SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response XML."); Pair<T, Map<String, String>> result = unmarshaller.unmarshall(pojoSupplier.apply(response), response); SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Done parsing service response."); AwsResponseMetadata responseMetadata = generateResponseMetadata(response, result.right()); return (T) result.left().toBuilder().responseMetadata(responseMetadata).build(); }
/** * Builds the Javadoc string with the current configuration. * * @return Formatted Javadoc string. */ public String build() { StringBuilder str = new StringBuilder(); if (StringUtils.isNotBlank(desc)) { str.append(desc).append(LF).append(LF); } params.forEach(p -> p.apply((paramName, paramDoc) -> formatParam(str, paramName, paramDoc))); if (hasReturn() || !asyncThrows.isEmpty()) { str.append("@return "); if (hasReturn()) { str.append(returns); } if (!asyncThrows.isEmpty()) { // If no docs were provided for success returns add a generic one. if (!hasReturn()) { str.append("A CompletableFuture indicating when result will be completed."); } appendAsyncThrows(str); } str.append(LF); } syncThrows.forEach(t -> t.apply((exName, exDoc) -> formatThrows(str, exName, exDoc))); tags.forEach(t -> t.apply((tagName, tagVals) -> formatTag(str, tagName, tagVals))); see.forEach(s -> str.append("@see ").append(s).append(LF)); return str.toString(); }
/** * Adds an arbitrary tag with values to the Javadoc. This will be added in between the throws and see sections * of the Javadoc. * * @param tagName Name of tag to add. * @param tagValues List of values associated with the same. * @return This builder for method chaining. */ public DocumentationBuilder tag(String tagName, String... tagValues) { tags.add(Pair.of(tagName, Arrays.asList(tagValues))); return this; }
@Override public AwsServiceException handle(SdkHttpFullResponse response, ExecutionAttributes executionAttributes) { Pair<XmlElement, SdkBytes> xmlAndBytes = parseXml(response); XmlElement document = xmlAndBytes.left(); Optional<XmlElement> errorRoot = errorRootExtractor.apply(document); String errorCode = getErrorCode(errorRoot); AwsServiceException.Builder builder = errorRoot .map(e -> invokeSafely(() -> unmarshallFromErrorCode(response, e, errorCode))) .orElseGet(this::defaultException); AwsErrorDetails awsErrorDetails = AwsErrorDetails.builder() .errorCode(errorCode) .errorMessage(builder.message()) .rawResponse(xmlAndBytes.right()) .sdkHttpResponse(response) .serviceName(executionAttributes.getAttribute(AwsExecutionAttribute.SERVICE_NAME)) .build(); builder.requestId(getRequestId(response, document)) .statusCode(response.statusCode()) .awsErrorDetails(awsErrorDetails); return builder.build(); }
/** * Builds the Javadoc string with the current configuration. * * @return Formatted Javadoc string. */ public String build() { StringBuilder str = new StringBuilder(); if (StringUtils.isNotBlank(desc)) { str.append(desc).append(LF).append(LF); } params.forEach(p -> p.apply((paramName, paramDoc) -> formatParam(str, paramName, paramDoc))); if (hasReturn() || !asyncThrows.isEmpty()) { str.append("@return "); if (hasReturn()) { str.append(returns); } if (!asyncThrows.isEmpty()) { // If no docs were provided for success returns add a generic one. if (!hasReturn()) { str.append("A CompletableFuture indicating when result will be completed."); } appendAsyncThrows(str); } str.append(LF); } syncThrows.forEach(t -> t.apply((exName, exDoc) -> formatThrows(str, exName, exDoc))); tags.forEach(t -> t.apply((tagName, tagVals) -> formatTag(str, tagName, tagVals))); see.forEach(s -> str.append("@see ").append(s).append(LF)); return str.toString(); }
/** * Adds a throws tag to the Javadoc. * * @param exceptionClass Class name of thrown exception. * @param exceptionDoc Documentation for thrown exception. * @return This builder for method chaining. */ public DocumentationBuilder syncThrows(String exceptionClass, String exceptionDoc) { return syncThrows(singletonList(Pair.of(exceptionClass, exceptionDoc))); }
@Override public AwsServiceException handle(SdkHttpFullResponse response, ExecutionAttributes executionAttributes) { Pair<XmlElement, SdkBytes> xmlAndBytes = parseXml(response); XmlElement document = xmlAndBytes.left(); Optional<XmlElement> errorRoot = errorRootExtractor.apply(document); String errorCode = getErrorCode(errorRoot); AwsServiceException.Builder builder = errorRoot .map(e -> invokeSafely(() -> unmarshallFromErrorCode(response, e, errorCode))) .orElseGet(this::defaultException); AwsErrorDetails awsErrorDetails = AwsErrorDetails.builder() .errorCode(errorCode) .errorMessage(builder.message()) .rawResponse(xmlAndBytes.right()) .sdkHttpResponse(response) .serviceName(executionAttributes.getAttribute(AwsExecutionAttribute.SERVICE_NAME)) .build(); builder.requestId(getRequestId(response, document)) .statusCode(response.statusCode()) .awsErrorDetails(awsErrorDetails); return builder.build(); }
/** * Async exceptions are not thrown from the method, rather the returned {@link java.util.concurrent.CompletableFuture} is * completed exceptionally ({@link java.util.concurrent.CompletableFuture#completeExceptionally(Throwable)}. Because of this * we don't add @throws to the Javadocs or method signature for async methods, we instead add a list of exceptions the future * may be completed exceptionally with in the @returns section of the Javadoc. * * @param exceptionClass Class name of thrown exception. * @param exceptionDoc Documentation for thrown exception. * @return This builder for method chaining. */ public DocumentationBuilder asyncThrows(String exceptionClass, String exceptionDoc) { return asyncThrows(singletonList(Pair.of(exceptionClass, exceptionDoc))); }