Search in sources :

Example 1 with IBinding

use of org.eclipse.e4.core.di.IBinding in project eclipse.platform.runtime by eclipse.

the class Binding method named.

@Override
public IBinding named(String name) {
    Binding binding = new Binding(this);
    binding.qualifierName = name;
    injector.addBinding(binding);
    return binding;
}
Also used : IBinding(org.eclipse.e4.core.di.IBinding)

Example 2 with IBinding

use of org.eclipse.e4.core.di.IBinding in project eclipse.platform.runtime by eclipse.

the class InjectorImpl method addBinding.

@Override
public IBinding addBinding(IBinding binding) {
    Binding internalBinding = (Binding) binding;
    Class<?> clazz = internalBinding.getDescribedClass();
    synchronized (bindings) {
        if (bindings.containsKey(clazz)) {
            Set<Binding> collection = bindings.get(clazz);
            String desiredQualifierName = internalBinding.getQualifierName();
            for (Iterator<Binding> i = collection.iterator(); i.hasNext(); ) {
                Binding collectionBinding = i.next();
                if (eq(collectionBinding.getQualifierName(), desiredQualifierName)) {
                    i.remove();
                    break;
                }
            }
            collection.add(internalBinding);
        } else {
            Set<Binding> collection = new HashSet<>(1);
            collection.add(internalBinding);
            bindings.put(clazz, collection);
        }
    }
    return binding;
}
Also used : IBinding(org.eclipse.e4.core.di.IBinding) HashSet(java.util.HashSet)

Example 3 with IBinding

use of org.eclipse.e4.core.di.IBinding in project eclipse.platform.runtime by eclipse.

the class Binding method implementedBy.

@Override
public IBinding implementedBy(Class<?> implClazz) {
    Binding binding = new Binding(this);
    binding.implementationClazz = implClazz;
    injector.addBinding(binding);
    return binding;
}
Also used : IBinding(org.eclipse.e4.core.di.IBinding)

Aggregations

IBinding (org.eclipse.e4.core.di.IBinding)3 HashSet (java.util.HashSet)1