#1557 - Polishing.
This commit is contained in:
committed by
Oliver Drotbohm
parent
33e853cbb5
commit
fff452cf8a
@@ -149,8 +149,8 @@ public abstract class AffordanceModel {
|
||||
*/
|
||||
public <T> List<T> createProperties(BiFunction<InputPayloadMetadata, PropertyMetadata, T> creator) {
|
||||
|
||||
return input.stream()
|
||||
.map(it -> creator.apply(input, it))
|
||||
return input.stream() //
|
||||
.map(it -> creator.apply(input, it)) //
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ public class PropertyUtils {
|
||||
|
||||
static {
|
||||
|
||||
INPUT_TYPE_FACTORY = SpringFactoriesLoader.loadFactories(InputTypeFactory.class,
|
||||
INPUT_TYPE_FACTORY = SpringFactoriesLoader.loadFactories(InputTypeFactory.class, //
|
||||
DefaultPropertyMetadata.class.getClassLoader()).get(0);
|
||||
}
|
||||
|
||||
@@ -528,8 +528,8 @@ public class PropertyUtils {
|
||||
|
||||
String annotatedInputType = getAnnotatedInputType();
|
||||
|
||||
return annotatedInputType != null
|
||||
? annotatedInputType
|
||||
return annotatedInputType != null //
|
||||
? annotatedInputType //
|
||||
: INPUT_TYPE_FACTORY.getInputType(getType().resolve(Object.class));
|
||||
}
|
||||
|
||||
@@ -684,8 +684,8 @@ public class PropertyUtils {
|
||||
@Nullable
|
||||
@Override
|
||||
public Long getMinLength() {
|
||||
return LENGTH_ANNOTATION.flatMap(it -> getAnnotationAttribute(it, "min", Integer.class))
|
||||
.map(Integer::longValue)
|
||||
return LENGTH_ANNOTATION.flatMap(it -> getAnnotationAttribute(it, "min", Integer.class)) //
|
||||
.map(Integer::longValue) //
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@@ -696,8 +696,8 @@ public class PropertyUtils {
|
||||
@Nullable
|
||||
@Override
|
||||
public Long getMaxLength() {
|
||||
return LENGTH_ANNOTATION.flatMap(it -> getAnnotationAttribute(it, "max", Integer.class))
|
||||
.map(Integer::longValue)
|
||||
return LENGTH_ANNOTATION.flatMap(it -> getAnnotationAttribute(it, "max", Integer.class)) //
|
||||
.map(Integer::longValue) //
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@@ -733,14 +733,14 @@ public class PropertyUtils {
|
||||
|
||||
private String lookupFromTypeMap() {
|
||||
|
||||
return TYPE_MAP.entrySet().stream()
|
||||
return TYPE_MAP.entrySet().stream() //
|
||||
.flatMap(it -> {
|
||||
|
||||
MergedAnnotation<? extends Annotation> annotation = property.getAnnotation(it.getKey());
|
||||
|
||||
return annotation.isPresent() ? Stream.of(it.getValue()) : Stream.empty();
|
||||
})
|
||||
.findFirst()
|
||||
}) //
|
||||
.findFirst() //
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ final class HalFormsProperty implements Named {
|
||||
}
|
||||
|
||||
private HalFormsProperty(String name, boolean readOnly, @Nullable Object value, String prompt, String regex,
|
||||
boolean templated,
|
||||
boolean templated, //
|
||||
boolean required, boolean multi, String placeholder, @Nullable Number min, @Nullable Number max,
|
||||
@Nullable Long minLength, @Nullable Long maxLength, @Nullable HtmlInputType type,
|
||||
@Nullable HalFormsOptions options) {
|
||||
|
||||
@@ -111,7 +111,7 @@ class HalFormsTemplateBuilderUnitTest {
|
||||
.withInput(Payload.class) //
|
||||
.toLink();
|
||||
|
||||
HalFormsTemplate template = new HalFormsTemplateBuilder(new HalFormsConfiguration(),
|
||||
HalFormsTemplate template = new HalFormsTemplateBuilder(new HalFormsConfiguration(), //
|
||||
MessageResolver.DEFAULTS_ONLY).findTemplates(new RepresentationModel<>().add(link)).get("default");
|
||||
|
||||
Optional<HalFormsProperty> number = template.getPropertyByName("number");
|
||||
@@ -149,7 +149,7 @@ class HalFormsTemplateBuilderUnitTest {
|
||||
Link link = Affordances.of(Link.of("/example", LinkRelation.of("create"))) //
|
||||
.afford(HttpMethod.POST) //
|
||||
.withInput(Payload.class) //
|
||||
.withName("create")
|
||||
.withName("create") //
|
||||
.toLink();
|
||||
|
||||
Map<String, HalFormsTemplate> templates = new HalFormsTemplateBuilder(new HalFormsConfiguration(),
|
||||
@@ -181,21 +181,21 @@ class HalFormsTemplateBuilderUnitTest {
|
||||
|
||||
List<String> values = Arrays.asList("1234123412341234", "4321432143214321");
|
||||
|
||||
HalFormsConfiguration configuration = new HalFormsConfiguration()
|
||||
HalFormsConfiguration configuration = new HalFormsConfiguration() //
|
||||
.withOptions(PatternExample.class, "number", metadata -> HalFormsOptions.inline(values));
|
||||
|
||||
RepresentationModel<?> models = new RepresentationModel<>(
|
||||
Affordances.of(Link.of("/example", LinkRelation.of("create")))
|
||||
.afford(HttpMethod.POST)
|
||||
.withInput(PatternExample.class)
|
||||
Affordances.of(Link.of("/example", LinkRelation.of("create"))) //
|
||||
.afford(HttpMethod.POST) //
|
||||
.withInput(PatternExample.class) //
|
||||
.toLink());
|
||||
|
||||
Map<String, HalFormsTemplate> templates = new HalFormsTemplateBuilder(configuration, MessageResolver.DEFAULTS_ONLY)
|
||||
.findTemplates(models);
|
||||
|
||||
assertThat(templates.get("default").getPropertyByName("number"))
|
||||
assertThat(templates.get("default").getPropertyByName("number")) //
|
||||
.hasValueSatisfying(it -> {
|
||||
assertThat(it.getOptions()).isNotNull()
|
||||
assertThat(it.getOptions()).isNotNull() //
|
||||
.isInstanceOfSatisfying(HalFormsOptions.Inline.class,
|
||||
inline -> assertThat(inline.getInline()).isEqualTo(values));
|
||||
});
|
||||
@@ -207,14 +207,14 @@ class HalFormsTemplateBuilderUnitTest {
|
||||
String selected = "1234123412341234";
|
||||
List<String> values = Arrays.asList(selected, "4321432143214321");
|
||||
|
||||
HalFormsConfiguration configuration = new HalFormsConfiguration()
|
||||
HalFormsConfiguration configuration = new HalFormsConfiguration() //
|
||||
.withOptions(PatternExample.class, "number",
|
||||
metadata -> HalFormsOptions.inline(values).withSelectedValue(selected));
|
||||
|
||||
RepresentationModel<?> models = new RepresentationModel<>(
|
||||
Affordances.of(Link.of("/example", LinkRelation.of("create")))
|
||||
.afford(HttpMethod.POST)
|
||||
.withInput(PatternExample.class)
|
||||
Affordances.of(Link.of("/example", LinkRelation.of("create"))) //
|
||||
.afford(HttpMethod.POST) //
|
||||
.withInput(PatternExample.class) //
|
||||
.toLink());
|
||||
|
||||
Map<String, HalFormsTemplate> templates = new HalFormsTemplateBuilder(configuration, MessageResolver.DEFAULTS_ONLY)
|
||||
|
||||
Reference in New Issue
Block a user