Browse Source

Polish

pull/28056/head
Stephane Nicoll 4 years ago
parent
commit
5fbd01f28f
  1. 11
      spring-core/src/main/java/org/springframework/aot/hint/TypeHint.java
  2. 8
      spring-core/src/test/java/org/springframework/aot/hint/TypeHintTests.java

11
spring-core/src/main/java/org/springframework/aot/hint/TypeHint.java

@ -23,10 +23,12 @@ import java.util.List; @@ -23,10 +23,12 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.StringJoiner;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -39,6 +41,7 @@ public final class TypeHint { @@ -39,6 +41,7 @@ public final class TypeHint {
private final TypeReference type;
@Nullable
private final TypeReference reachableType;
private final Set<FieldHint> fields;
@ -83,6 +86,7 @@ public final class TypeHint { @@ -83,6 +86,7 @@ public final class TypeHint {
* {@code null} if this hint should always been applied.
* @return the reachable type, if any
*/
@Nullable
public TypeReference getReachableType() {
return this.reachableType;
}
@ -119,6 +123,12 @@ public final class TypeHint { @@ -119,6 +123,12 @@ public final class TypeHint {
return this.memberCategories;
}
@Override
public String toString() {
return new StringJoiner(", ", TypeHint.class.getSimpleName() + "[", "]")
.add("type=" + this.type)
.toString();
}
/**
* Builder for {@link TypeHint}.
@ -127,6 +137,7 @@ public final class TypeHint { @@ -127,6 +137,7 @@ public final class TypeHint {
private final TypeReference type;
@Nullable
private TypeReference reachableType;
private final Map<String, FieldHint.Builder> fields = new HashMap<>();

8
spring-core/src/test/java/org/springframework/aot/hint/TypeHintTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -137,4 +137,10 @@ class TypeHintTests { @@ -137,4 +137,10 @@ class TypeHintTests {
assertThat(hint.getMemberCategories()).containsOnly(MemberCategory.DECLARED_FIELDS);
}
@Test
void typeHintHasAppropriateToString() {
TypeHint hint = TypeHint.of(TypeReference.of(String.class)).build();
assertThat(hint).hasToString("TypeHint[type=java.lang.String]");
}
}

Loading…
Cancel
Save