com.github.hal4j.resources.GenericResource 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 java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public final class GenericResource extends ResourceSupport {
public final Map model;
public GenericResource(Map model,
Map> _links,
Map> _embedded,
BindingContext ctx) {
super(_links, _embedded, ctx);
this.model = model != null ? Collections.unmodifiableMap(model) : null;
}
public GenericResource(Map model,
Map> _links,
Map> _embedded) {
this(model, _links, _embedded, null);
}
public GenericResource(Map> _links,
Map> _attachments) {
this(null, _links, _attachments, null);
}
public Resource as(Class clazz) {
T instance = context().bind(this.model, clazz);
return new Resource<>(this, instance);
}
@SuppressWarnings("unchecked")
public Resources asCollectionOf(Class clazz) {
List