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

com.github.thorbenkuck.di.runtime.WireRepository Maven / Gradle / Ivy

The newest version!
package com.github.thorbenkuck.di.runtime;

import com.github.thorbenkuck.di.annotations.ManualWireCandidate;
import com.github.thorbenkuck.di.aspects.AspectRepository;
import com.github.thorbenkuck.di.domain.WireConflictResolver;
import com.github.thorbenkuck.di.domain.WireConflictStrategy;
import com.github.thorbenkuck.di.domain.provider.IdentifiableProvider;
import com.github.thorbenkuck.di.runtime.exceptions.DiInstantiationException;
import com.github.thorbenkuck.di.runtime.properties.TypedProperties;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.inject.Provider;
import java.util.List;
import java.util.Optional;

@ManualWireCandidate
public interface WireRepository {

	static WireRepository open() {
		WiredTypes wiredTypes = new WiredTypes();
		wiredTypes.load();

		return wiredTypes;
	}

	static WireRepository create() {
		return new WiredTypes();
	}

	boolean isLoaded();

	@NotNull
	TypedProperties properties();

	@NotNull
	AspectRepository aspectRepository();

	@NotNull
	WiredTypesConfiguration configuration();

	 void announce(@NotNull final T o);

	 void announce(@NotNull final IdentifiableProvider identifiableProvider);

	@Nullable  Optional tryGet(Class type);

	/**
	 * Returns the instance of the provided type.
	 * 

* If the relevant provider is not found, the provider produces null, * or the provided instance of the provider set for the type does * not match the expected type, a {@link DiInstantiationException} * will be thrown. *

* If multiple {@link IdentifiableProvider} instances are found for * the requested type, it will be resolved using the set * {@link WireConflictResolver}, which by default will be set according * to {@link WireConflictStrategy}. * * @param type The type class of instance you want to have created * @param The generic type, matching the provided type class * @return An instance according to the relevant, set {@link IdentifiableProvider} * @throws DiInstantiationException if no provider is found, the provider * returns null, the set {@link WireConflictResolver} * throws the Exception or the supplied type of the * provider does not match the expected type. */ @NotNull T get(Class type) throws DiInstantiationException; /** * * @param type * @param * @return */ List getAll(Class type); Provider getProvider(Class type); Timed load(); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy