All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.hal4j.resources.DefaultResourceFactory Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
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);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy