Skip to content

Commit

Permalink
Pass GenerationOptions down to Children in FutureReflectionResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpartsch committed Mar 21, 2022
1 parent 03705ec commit 9be5e0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group 'com.docutools'
version = '1.4.0-alpha.24'
version = '1.4.0-alpha.25'

sourceCompatibility = "17"
targetCompatibility = "17"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.docutools.jocument.impl;

import com.docutools.jocument.CustomPlaceholderRegistry;
import com.docutools.jocument.GenerationOptions;
import com.docutools.jocument.GenerationOptionsBuilder;
import com.docutools.jocument.PlaceholderData;
import com.docutools.jocument.PlaceholderResolver;
import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -38,8 +40,16 @@ public FutureReflectionResolver(Object value, CustomPlaceholderRegistry customPl
public FutureReflectionResolver(Object value,
CustomPlaceholderRegistry customPlaceholderRegistry,
long maximumWaitTimeSeconds) {
this(value, customPlaceholderRegistry, GenerationOptionsBuilder.buildDefaultOptions(), maximumWaitTimeSeconds);
}

public FutureReflectionResolver(Object value,
CustomPlaceholderRegistry customPlaceholderRegistry,
GenerationOptions options,
long maximumWaitTimeSeconds) {
super(value, customPlaceholderRegistry);
this.maximumWaitTime = maximumWaitTimeSeconds;
setOptions(options);
}

@Override
Expand Down Expand Up @@ -67,13 +77,13 @@ public Optional<PlaceholderData> doReflectiveResolve(String placeholderName, Loc
if (property instanceof Collection<?> collection) {
logger.debug("Placeholder {} resolved to collection", placeholderName);
List<PlaceholderResolver> list = collection.stream()
.map(object -> new FutureReflectionResolver(object, customPlaceholderRegistry, maximumWaitTime))
.map(object -> new FutureReflectionResolver(object, customPlaceholderRegistry, options, maximumWaitTime))
.collect(Collectors.toList());
return Optional.of(new IterablePlaceholderData(list, list.size()));
}
if (bean.equals(property)) {
logger.debug("Placeholder {} resolved to the parent object", placeholderName);
return Optional.of(new IterablePlaceholderData(List.of(new FutureReflectionResolver(bean, customPlaceholderRegistry, maximumWaitTime)), 1));
return Optional.of(new IterablePlaceholderData(List.of(new FutureReflectionResolver(bean, customPlaceholderRegistry, options, maximumWaitTime)), 1));
} else {
var value = getBeanProperty(placeholderName);
logger.debug("Resolved placeholder {} to the bean property {}", placeholderName, value);
Expand All @@ -83,7 +93,7 @@ public Optional<PlaceholderData> doReflectiveResolve(String placeholderName, Loc
logger.debug("Placeholder {} property future retrieved", placeholderName);
}
return Optional.of(
new IterablePlaceholderData(List.of(new FutureReflectionResolver(value, customPlaceholderRegistry, maximumWaitTime)), 1));
new IterablePlaceholderData(List.of(new FutureReflectionResolver(value, customPlaceholderRegistry, options, maximumWaitTime)), 1));
}
}
} catch (NoSuchMethodException | IllegalArgumentException e) {
Expand Down

0 comments on commit 9be5e0c

Please sign in to comment.