Java Code Examples for java.util.Map.remove()

The following are Jave code examples for showing how to use remove() of the java.util.Map class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Tarski   File: AlloyModel.java   View Source Code Vote up 6 votes
/** Construct a new AlloyModel object.
 * @param types - the types; we will always add "univ" to it if it's not there already
 * @param sets - the sets
 * @param rels - the relations
 * @param map - we consult this "sig to parent sig" map and extract the mappings relevant to this model.
 * (If we detect a cycle, we will arbitrarily break the cycle)
 */
public AlloyModel(Collection<AlloyType> types
      , Collection<AlloySet> sets
      , Collection<AlloyRelation> rels
      , Map<AlloyType,AlloyType> map) {
   // The following 3 have to be tree sets, since we want to keep them sorted
   Set<AlloyType> allTypes = new TreeSet<AlloyType>();
   Set<AlloySet> allSets = new TreeSet<AlloySet>();
   Set<AlloyRelation> allRelations = new TreeSet<AlloyRelation>();
   allTypes.addAll(types);
   allTypes.add(AlloyType.UNIV);
   for(AlloySet s:sets) if (allTypes.contains(s.getType())) allSets.add(s);
   for(AlloyRelation r:rels) if (allTypes.containsAll(r.getTypes())) allRelations.add(r);
   this.types=Collections.unmodifiableSet(allTypes);
   this.sets=Collections.unmodifiableSet(allSets);
   this.relations=Collections.unmodifiableSet(allRelations);
   Map<AlloyType,AlloyType> newmap=new LinkedHashMap<AlloyType,AlloyType>();
   for(AlloyType type:allTypes) {
      AlloyType sup = isCycle(map,type) ? null : map.get(type);
      if (sup==null || !allTypes.contains(sup)) sup=AlloyType.UNIV;
      newmap.put(type,sup);
   }
   newmap.remove(AlloyType.UNIV); // This ensures univ is not in hierarchy's keySet
   this.hierarchy=Collections.unmodifiableMap(newmap);
   for(AlloyType t: this.types) this.name2types.put(t.getName(), t);
}
 
Example 2
Project: Elasticsearch   File: MovAvgModel.java   View Source Code Vote up 6 votes
/**
 * Extracts a 0-1 inclusive double from the settings map, otherwise throws an exception
 *
 * @param settings      Map of settings provided to this model
 * @param name          Name of parameter we are attempting to extract
 * @param defaultValue  Default value to be used if value does not exist in map
 * @return Double value extracted from settings map
 */
protected double parseDoubleParam(@Nullable Map<String, Object> settings, String name, double defaultValue) throws ParseException {
    if (settings == null) {
        return defaultValue;
    }

    Object value = settings.get(name);
    if (value == null) {
        return defaultValue;
    } else if (value instanceof Number) {
        double v = ((Number) value).doubleValue();
        if (v >= 0 && v <= 1) {
            settings.remove(name);
            return v;
        }

        throw new ParseException("Parameter [" + name + "] must be between 0-1 inclusive.  Provided"
                + "value was [" + v + "]", 0);
    }

    throw new ParseException("Parameter [" + name + "] must be a double, type `"
            + value.getClass().getSimpleName() + "` provided instead", 0);
}
 
Example 3
Project: alfresco-remote-api   File: CustomModelsImpl.java   View Source Code Vote up 5 votes
@Override
public void deleteCustomType(String modelName, String typeName)
{
    // Check the current user is authorised to delete the custom model's type
    validateCurrentUser();

    if(typeName == null)
    {
        throw new InvalidArgumentException(TYPE_NAME_NULL_ERR);
    }

    ModelDetails existingModelDetails = new ModelDetails(getCustomModelImpl(modelName));
    if(existingModelDetails.isActive())
    {
        throw new ConstraintViolatedException("cmm.rest_api.type_cannot_delete");
    }

    Map<String, CustomType> allTypes = transformToMap(existingModelDetails.getTypes(), toNameFunction());
    CustomType typeToBeDeleted = allTypes.get(typeName);

    if(typeToBeDeleted == null)
    {
        throw new EntityNotFoundException(typeName);
    }

    // Validate type's dependency
    validateTypeAspectDelete(allTypes.values(), typeToBeDeleted.getPrefixedName());

    // Remove the validated type
    allTypes.remove(typeName);
    existingModelDetails.setTypes(new ArrayList<>(allTypes.values()));

    updateModel(existingModelDetails, "cmm.rest_api.type_delete_failure");
}
 
Example 4
Project: alfresco-remote-api   File: BaseActivitySummaryProcessor.java   View Source Code Vote up 5 votes
public void process(Map<String, Object> entries)
{
	String value = (String)entries.remove(key);
	try
	{
		value = URLDecoder.decode(value, "UTF-8");
		Matcher matcher = pattern.matcher(value);
		if(matcher.matches())
		{
			String nodeRefStr = matcher.group(1);
			boolean isNodeRef = NodeRef.isNodeRef(nodeRefStr);
			if(isNodeRef)
			{
				NodeRef nodeRef = new NodeRef(nodeRefStr);
				entries.put("objectId", nodeRef.getId());
			}
			else
			{
				logger.warn("Activity page url contains an invalid NodeRef " + value);
			}
		}
		else
		{
			logger.warn("Failed to match activity page url for objectId extraction " + value);
		}
	}
	catch (UnsupportedEncodingException e)
	{
		logger.warn("Unable to decode activity page url " + value);
	}
}
 
Example 5
Project: monarch   File: AnalyzeSerializablesJUnitTest.java   View Source Code Vote up 5 votes
private static void removeExclusions(Map<String, CompiledClass> classes,
    List<String> exclusions) {
  for (String exclusion : exclusions) {
    exclusion = exclusion.replace('.', '/');
    classes.remove(exclusion);
  }
}
 
Example 6
Project: lemon   File: MemoryMessageHandler.java   View Source Code Vote up 5 votes
public void unregisterFromTopic(String topicName, String consumerName) {
    Map<String, List<Message>> consumerMap = topicMessages.get(topicName);

    if (consumerMap == null) {
        return;
    }

    if (consumerMap.containsKey(consumerName)) {
        consumerMap.remove(consumerMap);
    }
}
 
Example 7
Project: courgette-jvm   File: CourgetteRunnerInfo.java   View Source Code Vote up 5 votes
public Map<String, List<String>> getRuntimeOptions() {
    Map<String, List<String>> runtimeOptions = courgetteRuntimeOptions.mapRuntimeOptions();

    if (courgetteRunLevel.equals(CourgetteRunLevel.SCENARIO) && lineId != null) {
        final String featurePath = runtimeOptions.get(null).get(0);

        final List<String> scenarioPath = new ArrayList<>();
        scenarioPath.add(String.format("%s:%s", featurePath, lineId));
        runtimeOptions.put(null, scenarioPath);

        runtimeOptions.remove("--tags");
    }
    return runtimeOptions;
}
 
Example 8
Project: neoscada   File: ParserComponent.java   View Source Code Vote up 5 votes
private void disposeItem ( final Extractor extractor, final String localId )
{
    logger.debug ( "Dispose item: {}", localId );

    final Map<String, DataItemInputChained> cache = this.itemCache.get ( extractor );
    final DataItemInputChained item = cache.remove ( localId );
    if ( item == null )
    {
        logger.debug ( "Item not found" );
        return;
    }

    this.storage.removed ( new org.eclipse.scada.da.server.browser.common.query.ItemDescriptor ( item, null ) );
    this.itemFactory.disposeItem ( localId );
}
 
Example 9
Project: nuls   File: SessionManager.java   View Source Code Vote up 5 votes
public static void setConnection(String id, SqlSession session) {
    Map<String, SqlSession> map = sessionHolder.get();
    if (null == map) {
        map = new HashMap<>();
    }
    if (null == session) {
        map.remove(id);
    } else {
        map.put(id, session);
    }
    sessionHolder.remove();
    sessionHolder.set(map);
}
 
Example 10
Project: dubbox-hystrix   File: Overrides.java   View Source Code Vote up 5 votes
public void show(Long id, Map<String, Object> context) {
    Override override = overrideService.findById(id);
    
    Map<String, String> parameters = parseQueryString(override.getParams());

    if(parameters.get(DEFAULT_MOCK_JSON_KEY) != null) {
        String mock = URL.decode(parameters.get(DEFAULT_MOCK_JSON_KEY));
        String[] tokens = parseMock(mock);
        context.put(FORM_DEFAULT_MOCK_METHOD_FORCE, tokens[0]);
        context.put(FORM_DEFAULT_MOCK_METHOD_JSON, tokens[1]);
        parameters.remove(DEFAULT_MOCK_JSON_KEY);
    }
    
    Map<String, String> method2Force = new LinkedHashMap<String, String>();
    Map<String, String> method2Json = new LinkedHashMap<String, String>();
    
    for (Iterator<Map.Entry<String, String>> iterator = parameters.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, String> e =  iterator.next();
        String key = e.getKey();
        
        if(key.endsWith(MOCK_JSON_KEY_POSTFIX)) {
            String m = key.substring(0, key.length() - MOCK_JSON_KEY_POSTFIX.length());
            parseMock(m, e.getValue(), method2Force, method2Json);
            iterator.remove();
        }
    }
    
    context.put("methodForces", method2Force);
    context.put("methodJsons", method2Json);
    context.put("parameters", parameters);
    context.put("override", override);
}
 
Example 11
Project: forweaver2.0   File: GitInfo.java   View Source Code Vote up 5 votes
private Map<String, Set<String>> mergeIdentities(
		Collection<PersonIdent> persons) {
	Map<String, Set<String>> namesToEmails = new TreeMap<String, Set<String>>(
			caseInsensitveComparator);
	namesToEmails.putAll(RepositoryUtils.mapNamesToEmails(persons));
	Map<String, Set<String>> emailsToNames = RepositoryUtils
			.mapEmailsToNames(persons);
	for (Entry<String, Set<String>> entry : emailsToNames.entrySet())
		for (String name : entry.getValue())
			namesToEmails.get(name).add(entry.getKey());

	Object[] nameEntries = namesToEmails.entrySet().toArray();
	for (int i = 0; i < nameEntries.length; i++) {
		@SuppressWarnings("unchecked")
		Entry<String, Set<String>> curr = (Entry<String, Set<String>>) nameEntries[i];
		if (curr == null)
			continue;
		for (int j = 0; j < nameEntries.length; j++) {
			if (i == j)
				continue;
			for (String email : curr.getValue().toArray(
					new String[curr.getValue().size()])) {
				@SuppressWarnings("unchecked")
				Entry<String, Set<String>> other = (Entry<String, Set<String>>) nameEntries[j];
				if (other == null)
					continue;
				if (other.getValue().contains(email)) {
					curr.getValue().addAll(other.getValue());
					namesToEmails.remove(other.getKey());
					nameEntries[j] = null;
				}
			}
		}
	}
	return namesToEmails;
}
 
Example 12
Project: jsf-core   File: URL.java   View Source Code Vote up 5 votes
public URL removeParameters(String... keys) {
    if (keys == null || keys.length == 0) {
        return this;
    }
    Map<String, String> map = new HashMap<String, String>(getParameters());
    for (String key : keys) {
        map.remove(key);
    }
    if (map.size() == getParameters().size()) {
        return this;
    }
    return new URL(protocol, username, password, host, port, path, map);
}
 
Example 13
Project: unitimes   File: TeachingRequestsFilterBackend.java   View Source Code Vote up 5 votes
protected void addParameter(String option, String name, Object value) {
	Map<String, Object> params = iParams.get(option);
	if (params == null) { params = new HashMap<String, Object>(); iParams.put(option, params); }
	if (value == null)
		params.remove(name);
	else
		params.put(name, value);
}
 
Example 14
Project: Nird2   File: ConnectionRegistryImpl.java   View Source Code Vote up 5 votes
@Override
public void unregisterConnection(ContactId c, TransportId t,
		boolean incoming) {
	if (LOG.isLoggable(INFO)) {
		if (incoming) LOG.info("Incoming connection unregistered: " + t);
		else LOG.info("Outgoing connection unregistered: " + t);
	}
	boolean lastConnection = false;
	lock.lock();
	try {
		Map<ContactId, Integer> m = connections.get(t);
		if (m == null) throw new IllegalArgumentException();
		Integer count = m.remove(c);
		if (count == null) throw new IllegalArgumentException();
		if (count == 1) {
			if (m.isEmpty()) connections.remove(t);
		} else {
			m.put(c, count - 1);
		}
		count = contactCounts.get(c);
		if (count == null) throw new IllegalArgumentException();
		if (count == 1) {
			lastConnection = true;
			contactCounts.remove(c);
		} else {
			contactCounts.put(c, count - 1);
		}
	} finally {
		lock.unlock();
	}
	eventBus.broadcast(new ConnectionClosedEvent(c, t, incoming));
	if (lastConnection) {
		LOG.info("Contact disconnected");
		eventBus.broadcast(new ContactDisconnectedEvent(c));
	}
}
 
Example 15
Project: S2X   File: BGPVerifyUtilTest.java   View Source Code Vote up 4 votes
@Test
   public void checkTriplePatternGroup() {
TriplePattern tp11 = new TriplePattern("?a", "knows", "?b");
TriplePattern tp21 = new TriplePattern("?b", "knows", "?c");
TriplePattern tp31 = new TriplePattern("?a", "knows", "?c");
TriplePattern tp41 = new TriplePattern("?t", "knows", "X");
TriplePattern tp51 = new TriplePattern("?b", "?t", "Y");

List<TriplePattern> bgp = new ArrayList<TriplePattern>();
bgp.add(tp11);
bgp.add(tp21);
bgp.add(tp31);
bgp.add(tp41);
bgp.add(tp51);

Map<CompositeKey, List<ResultValue>> nodeResults = new HashMap<CompositeKey, List<ResultValue>>();
List<ResultValue> l1 = new ArrayList<>();
l1.add(new ResultValue("knows", "b"));
List<ResultValue> l2 = new ArrayList<>();
l2.add(new ResultValue("knows", "b2"));
nodeResults.put(new CompositeKey(tp31.getStringRepresentation(),
	Position.SUBJECT), l1);
nodeResults.put(new CompositeKey(tp11.getStringRepresentation(),
	Position.SUBJECT), l2);

// Correct result
assertEquals(true, BGPVerifyUtil.checkTriplePatternGroup(
	new CompositeKey(tp11.getStringRepresentation(),
		Position.SUBJECT), nodeResults, bgp));
assertEquals(true, BGPVerifyUtil.checkTriplePatternGroup(
	new CompositeKey(tp31.getStringRepresentation(),
		Position.SUBJECT), nodeResults, bgp));

// Result missing
assertEquals(false, BGPVerifyUtil.checkTriplePatternGroup(
	new CompositeKey(tp11.getStringRepresentation(),
		Position.OBJECT), nodeResults, bgp));

// Result empty
nodeResults.clear();
l1.clear();
l1.add(new ResultValue("likes", "Y"));
nodeResults.put(new CompositeKey(tp51.getStringRepresentation(),
	Position.PREDICATE), l1);
nodeResults.put(new CompositeKey(tp41.getStringRepresentation(),
	Position.SUBJECT), new ArrayList<ResultValue>());

assertEquals(false, BGPVerifyUtil.checkTriplePatternGroup(
	new CompositeKey(tp51.getStringRepresentation(),
		Position.PREDICATE), nodeResults, bgp));

// Result null
nodeResults.remove(new CompositeKey(tp41.getStringRepresentation(),
	Position.SUBJECT));
assertEquals(false, BGPVerifyUtil.checkTriplePatternGroup(
	new CompositeKey(tp51.getStringRepresentation(),
		Position.PREDICATE), nodeResults, bgp));
   }
 
Example 16
Project: jdk8u-jdk   File: BeanContextServicesSupport.java   View Source Code Vote up 4 votes
synchronized void releaseService(Object requestor, Object service) {
    if (serviceRequestors == null) return;

    Map services = (Map)serviceRequestors.get(requestor);

    if (services == null) return; // oops its not there anymore!

    BCSSCServiceRef serviceRef = (BCSSCServiceRef)services.get(service);

    if (serviceRef == null) return; // oops its not there anymore!

    BCSSCServiceClassRef serviceClassRef = serviceRef.getServiceClassRef();
    boolean                    isDelegated = serviceRef.isDelegated();
    BeanContextServiceProvider bcsp        = isDelegated ? serviceClassRef.getDelegateProvider() : serviceClassRef.getServiceProvider();

    bcsp.releaseService(BeanContextServicesSupport.this.getBeanContextServicesPeer(), requestor, service);

    serviceClassRef.releaseRef(isDelegated);
    serviceClassRef.removeRequestor(requestor);

    if (serviceRef.release() == 0) {

        services.remove(service);

        if (services.isEmpty()) {
            serviceRequestors.remove(requestor);
            serviceClassRef.removeRequestor(requestor);
        }

        if (serviceRequestors.isEmpty()) {
            serviceRequestors = null;
        }

        if (serviceClassRef.isEmpty()) {
            serviceClasses.remove(serviceClassRef.getServiceClass());
        }

        if (serviceClasses.isEmpty())
            serviceClasses = null;
    }
}
 
Example 17
Project: elasticsearch_my   File: TypeParsers.java   View Source Code Vote up 4 votes
public static boolean parseMultiField(FieldMapper.Builder builder, String name, Mapper.TypeParser.ParserContext parserContext,
                                      String propName, Object propNode) {
    parserContext = parserContext.createMultiFieldContext(parserContext);
    if (propName.equals("fields")) {

        final Map<String, Object> multiFieldsPropNodes;

        if (propNode instanceof List && ((List<?>) propNode).isEmpty()) {
            multiFieldsPropNodes = Collections.emptyMap();
        } else if (propNode instanceof Map) {
            multiFieldsPropNodes = (Map<String, Object>) propNode;
        } else {
            throw new MapperParsingException("expected map for property [fields] on field [" + propNode + "] or " +
                "[" + propName + "] but got a " + propNode.getClass());
        }

        for (Map.Entry<String, Object> multiFieldEntry : multiFieldsPropNodes.entrySet()) {
            String multiFieldName = multiFieldEntry.getKey();
            if (multiFieldName.contains(".")) {
                throw new MapperParsingException("Field name [" + multiFieldName + "] which is a multi field of [" + name + "] cannot" +
                    " contain '.'");
            }
            if (!(multiFieldEntry.getValue() instanceof Map)) {
                throw new MapperParsingException("illegal field [" + multiFieldName + "], only fields can be specified inside fields");
            }
            @SuppressWarnings("unchecked")
            Map<String, Object> multiFieldNodes = (Map<String, Object>) multiFieldEntry.getValue();

            String type;
            Object typeNode = multiFieldNodes.get("type");
            if (typeNode != null) {
                type = typeNode.toString();
            } else {
                throw new MapperParsingException("no type specified for property [" + multiFieldName + "]");
            }
            if (type.equals(ObjectMapper.CONTENT_TYPE) || type.equals(ObjectMapper.NESTED_CONTENT_TYPE)) {
                throw new MapperParsingException("Type [" + type + "] cannot be used in multi field");
            }

            Mapper.TypeParser typeParser = parserContext.typeParser(type);
            if (typeParser == null) {
                throw new MapperParsingException("no handler for type [" + type + "] declared on field [" + multiFieldName + "]");
            }
            builder.addMultiField(typeParser.parse(multiFieldName, multiFieldNodes, parserContext));
            multiFieldNodes.remove("type");
            DocumentMapperParser.checkNoRemainingFields(propName, multiFieldNodes, parserContext.indexVersionCreated());
        }
        return true;
    }
    return false;
}
 
Example 18
Project: iTAP-controller   File: OFSwitch.java   View Source Code Vote up 4 votes
/**
 * Handle a OFPortStatus message, update the internal data structures
 * that store ports and return the list of OFChangeEvents.
 *
 * This method will increment error/warn counters and log
 *
 * @param ps
 * @return
 */
@SuppressFBWarnings(value="SF_SWITCH_FALLTHROUGH")
public OrderedCollection<PortChangeEvent> handlePortStatusMessage(OFPortStatus ps) {
	if (ps == null) {
		throw new NullPointerException("OFPortStatus message must " +
				"not be null");
	}
	lock.writeLock().lock();
	try {
		OFPortDesc port = ps.getDesc();
		OFPortReason reason = ps.getReason();
		if (reason == null) {
			throw new IllegalArgumentException("Unknown PortStatus " +
					"reason code " + ps.getReason());
		}

		if (log.isDebugEnabled()) {
			log.debug("Handling OFPortStatus: {} for {}",
					reason, String.format("%s (%d)", port.getName(), port.getPortNo().getPortNumber()));
		}

		if (reason == OFPortReason.DELETE)
			return handlePortStatusDelete(port);

		// We handle ADD and MODIFY the same way. Since OpenFlow
		// doesn't specify what uniquely identifies a port the
		// notion of ADD vs. MODIFY can also be hazy. So we just
		// compare the new port to the existing ones.
		Map<OFPort,OFPortDesc> newPortByNumber =
				new HashMap<OFPort, OFPortDesc>(portsByNumber);
		OrderedCollection<PortChangeEvent> events = getSinglePortChanges(port);
		for (PortChangeEvent e: events) {
			switch(e.type) {
			case DELETE:
				newPortByNumber.remove(e.port.getPortNo());
				break;
			case ADD:
				if (reason != OFPortReason.ADD) {
					// weird case
				}
				// fall through
			case DOWN:
			case OTHER_UPDATE:
			case UP:
				// update or add the port in the map
				newPortByNumber.put(e.port.getPortNo(), e.port);
				break;
			}
		}
		updatePortsWithNewPortsByNumber(newPortByNumber);
		return events;
	} finally {
		lock.writeLock().unlock();
	}

}
 
Example 19
Project: ProyectoPacientes   File: ConnectionRegressionTest.java   View Source Code Vote up 4 votes
/**
 * Tests if the driver configures character sets correctly for 4.1.x
 * servers. Requires that the 'admin connection' is configured, as this test
 * needs to create/drop databases.
 * 
 * @throws Exception
 *             if an error occurs
 */
public void testCollation41() throws Exception {
    if (versionMeetsMinimum(4, 1) && isAdminConnectionConfigured()) {
        Map<String, String> charsetsAndCollations = getCharacterSetsAndCollations();
        charsetsAndCollations.remove("latin7"); // Maps to multiple Java
        // charsets
        charsetsAndCollations.remove("ucs2"); // can't be used as a
        // connection charset

        for (String charsetName : charsetsAndCollations.keySet()) {
            Connection charsetConn = null;
            Statement charsetStmt = null;

            try {
                //String collationName = charsetsAndCollations.get(charsetName);

                Properties props = new Properties();
                props.put("characterEncoding", charsetName);

                System.out.println("Testing character set " + charsetName);

                charsetConn = getAdminConnectionWithProps(props);

                charsetStmt = charsetConn.createStatement();

                charsetStmt.executeUpdate("DROP DATABASE IF EXISTS testCollation41");
                charsetStmt.executeUpdate("DROP TABLE IF EXISTS testCollation41");

                charsetStmt.executeUpdate("CREATE DATABASE testCollation41 DEFAULT CHARACTER SET " + charsetName);
                charsetConn.setCatalog("testCollation41");

                // We've switched catalogs, so we need to recreate the
                // statement to pick this up...
                charsetStmt = charsetConn.createStatement();

                StringBuilder createTableCommand = new StringBuilder("CREATE TABLE testCollation41(field1 VARCHAR(255), field2 INT)");

                charsetStmt.executeUpdate(createTableCommand.toString());

                charsetStmt.executeUpdate("INSERT INTO testCollation41 VALUES ('abc', 0)");

                int updateCount = charsetStmt.executeUpdate("UPDATE testCollation41 SET field2=1 WHERE field1='abc'");
                assertTrue(updateCount == 1);
            } finally {
                if (charsetStmt != null) {
                    charsetStmt.executeUpdate("DROP TABLE IF EXISTS testCollation41");
                    charsetStmt.executeUpdate("DROP DATABASE IF EXISTS testCollation41");
                    charsetStmt.close();
                }

                if (charsetConn != null) {
                    charsetConn.close();
                }
            }
        }
    }
}
 
Example 20
Project: JavaGraph   File: STS.java   View Source Code Vote up 4 votes
/**
 * Creates the update from a rule event.
 * @param event The rule event.
 * @param iVarMap A map of variable nodes to interaction variables.
 * @param lVarMap A map of variable nodes to location variables.
 * @return The created update.
 * @throws STSException Inconsistencies in the model are reported by throwing an STSException.
 */
private String createUpdate(RuleEvent event, Map<VariableNode,InteractionVariable> iVarMap,
    Map<VariableNode,LocationVariable> lVarMap) throws STSException {
    Rule rule = event.getRule();
    QualName name = rule.getQualName();
    Condition nac = rule.getCondition();

    String update = "";
    // first find the location variables undergoing an update, by finding
    // eraser edges to these variables
    Map<Pair<RuleNode,RuleLabel>,RuleEdge> possibleUpdates =
        new HashMap<>();
    for (RuleEdge e : rule.getEraserEdges()) {
        if (e.target()
            .getType()
            .isDataType() && !isFinal(rule.lhs(), e.source())) {
            possibleUpdates.put(new Pair<>(e.source(), e.label()), e);
        }
    }

    for (RuleEdge creatorEdge : rule.getCreatorEdges()) {
        if (creatorEdge.target()
            .getType()
            .isDataType() && !isFinal(rule.lhs(), creatorEdge.source())) {
            // A creator edge has been detected to a data node,
            // this indicates an update for a location variable.
            RuleEdge eraserEdge = possibleUpdates.remove(
                new Pair<>(creatorEdge.source(), creatorEdge.label()));
            if (eraserEdge == null) {
                // Modeling constraint, updates have to be done in
                // eraser/creator pairs.
                throw new STSException(
                    "ERROR: no eraser edge found for created location variable " + creatorEdge
                        + "; location variables have to be declared in start location and reference must be deleted");
            }
            Variable var = lVarMap.get(eraserEdge.target());
            if (var == null) {
                // Data nodes should always be a location variable.
                throw new STSException(
                    "ERROR: no location variable found referenced by " + eraserEdge.target()
                        .toString() + " in the LHS or Condition of rule " + name);
            }
            RuleNode node = creatorEdge.target();
            // Parse the resulting value. This can be a variable or an
            // expression over variables and primitive data types.
            String updateValue = this.ruleInspector.parseExpression(rule,
                nac.getPattern(),
                node,
                iVarMap,
                lVarMap);
            if (updateValue.length() == 0) {
                // Update can't be empty. This should never happen.
                throw new STSException("ERROR: Update of " + var.toString() + " in rule "
                    + rule.getQualName() + " is empty where it shouldn't be.");
            }
            update += var.getLabel() + " = " + updateValue + "; ";
        }
    }

    if (!possibleUpdates.isEmpty()) {
        throw new STSException(
            "ERROR: eraser edge found without creator: " + possibleUpdates.values()
                .iterator()
                .next());
    }
    return update;
}