com.github.hal4j.resources.ResourcesBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hal4j-api Show documentation
Show all versions of hal4j-api Show documentation
HAL API specification for Java
package com.github.hal4j.resources;
import com.github.hal4j.resources.curie.CurieResolver;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import static java.util.stream.Collectors.toList;
public class ResourcesBuilder
extends ResourceBuilderSupport, ResourcesBuilder>
implements Builder> {
private final Class elementType;
private final Collection elements;
private Function> binding;
public ResourcesBuilder(Class elementType,
Collection elements,
CurieResolver resolver) {
super(resolver);
this.elementType = elementType;
this.elements = elements;
}
public ResourcesBuilder as(Function> bindingFunction) {
this.binding = bindingFunction;
return this;
}
@Override
protected ResourcesBuilder _this() {
return this;
}
@Override
public Resources build() {
List> model = elements.stream().map(binding).collect(toList());
return new Resources(_links, _embedded, elementType, model, context());
}
}