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

com.github.peterbecker.configuration.parser.ConfigurationInvocationHandler Maven / Gradle / Ivy

There is a newer version: 1.1
Show newest version
package com.github.peterbecker.configuration.parser;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;

/**
 * Binds calls to the configuration interface to the data extracted.
 */
public class ConfigurationInvocationHandler implements InvocationHandler {
    private final Class configurationInterface;
    private final Map data;

    public ConfigurationInvocationHandler(Class configurationInterface, Map data) {
        this.configurationInterface = configurationInterface;
        this.data = data;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        assert configurationInterface.isAssignableFrom(proxy.getClass());
        assert args == null;

        return data.get(method.getName());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy