Polish
This commit is contained in:
parent
d2d54c826f
commit
5fbd01f28f
|
@ -23,10 +23,12 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.StringJoiner;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,6 +41,7 @@ public final class TypeHint {
|
||||||
|
|
||||||
private final TypeReference type;
|
private final TypeReference type;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private final TypeReference reachableType;
|
private final TypeReference reachableType;
|
||||||
|
|
||||||
private final Set<FieldHint> fields;
|
private final Set<FieldHint> fields;
|
||||||
|
@ -83,6 +86,7 @@ public final class TypeHint {
|
||||||
* {@code null} if this hint should always been applied.
|
* {@code null} if this hint should always been applied.
|
||||||
* @return the reachable type, if any
|
* @return the reachable type, if any
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public TypeReference getReachableType() {
|
public TypeReference getReachableType() {
|
||||||
return this.reachableType;
|
return this.reachableType;
|
||||||
}
|
}
|
||||||
|
@ -119,6 +123,12 @@ public final class TypeHint {
|
||||||
return this.memberCategories;
|
return this.memberCategories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new StringJoiner(", ", TypeHint.class.getSimpleName() + "[", "]")
|
||||||
|
.add("type=" + this.type)
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder for {@link TypeHint}.
|
* Builder for {@link TypeHint}.
|
||||||
|
@ -127,6 +137,7 @@ public final class TypeHint {
|
||||||
|
|
||||||
private final TypeReference type;
|
private final TypeReference type;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private TypeReference reachableType;
|
private TypeReference reachableType;
|
||||||
|
|
||||||
private final Map<String, FieldHint.Builder> fields = new HashMap<>();
|
private final Map<String, FieldHint.Builder> fields = new HashMap<>();
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -137,4 +137,10 @@ class TypeHintTests {
|
||||||
assertThat(hint.getMemberCategories()).containsOnly(MemberCategory.DECLARED_FIELDS);
|
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…
Reference in New Issue