com.github.hal4j.resources.DefaultResourceFactory 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;
public class DefaultResourceFactory implements ResourceFactory {
private CurieResolver resolver;
private BindingContext context;
public DefaultResourceFactory() {
this(null, null);
}
public DefaultResourceFactory(CurieResolver resolver) {
this(resolver, null);
}
public DefaultResourceFactory(CurieResolver resolver, BindingContext context) {
this.resolver = resolver != null ? resolver : anyNamespace -> null;
this.context = context;
}
public ResourceBuilder bind(T object) {
return new ResourceBuilder<>(object, resolver).in(context);
}
@Override
public ResourcesBuilder bindAll(Class elementType, Collection objects) {
return new ResourcesBuilder(elementType, objects, resolver).in(context);
}
public GenericResourceBuilder bindGeneric() {
return new GenericResourceBuilder(resolver).in(context);
}
@Override
public NavigationResourceBuilder bindEntry() {
return new NavigationResourceBuilder(resolver).in(context);
}
}