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

org.weakref.jmx.guice.SetMapping Maven / Gradle / Ivy

There is a newer version: 1.26
Show newest version
package org.weakref.jmx.guice;

import com.google.common.reflect.TypeParameter;
import com.google.common.reflect.TypeToken;
import com.google.inject.Key;

import java.lang.reflect.Type;
import java.util.Set;

class SetMapping
{
    private final ObjectNameFunction objectNameFunction;
    private final Class clazz;

    SetMapping(Class key, ObjectNameFunction objectNameFunction)
    {
        this.clazz = key;
        this.objectNameFunction = objectNameFunction;
    }

    public ObjectNameFunction getObjectNameFunction()
    {
        return objectNameFunction;
    }

    public Key> getKey()
    {
        return (Key>) Key.get(setOf(clazz));
    }

    private static  Type setOf(Class clazz)
    {
        return new TypeToken>() {}.where(new TypeParameter() {}, TypeToken.of(clazz)).getType();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy