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

io.github.amayaframework.di.RepositoryImpl Maven / Gradle / Ivy

Go to download

A framework responsible for monitoring and automating the dependency injection process.

There is a newer version: 2.2.0
Show newest version
package io.github.amayaframework.di;

import com.github.romanqed.jfunc.Function0;

import java.util.HashMap;
import java.util.Map;

final class RepositoryImpl implements Repository {
    private final Map> body;

    RepositoryImpl() {
        this.body = new HashMap<>();
    }

    @Override
    public Function0 get(Artifact artifact) {
        return body.get(artifact);
    }

    @Override
    public boolean contains(Artifact artifact) {
        return body.containsKey(artifact);
    }

    @Override
    public void add(Artifact artifact, Function0 supplier) {
        body.put(artifact, supplier);
    }

    @Override
    public boolean remove(Artifact artifact) {
        return body.remove(artifact) != null;
    }

    @Override
    public void clear() {
        body.clear();
    }
}