#1505 - Improve signatures of HalFormsOptions.inline(…).
A bit of generics ♥️ for HalFormsOptions.inline(…) to avoid compiler warnings.
This commit is contained in:
@@ -43,7 +43,8 @@ public interface HalFormsOptions {
|
||||
* @param values must not be {@literal null}.
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public static Inline inline(Object... values) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Inline inline(T... values) {
|
||||
|
||||
Assert.notNull(values, "Values must not be null!");
|
||||
|
||||
@@ -56,7 +57,7 @@ public interface HalFormsOptions {
|
||||
* @param values must not be {@literal null}.
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public static Inline inline(Collection<Object> values) {
|
||||
public static Inline inline(Collection<? extends Object> values) {
|
||||
|
||||
Assert.notNull(values, "Values must not be null!");
|
||||
|
||||
@@ -253,14 +254,14 @@ public interface HalFormsOptions {
|
||||
|
||||
public static class Inline extends AbstractHalFormsOptions<Inline> {
|
||||
|
||||
private final Collection<Object> inline;
|
||||
private final Collection<? extends Object> inline;
|
||||
|
||||
/**
|
||||
* @param values
|
||||
* @param promptRef
|
||||
* @param valueRef
|
||||
*/
|
||||
private Inline(Collection<Object> values, @Nullable String promptRef, @Nullable String valueRef,
|
||||
private Inline(Collection<? extends Object> values, @Nullable String promptRef, @Nullable String valueRef,
|
||||
@Nullable Long minItems, @Nullable Long maxItems) {
|
||||
|
||||
super(promptRef, valueRef, minItems, maxItems);
|
||||
@@ -276,7 +277,7 @@ public interface HalFormsOptions {
|
||||
* @return
|
||||
*/
|
||||
@JsonProperty
|
||||
public Collection<Object> getInline() {
|
||||
public Collection<? extends Object> getInline() {
|
||||
return inline;
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ class HalFormsTemplateBuilderUnitTest {
|
||||
@Test // #1483
|
||||
void rendersRegisteredSuggest() {
|
||||
|
||||
List<Object> values = Arrays.asList("1234123412341234", "4321432143214321");
|
||||
List<String> values = Arrays.asList("1234123412341234", "4321432143214321");
|
||||
|
||||
HalFormsConfiguration configuration = new HalFormsConfiguration()
|
||||
.withOptions(PatternExample.class, "number", metadata -> HalFormsOptions.inline(values));
|
||||
|
||||
Reference in New Issue
Block a user