Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide SerializationHintsPredicates in RuntimeHintsPredicates #28772

Closed
marcusdacoregio opened this issue Jul 7, 2022 · 1 comment
Closed
Assignees
Labels
theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Milestone

Comments

@marcusdacoregio
Copy link
Contributor

It would be nice to have the SerializationHintsPredicates in RuntimeHintsPredicates as we have for reflections, resource and proxies.

I've created one myself for now:

public class SerializationHintsPredicates {

	public TypeHintPredicate onType(TypeReference typeReference) {
		Assert.notNull(typeReference, "'typeReference' should not be null");
		return new TypeHintPredicate(typeReference);
	}

	public TypeHintPredicate onType(Class<?> type) {
		Assert.notNull(type, "'type' should not be null");
		return new TypeHintPredicate(TypeReference.of(type));
	}

	public static class TypeHintPredicate implements Predicate<RuntimeHints> {

		private final TypeReference type;

		TypeHintPredicate(TypeReference type) {
			this.type = type;
		}

		@Override
		public boolean test(RuntimeHints hints) {
			return hints.serialization().javaSerialization().anyMatch((hint) -> hint.getType().equals(this.type));
		}

	}

}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 7, 2022
@sdeleuze sdeleuze added this to the 6.0.0-M6 milestone Jul 7, 2022
@sdeleuze sdeleuze added type: enhancement A general enhancement theme: aot An issue related to Ahead-of-time processing and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 7, 2022
@snicoll snicoll self-assigned this Jul 11, 2022
@snicoll snicoll modified the milestones: 6.0.0-M6, 5.3.22, 6.0.0-M5 Jul 11, 2022
@snicoll
Copy link
Member

snicoll commented Jul 11, 2022

Good catch @marcusdacoregio, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants