Instantiates the classToInstantiate with the given instanceName on the placeholder identified by placeholder on the specified instantiationTarget. By means of the boolean argument instantiateExtensions can be controlled, whether it is possible to instantiate objects on the contained extension points. If the delivered placeholder name is null and no fitting one can be determined, a NoMatchingPlaceholderException is thrown. If the classToInstantiate does not fit on the given placeholder, a PlaceholderNotMatchingException is thrown. If no placeholder name for the placeholder can be determined a PlaceholderNotExistingException is thrown.
instantiate(instantiationTarget, MechatronicObjectClass classToInstantiate, String instanceName, boolean instantiateExtensions, String placeholderName) throws PlaceholderNotMatchingException, PlaceholderNotExistingException, NoMatchingPlaceholderException | |||
---|---|---|---|
Argument | instantiationTarget | A mechatronic component or mechatronic root, under which the new object is placed | |
MechatronicObjectClass | classToInstantiate | The class to instantiate | |
String | instanceName | The name of the object. If null is returned, the object gets the name of the class. | |
Boolean | instantiateExtensions | If the return value is true, internal extension points are calculated while instantiation, if the return value is false no calculation is done. | |
String | placeholderName | Defines the placeholder where the instantiated object is placed. | |
Return value | Component | The instantiated object |
import com.mind8.mechatronic.skill.api.IMechatronicInstantiationAPI;
import com.mind8.mechatronic.skill.api. NoMatchingPlaceholderException;
import com.mind8.mechatronic.skill.api. PlaceholderNotMatchingException;
import com.mind8.mechatronic.skill.api. PlaceholderNotExistingException;
import com.mind8.mechatronic.skill.eos.TypeClass;
instantiationTarget = obj; // Argument in Command
classToInstantiate = TypeClass.findType(self.getUnitOfWork(),
"Pfuderer_Baukasten.Mechatronik.Stationen.Einsetzen.Einsetzen");
instance = null;
try
{
instance = IMechatronicInstantiationAPI.DEFAULT.instantiate(instantiationTarget, classToInstantiate, "Einsetzen", true, "Einfügeplatz");
}
catch (NoMatchingPlaceholderException nmpe)
{
// error handling
}
catch (PlaceholderNotMatchingException pnme)
{
// error handling
}
catch (PlaceholderNotExistingException pnee)
{
// error handling
}
return instance;
The instantiation methods with specified placeholder are also available in variants with reusable context.