//If this operator has been used before, retrieve it from the flyweights
if(operatorInstances.containsKey(operatorSignature)) {
return operatorInstances.get(operatorSignature);
} else {
//Otherwise, we have to create a new one from a template
Structure signature = Structure.parse(operatorSignature);
//If a template exists matching the supplied indicator
if(this.operatorTemplates.containsKey(signature.getPredicateIndicator().toString())) {
//We get the template
OperatorImpl template = (OperatorImpl) this.operatorTemplates.get(signature.getPredicateIndicator().toString());
//And start copying it
Structure templateSignature = new Structure(template);
Unifier un = new Unifier();
//The signature should unify with the template
if(!un.unifies(signature, templateSignature)) {
//This should not happen in a properly described domain
throw new OperatorFactoryException("Failed to unify "+templateSignature+" with operator "+templateSignature+" instantiating "+operatorSignature);
}
templateSignature.apply(un);
PropositionFactory propositionFactory = PropositionFactory.getInstance();
//Then get the preconditions in the template
List<Proposition> templatePreconds = template.getPreconds();
List<Proposition> concretePreconds = new ArrayList<Proposition>(templatePreconds.size());