<commit_before>/*******************************************************************************
 * Copyright (c) 2010, 2013 Sonatype, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    <NAME> (Sonatype, Inc.) - initial API and implementation
 *******************************************************************************/
package org.sonatype.guice.bean.locators;

import java.lang.annotation.Annotation;

import javax.inject.Inject;
import javax.inject.Singleton;

import org.eclipse.sisu.inject.BindingPublisher;
import org.eclipse.sisu.inject.InjectorPublisher;
import org.eclipse.sisu.inject.Legacy;
import org.sonatype.inject.BeanEntry;
import org.sonatype.inject.Mediator;

import com.google.inject.Injector;
import com.google.inject.Key;

@Deprecated
@Singleton
public final class DefaultBeanLocator
    implements MutableBeanLocator
{
    private final org.eclipse.sisu.inject.MutableBeanLocator delegate;

    private final boolean decoupledDelegate;

    @Inject
    public DefaultBeanLocator( final org.eclipse.sisu.inject.MutableBeanLocator delegate )
    {
        this.delegate = delegate;
        decoupledDelegate = false;
    }

    public DefaultBeanLocator()
    {
        delegate = new org.eclipse.sisu.inject.DefaultBeanLocator();
        decoupledDelegate = true;
    }

    public <Q extends Annotation, T> Iterable<BeanEntry<Q, T>> locate( final Key<T> key )
    {
        return Legacy.adapt( delegate.<Q, T> locate( key ) );
    }

    public <Q extends Annotation, T, W> void watch( final Key<T> key, final Mediator<Q, T, W> mediator, final W watcher )
    {
        delegate.watch( key, Legacy.adapt( mediator ), watcher );
    }

    public <Q extends Annotation, T, W> void watch( final Key<T> key,
                                                    final org.eclipse.sisu.Mediator<Q, T, W> mediator, final W watcher )
    {
        delegate.watch( key, mediator, watcher );
    }

    public void add( final Injector injector, final int rank )
    {
        delegate.add( injector, rank );
    }

    public void remove( final Injector injector )
    {
        delegate.remove( injector );
    }

    public void clear()
    {
        delegate.clear();
    }

    public boolean add( final BindingPublisher publisher, final int rank )
    {
        return delegate.add( publisher, rank );
    }

    public boolean remove( final BindingPublisher publisher )
    {
        return delegate.remove( publisher );
    }

    public Iterable<BindingPublisher> publishers()
    {
        return delegate.publishers();
    }

    @Inject
    void autoPublish( final Injector injector )
    {
        if ( decoupledDelegate )
        {
            final RankingFunction function = injector.getInstance( RankingFunction.class );
            delegate.add( new InjectorPublisher( injector, function ), function.maxRank() );
        }
    }
}
<commit_msg>Update wrt. simplified MutableBeanLocator API<commit_after>/*******************************************************************************
 * Copyright (c) 2010, 2013 Sonatype, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    <NAME> (Sonatype, Inc.) - initial API and implementation
 *******************************************************************************/
package org.sonatype.guice.bean.locators;

import java.lang.annotation.Annotation;

import javax.inject.Inject;
import javax.inject.Singleton;

import org.eclipse.sisu.inject.BindingPublisher;
import org.eclipse.sisu.inject.InjectorPublisher;
import org.eclipse.sisu.inject.Legacy;
import org.sonatype.inject.BeanEntry;
import org.sonatype.inject.Mediator;

import com.google.inject.Injector;
import com.google.inject.Key;

@Deprecated
@Singleton
public final class DefaultBeanLocator
    implements MutableBeanLocator
{
    private final org.eclipse.sisu.inject.MutableBeanLocator delegate;

    private final boolean decoupledDelegate;

    @Inject
    public DefaultBeanLocator( final org.eclipse.sisu.inject.MutableBeanLocator delegate )
    {
        this.delegate = delegate;
        decoupledDelegate = false;
    }

    public DefaultBeanLocator()
    {
        delegate = new org.eclipse.sisu.inject.DefaultBeanLocator();
        decoupledDelegate = true;
    }

    public <Q extends Annotation, T> Iterable<BeanEntry<Q, T>> locate( final Key<T> key )
    {
        return Legacy.adapt( delegate.<Q, T> locate( key ) );
    }

    public <Q extends Annotation, T, W> void watch( final Key<T> key, final Mediator<Q, T, W> mediator, final W watcher )
    {
        delegate.watch( key, Legacy.adapt( mediator ), watcher );
    }

    public <Q extends Annotation, T, W> void watch( final Key<T> key,
                                                    final org.eclipse.sisu.Mediator<Q, T, W> mediator, final W watcher )
    {
        delegate.watch( key, mediator, watcher );
    }

    public void add( final Injector injector, final int rank )
    {
        delegate.add( injector, rank );
    }

    public void remove( final Injector injector )
    {
        delegate.remove( injector );
    }

    public void clear()
    {
        delegate.clear();
    }

    public boolean add( final BindingPublisher publisher )
    {
        return delegate.add( publisher );
    }

    public boolean remove( final BindingPublisher publisher )
    {
        return delegate.remove( publisher );
    }

    public Iterable<BindingPublisher> publishers()
    {
        return delegate.publishers();
    }

    @Inject
    void autoPublish( final Injector injector )
    {
        if ( decoupledDelegate )
        {
            final RankingFunction function = injector.getInstance( RankingFunction.class );
            delegate.add( new InjectorPublisher( injector, function ) );
        }
    }
}

{'fraction_non_alphanumeric': 0.1392834086507424, 'fraction_numerical': 0.003873466752743706, 'mean_word_length': 2.977535301668806, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4159783', 'n_tokens_mistral': 1773, 'n_tokens_neox': 1656, 'n_words': 467}