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

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

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

import com.google.inject.Binder;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
import com.google.inject.multibindings.Multibinder;

import static com.google.inject.multibindings.Multibinder.newSetBinder;

public class ExportBinder
{
    private final Multibinder binder;
    private final Multibinder> collectionBinder;
    private final Multibinder> mapBinder;

    ExportBinder(Multibinder binder, Multibinder> collectionBinder, Multibinder> mapBinder)
    {
        this.binder = binder;
        this.collectionBinder = collectionBinder;
        this.mapBinder = mapBinder;
    }

    public static ExportBinder newExporter(Binder binder)
    {
        Multibinder> collectionBinder = newSetBinder(binder, new TypeLiteral>() {});
        Multibinder> mapBinder = newSetBinder(binder, new TypeLiteral>() {});

        return new ExportBinder(newSetBinder(binder, Mapping.class), collectionBinder, mapBinder);
    }

    public AnnotatedExportBinder export(Class clazz)
    {
        return new AnnotatedExportBinder(binder, Key.get(clazz));
    }

    public NamedExportBinder export(Key key)
    {
        return new NamedExportBinder(binder, key);
    }

    public  SetExportBinder exportSet(Class clazz)
    {
        return new SetExportBinder(collectionBinder, clazz);
    }

    public  StringMapExportBinder exportMap(Class valueClass)
    {
        return new StringMapExportBinder(mapBinder, valueClass);
    }

    public  MapExportBinder exportMap(Class keyClass, Class valueClass)
    {
        return new MapExportBinder(mapBinder, keyClass, valueClass);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy