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

com.coditory.quark.context.ResolutionContext Maven / Gradle / Ivy

There is a newer version: 0.1.22
Show newest version
package com.coditory.quark.context;

import java.util.List;

import static com.coditory.quark.context.Args.checkNonNull;
import static com.coditory.quark.context.BeanDescriptor.descriptor;

public final class ResolutionContext {
    private final Context context;
    private final ResolutionPath path;

    ResolutionContext(
            Context context,
            ResolutionPath path
    ) {
        this.context = context;
        this.path = path;
    }

    public  T get(Class type) {
        checkNonNull(type, "type");
        return context.get(descriptor(type), path);
    }

    public  T getOrNull(Class type) {
        checkNonNull(type, "type");
        return context.getOrNull(descriptor(type), path);
    }

    public  T get(Class type, String name) {
        checkNonNull(type, "type");
        checkNonNull(name, "name");
        return context.get(descriptor(type, name), path);
    }

    public  T getOrNull(Class type, String name) {
        checkNonNull(type, "type");
        checkNonNull(name, "name");
        return context.getOrNull(descriptor(type, name), path);
    }

    public boolean contains(Class type) {
        checkNonNull(type, "type");
        return context.contains(type);
    }

    public boolean contains(String name) {
        checkNonNull(name, "name");
        return context.contains(name);
    }

    public boolean contains(Class type, String name) {
        checkNonNull(type, "type");
        checkNonNull(name, "name");
        return context.contains(type, name);
    }

    public  List getAll(Class type) {
        checkNonNull(type, "type");
        return context.getAll(type, path);
    }

    public  List getAllOrEmpty(Class type) {
        checkNonNull(type, "type");
        return context.getAllOrEmpty(type, path);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy