Harmonize accessors of RuntimeHints API
Closes gh-29269
This commit is contained in:
@@ -36,7 +36,7 @@ public class ProxyHints {
|
||||
* Return the interface-based proxies that are required.
|
||||
* @return a stream of {@link JdkProxyHint}
|
||||
*/
|
||||
public Stream<JdkProxyHint> jdkProxies() {
|
||||
public Stream<JdkProxyHint> jdkProxyHints() {
|
||||
return this.jdkProxies.stream();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ResourceHints {
|
||||
* Return the resources that should be made available at runtime.
|
||||
* @return a stream of {@link ResourcePatternHints}
|
||||
*/
|
||||
public Stream<ResourcePatternHints> resourcePatterns() {
|
||||
public Stream<ResourcePatternHints> resourcePatternHints() {
|
||||
Stream<ResourcePatternHints> patterns = this.resourcePatternHints.stream();
|
||||
return (this.types.isEmpty() ? patterns
|
||||
: Stream.concat(Stream.of(typesPatternResourceHint()), patterns));
|
||||
@@ -64,7 +64,7 @@ public class ResourceHints {
|
||||
* Return the resource bundles that should be made available at runtime.
|
||||
* @return a stream of {@link ResourceBundleHint}
|
||||
*/
|
||||
public Stream<ResourceBundleHint> resourceBundles() {
|
||||
public Stream<ResourceBundleHint> resourceBundleHints() {
|
||||
return this.resourceBundleHints.stream();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SerializationHints {
|
||||
* that need to be serialized using Java serialization at runtime.
|
||||
* @return a stream of {@link JavaSerializationHint java serialization hints}
|
||||
*/
|
||||
public Stream<JavaSerializationHint> javaSerialization() {
|
||||
public Stream<JavaSerializationHint> javaSerializationHints() {
|
||||
return this.javaSerializationHints.stream();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ProxyHintsPredicates {
|
||||
public Predicate<RuntimeHints> forInterfaces(TypeReference... interfaces) {
|
||||
Assert.notEmpty(interfaces, "'interfaces' should not be empty");
|
||||
List<TypeReference> interfaceList = Arrays.asList(interfaces);
|
||||
return hints -> hints.proxies().jdkProxies().anyMatch(proxyHint ->
|
||||
return hints -> hints.proxies().jdkProxyHints().anyMatch(proxyHint ->
|
||||
proxyHint.getProxiedInterfaces().equals(interfaceList));
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ResourceHintsPredicates {
|
||||
*/
|
||||
public Predicate<RuntimeHints> forBundle(String bundleName) {
|
||||
Assert.hasText(bundleName, "resource bundle name should not be empty");
|
||||
return runtimeHints -> runtimeHints.resources().resourceBundles()
|
||||
return runtimeHints -> runtimeHints.resources().resourceBundleHints()
|
||||
.anyMatch(bundleHint -> bundleName.equals(bundleHint.getBaseName()));
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ResourceHintsPredicates {
|
||||
static AggregatedResourcePatternHints of(ResourceHints resourceHints) {
|
||||
List<ResourcePatternHint> includes = new ArrayList<>();
|
||||
List<ResourcePatternHint> excludes = new ArrayList<>();
|
||||
resourceHints.resourcePatterns().forEach(resourcePatternHint -> {
|
||||
resourceHints.resourcePatternHints().forEach(resourcePatternHint -> {
|
||||
includes.addAll(resourcePatternHint.getIncludes());
|
||||
excludes.addAll(resourcePatternHint.getExcludes());
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ public class SerializationHintsPredicates {
|
||||
*/
|
||||
public Predicate<RuntimeHints> onType(TypeReference typeReference) {
|
||||
Assert.notNull(typeReference, "'typeReference' should not be null");
|
||||
return hints -> hints.serialization().javaSerialization().anyMatch(
|
||||
return hints -> hints.serialization().javaSerializationHints().anyMatch(
|
||||
hint -> hint.getType().equals(typeReference));
|
||||
}
|
||||
|
||||
|
||||
@@ -40,17 +40,17 @@ public abstract class NativeConfigurationWriter {
|
||||
* @param hints the hints to handle
|
||||
*/
|
||||
public void write(RuntimeHints hints) {
|
||||
if (hints.serialization().javaSerialization().findAny().isPresent()) {
|
||||
writeJavaSerializationHints(hints.serialization());
|
||||
if (hints.serialization().javaSerializationHints().findAny().isPresent()) {
|
||||
writeSerializationHints(hints.serialization());
|
||||
}
|
||||
if (hints.proxies().jdkProxies().findAny().isPresent()) {
|
||||
if (hints.proxies().jdkProxyHints().findAny().isPresent()) {
|
||||
writeProxyHints(hints.proxies());
|
||||
}
|
||||
if (hints.reflection().typeHints().findAny().isPresent()) {
|
||||
writeReflectionHints(hints.reflection());
|
||||
}
|
||||
if (hints.resources().resourcePatterns().findAny().isPresent() ||
|
||||
hints.resources().resourceBundles().findAny().isPresent()) {
|
||||
if (hints.resources().resourcePatternHints().findAny().isPresent() ||
|
||||
hints.resources().resourceBundleHints().findAny().isPresent()) {
|
||||
writeResourceHints(hints.resources());
|
||||
}
|
||||
if (hints.jni().typeHints().findAny().isPresent()) {
|
||||
@@ -66,7 +66,7 @@ public abstract class NativeConfigurationWriter {
|
||||
*/
|
||||
protected abstract void writeTo(String fileName, Consumer<BasicJsonWriter> writer);
|
||||
|
||||
private void writeJavaSerializationHints(SerializationHints hints) {
|
||||
private void writeSerializationHints(SerializationHints hints) {
|
||||
writeTo("serialization-config.json", writer ->
|
||||
SerializationHintsWriter.INSTANCE.write(writer, hints));
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class ProxyHintsWriter {
|
||||
public static final ProxyHintsWriter INSTANCE = new ProxyHintsWriter();
|
||||
|
||||
public void write(BasicJsonWriter writer, ProxyHints hints) {
|
||||
writer.writeArray(hints.jdkProxies().map(this::toAttributes).toList());
|
||||
writer.writeArray(hints.jdkProxyHints().map(this::toAttributes).toList());
|
||||
}
|
||||
|
||||
private Map<String, Object> toAttributes(JdkProxyHint hint) {
|
||||
|
||||
@@ -47,15 +47,15 @@ class ResourceHintsWriter {
|
||||
public void write(BasicJsonWriter writer, ResourceHints hints) {
|
||||
Map<String, Object> attributes = new LinkedHashMap<>();
|
||||
addIfNotEmpty(attributes, "resources", toAttributes(hints));
|
||||
handleResourceBundles(attributes, hints.resourceBundles());
|
||||
handleResourceBundles(attributes, hints.resourceBundleHints());
|
||||
writer.writeObject(attributes);
|
||||
}
|
||||
|
||||
private Map<String, Object> toAttributes(ResourceHints hint) {
|
||||
Map<String, Object> attributes = new LinkedHashMap<>();
|
||||
addIfNotEmpty(attributes, "includes", hint.resourcePatterns().map(ResourcePatternHints::getIncludes)
|
||||
addIfNotEmpty(attributes, "includes", hint.resourcePatternHints().map(ResourcePatternHints::getIncludes)
|
||||
.flatMap(List::stream).distinct().map(this::toAttributes).toList());
|
||||
addIfNotEmpty(attributes, "excludes", hint.resourcePatterns().map(ResourcePatternHints::getExcludes)
|
||||
addIfNotEmpty(attributes, "excludes", hint.resourcePatternHints().map(ResourcePatternHints::getExcludes)
|
||||
.flatMap(List::stream).distinct().map(this::toAttributes).toList());
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class SerializationHintsWriter {
|
||||
public static final SerializationHintsWriter INSTANCE = new SerializationHintsWriter();
|
||||
|
||||
public void write(BasicJsonWriter writer, SerializationHints hints) {
|
||||
writer.writeArray(hints.javaSerialization().map(this::toAttributes).toList());
|
||||
writer.writeArray(hints.javaSerializationHints().map(this::toAttributes).toList());
|
||||
}
|
||||
|
||||
private Map<String, Object> toAttributes(JavaSerializationHint serializationHint) {
|
||||
|
||||
Reference in New Issue
Block a user