org.eclipse.sisu.space.WildcardKey Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (c) 2010-present 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:
* Stuart McCulloch (Sonatype, Inc.) - initial API and implementation
*******************************************************************************/
package org.eclipse.sisu.space;
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import javax.inject.Provider;
import javax.inject.Qualifier;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
/**
* Binding {@link Key} for implementations that act as "wild-cards", meaning they match against any assignable type.
*
* Since the wild-card type is {@link Object} and the associated qualifier may not be unique between implementations,
* the qualifier is saved and replaced with a unique (per-implementation) pseudo-qualifier. The original qualifier is
* available by casting the pseudo-qualifier to {@link Provider} and calling {@code get()}.
*/
final class WildcardKey
{
// ----------------------------------------------------------------------
// Constants
// ----------------------------------------------------------------------
private static final TypeLiteral