
com.cookingfox.chefling.impl.command.MapInstanceCommandImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chefling-di-java Show documentation
Show all versions of chefling-di-java Show documentation
Chefling is a very minimal dependency injection container written in pure Java.
package com.cookingfox.chefling.impl.command;
import com.cookingfox.chefling.api.command.MapInstanceCommand;
import com.cookingfox.chefling.api.exception.NotAnInstanceOfTypeException;
/**
* @see MapInstanceCommand
*/
public class MapInstanceCommandImpl extends AbstractCommand implements MapInstanceCommand {
//----------------------------------------------------------------------------------------------
// CONSTRUCTORS
//----------------------------------------------------------------------------------------------
public MapInstanceCommandImpl(CommandContainer container) {
super(container);
}
//----------------------------------------------------------------------------------------------
// PUBLIC METHODS
//----------------------------------------------------------------------------------------------
@Override
public void mapInstance(Class type, T instance) {
assertNonNull(type, "type");
assertNonNull(instance, "instance");
// validate the instance is an instance of type
if (!type.isInstance(instance)) {
throw new NotAnInstanceOfTypeException(type, instance);
}
addMapping(type, instance);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy