Java Code Examples for java.util.Map#clear()

The following examples show how to use java.util.Map#clear() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigMission.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static void loadConfig(FileConfiguration cfg, Map<String, ConfigMission> missions){
	missions.clear();
	List<Map<?, ?>> configMissions = cfg.getMapList("missions");
	for (Map<?, ?> b : configMissions) {
		ConfigMission mission = new ConfigMission();
		mission.id = (String)b.get("id");
		mission.name = (String)b.get("name");
		mission.cost = (Double)b.get("cost");
		mission.range = (Double)b.get("range");
		mission.cooldown = (Double)b.get("cooldown");
		mission.intel = (Integer)b.get("intel");
		mission.length = (Integer)b.get("length");
		mission.fail_chance = (Double)b.get("fail_chance");
		mission.compromise_chance = (Double)b.get("compromise_chance");
		mission.slot = (Integer)b.get("slot");
		mission.description = (List<String>) b.get("description");
		
		missions.put(mission.id.toLowerCase(), mission);
	}
	
	CivLog.info("Loaded "+missions.size()+" Espionage Missions.");
}
 
Example 2
Source File: TestDefinitionsAreValid.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
@Test
public void testServiceDefinitionsAreUnique() {
   Map<String, String> nameToFile = new HashMap<String, String>();
   Map<String, String> namespaceToFile = new HashMap<String, String>();
   Map<String, String> errors = new HashMap<String, String>();
   validateUnique(new File(COMMON_PATH + "/service"), nameToFile, namespaceToFile, errors);
   if(!errors.isEmpty()) {
      fail("Invalid XML files: " + errors);
   }

   nameToFile.clear();
   namespaceToFile.clear();
   errors.clear();
   validateUnique(new File(INTERNAL_PATH + "/service"), nameToFile, namespaceToFile, errors);
   if(!errors.isEmpty()) {
      fail("Invalid XML files: " + errors);
   }
}
 
Example 3
Source File: ClientSendFile.java    From p4ic4idea with Apache License 2.0 6 votes vote down vote up
private long sendStream(InputStream stream, RpcConnection connection, String handle, String write,
		MD5Digester digester, CommandEnv cmdEnv) throws ConnectionException, IOException {
	long fileLength = 0;
	
	Map<String, Object> sendMap = new HashMap<String, Object>();
	byte[] bytes = new byte[1024 * 64];
	int bytesRead;
	while ((bytesRead = stream.read(bytes)) > 0) {
		byte[] readBytes = new byte[bytesRead];
		
		System.arraycopy(bytes, 0, readBytes, 0, bytesRead);
		fileLength += bytesRead;
		sendMap.clear();
		sendMap.put(RpcFunctionMapKey.DATA, readBytes);
		sendMap.put(RpcFunctionMapKey.HANDLE, handle);

		RpcPacket sendPacket = RpcPacket.constructRpcPacket(write,
				sendMap, null);
		
		connection.putRpcPacket(sendPacket);
		digester.update(readBytes);

		currentSize = sendBackWrittenDataBytes(cmdEnv, filePath, fileSize, currentSize, bytesRead);
	}
	return fileLength;
}
 
Example 4
Source File: ParamsExtractorTests.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Params testExtractOperationParams(Map<String, String> templateVars, WebScriptRequest request, ParamsExtractor extractor)
{
    templateVars.clear();
    templateVars.put(ResourceLocator.ENTITY_ID, "1234");
    templateVars.put(ResourceLocator.RELATIONSHIP_RESOURCE, "codfish");
    Params params = extractor.extractParams(mockOperation(), request);
    assertNotNull(params);
    assertNull("For a Collection there should be no relationshipId params.",params.getRelationshipId());

    templateVars.put(ResourceLocator.RELATIONSHIP_ID, "9865");
    templateVars.put(ResourceLocator.PROPERTY, "monkFish");
    params = extractor.extractParams(mockOperation(), request);
    assertNotNull(params);
    assertEquals("1234", params.getEntityId());
    assertEquals("9865", params.getRelationshipId());
    return params;
}
 
Example 5
Source File: VariadicCommandsTest.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
@Test
public void zadd() {
  Map<String, Double> scoreMembers = new HashMap<String, Double>();
  scoreMembers.put("bar", 1d);
  scoreMembers.put("foo", 10d);

  long status = jedis.zadd("foo", scoreMembers);
  assertEquals(2, status);

  scoreMembers.clear();
  scoreMembers.put("car", 0.1d);
  scoreMembers.put("bar", 2d);

  status = jedis.zadd("foo", scoreMembers);
  assertEquals(1, status);

  Map<byte[], Double> bscoreMembers = new HashMap<byte[], Double>();
  bscoreMembers.put(bbar, 1d);
  bscoreMembers.put(bfoo, 10d);

  status = jedis.zadd(bfoo, bscoreMembers);
  assertEquals(2, status);

  bscoreMembers.clear();
  bscoreMembers.put(bcar, 0.1d);
  bscoreMembers.put(bbar, 2d);

  status = jedis.zadd(bfoo, bscoreMembers);
  assertEquals(1, status);

}
 
Example 6
Source File: SourceServiceImpl.java    From singleton with Eclipse Public License 2.0 5 votes vote down vote up
private boolean catcheMapDTO(Map<String, ComponentSourceDTO> sources) throws L10nAPIException{
	     LOGGER.debug("begin process catcheMapDTO collection string to tem cache queue");

	        try {
				DiskQueueUtils.createQueueFile(sources, basePath);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				LOGGER.error(e.getMessage(), e);
				return false;
			}
		    sources.clear();
		
		return true;
}
 
Example 7
Source File: TestWorkspaceManager.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Converts from pairs to a corresponding map. This method has two return values:
 * <ol>
 * <li>the resulting map, which is returned by changing the given argument <code>addHere</code>, and
 * <li>iff a module in the given pairs is marked as selected module (see {@link #MODULE_SELECTOR}), then this method
 * returns a pair "selected project path" -&gt; "selected module"; otherwise it returns <code>null</code>.
 * </ol>
 */
/* package */ static Pair<String, String> convertProjectsModulesContentsToMap(
		Iterable<Pair<String, List<Pair<String, String>>>> projectsModulesContentsAsPairs,
		Map<String, Map<String, String>> addHere,
		boolean requireSelectedModule) {

	String selectedProjectPath = null;
	String selectedModule = null;
	addHere.clear();
	for (Pair<String, ? extends Iterable<Pair<String, String>>> project : projectsModulesContentsAsPairs) {
		String projectPath = project.getKey();
		Iterable<? extends Pair<String, String>> modules = project.getValue();
		Map<String, String> modulesMap = null;
		if (modules != null) {
			modulesMap = new HashMap<>();
			for (Pair<String, String> moduleContent : modules) {
				String moduleName = moduleContent.getKey();
				if (moduleName.endsWith(MODULE_SELECTOR)) {
					moduleName = moduleName.substring(0, moduleName.length() - 1);
					selectedProjectPath = projectPath;
					selectedModule = moduleName;
				}
				modulesMap.put(moduleName, moduleContent.getValue());
			}
		}
		addHere.put(projectPath, modulesMap);
	}

	if (requireSelectedModule && selectedModule == null) {
		throw new IllegalArgumentException(
				"No module selected. Fix by appending '" + MODULE_SELECTOR + "' to one of the project modules.");
	}

	return selectedModule != null ? Pair.of(selectedProjectPath, selectedModule) : null;
}
 
Example 8
Source File: MaxPoints.java    From LeetCode-Sol-Res with MIT License 5 votes vote down vote up
/**
 * Set a point and go through the rest
 * Use max to record the max points of current loop
 * Use countSame to track the number of points
 * Use result to track the max points
 * Use a map to store lines, key is the feature of the line, value is the
 * number of points
 *
 * @param points points generated, can be same
 * @return number of max points share a same line
 */
private static int maxPoints(Point[] points) {
    if (points.length < 3) return points.length; // 0/1/2 points
    int res = 1; // at least 1 point
    Map<String, Integer> map = new HashMap<String, Integer>(); // line,count
    for (int i = 0; i < points.length; i++) {
        int max = 0;
        int countSame = 0; // # of same points
        for (int j = i + 1; j < points.length; j++) {
            if (points[i].x == points[j].x && points[i].y == points[j].y ) countSame++; // same point
            else {
                String key = normalize(points[i], points[j]); // a|b|c
                if (map.containsKey(key)) { // on the line
                    int count = map.get(key) + 1;
                    map.put(key, count); // update count
                    if (count > max) max = count; // update max
                } else { // not on any line
                    map.put(key, 1);
                    if (max == 0) max++; // update max
                }
            }
        }
        res = Math.max(res, max + countSame + 1); // +1 for the start point
        map.clear(); // clear map for next point
    }
    return res;
}
 
Example 9
Source File: LoggerUtil.java    From BigDataArchitect with Apache License 2.0 5 votes vote down vote up
/**
 * 处理日志数据logText,返回处理结果map集合<br/>
 * 如果logText没有指定数据格式,那么直接返回empty的集合
 * 
 * @param logText
 * @return
 */
public static Map<String, String> handleLog(String logText) {
    Map<String, String> clientInfo = new HashMap<String, String>();
    if (StringUtils.isNotBlank(logText)) {
        String[] splits = logText.trim().split(EventLogConstants.LOG_SEPARTIOR);
        if (splits.length == 4) {
            // 日志格式为: ip^A服务器时间^Ahost^A请求参数
            clientInfo.put(EventLogConstants.LOG_COLUMN_NAME_IP, splits[0].trim()); // 设置ip
            // 设置服务器时间
            clientInfo.put(EventLogConstants.LOG_COLUMN_NAME_SERVER_TIME, String.valueOf(TimeUtil.parseNginxServerTime2Long(splits[1].trim())));
            int index = splits[3].indexOf("?");
            if (index > -1) {
                String requestBody = splits[3].substring(index + 1); // 获取请求参数,也就是我们的收集数据
                // 处理请求参数
                handleRequestBody(requestBody, clientInfo);
                // 处理userAgent
                handleUserAgent(clientInfo);
                // 处理ip地址
                handleIp(clientInfo);
            } else {
                // 数据格式异常
                clientInfo.clear();
            }
        }
    }
    return clientInfo;
}
 
Example 10
Source File: PathTemplateMatcher.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
private PathMatchResult<T> handleStemMatch(Set<PathTemplateHolder> entry, final String path, final Map<String, String> params) {
    for (PathTemplateHolder val : entry) {
        if (val.template.matches(path, params)) {
            return new PathMatchResult<>(params, val.template.getTemplateString(), val.value);
        } else {
            params.clear();
        }
    }
    return null;
}
 
Example 11
Source File: TestType.java    From oopsla15-artifact with Eclipse Public License 1.0 4 votes vote down vote up
public void testMatchAndInstantiate() {
	Type X = ft.parameterType("X");
	Map<Type, Type> bindings = new HashMap<>();

	Type subject = ft.integerType();
	X.match(subject, bindings);

	if (!bindings.get(X).equals(subject)) {
		fail("simple match failed");
	}

	if (!X.instantiate(bindings).equals(subject)) {
		fail("instantiate failed");
	}

	Type relXX = ft.relType(X, X);
	bindings.clear();
	subject = ft.relType(ft.integerType(), ft.integerType());
	relXX.match(subject, bindings);

	if (!bindings.get(X).equals(ft.integerType())) {
		fail("relation match failed");
	}

	if (!relXX.instantiate(bindings).equals(subject)) {
		fail("instantiate failed");
	}

	bindings.clear();
	subject = ft.relType(ft.integerType(), ft.realType());
	relXX.match(subject, bindings);

	Type lub = ft.integerType().lub(ft.realType());
	if (!bindings.get(X).equals(lub)) {
		fail("lubbing during matching failed");
	}

	if (!relXX.instantiate(bindings).equals(ft.relType(lub, lub))) {
		fail("instantiate failed");
	}

}
 
Example 12
Source File: FmrcDataset.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void closeAll(Map<String, NetcdfDataset> openFiles) throws IOException {
  for (NetcdfDataset ncfile : openFiles.values())
    ncfile.close();
  openFiles.clear();
}
 
Example 13
Source File: Solution2.java    From LeetCode-Solution-in-Good-Style with Apache License 2.0 4 votes vote down vote up
public boolean isCousins(TreeNode root, int x, int y) {
    if (root == null) {
        return false;
    }

    Queue<TreeNode> queue = new LinkedList<>();
    queue.add(root);
    // key:当前层结点值,value:当前层结点输出的下标
    // 这个 currentLevel 每次使用完都得清空
    Map<Integer, Integer> currentLevel = new HashMap<>();

    while (!queue.isEmpty()) {
        int size = queue.size();
        for (int i = 0; i < size; i++) {
            TreeNode head = queue.poll();
            if (head != null) {
                currentLevel.put(head.val, i);
                queue.add(head.left);
                queue.add(head.right);
            }
        }

        if (currentLevel.containsKey(x) && currentLevel.containsKey(y)) {
            int index1 = currentLevel.get(x);
            int index2 = currentLevel.get(y);

            if (index1 > index2) {
                int temp = index1;
                index1 = index2;
                index2 = temp;
            }

            if (index1 + 1 == index2 && (index1 % 2) == 0) {
                return false;
            }
            return true;
        }

        if (currentLevel.containsKey(x) || currentLevel.containsKey(y)) {
            return false;
        }

        currentLevel.clear();
    }
    return false;
}
 
Example 14
Source File: FileAttributesTest.java    From p4ic4idea with Apache License 2.0 4 votes vote down vote up
@Test
public void testFileAttributesRetrieval() {
	final String filePath = "//depot/102Dev/Attributes";
	final String fileName = filePath + "/" + "test01.txt";
	final String attr1Name = "test1";
	final String attr1Value = "Test1Value";
	final String attr1HexValue = "546573743156616C7565";
	final String attr2Name = "test2";
	final byte[] attr2Value = {-85, -51, -17}; 	// FIXME: byte order -- HR.
	final String attr2HexValue = "ABCDEF";
	IOptionsServer server = null;
	IClient client = null;

	try {
		server = getServer();
		client = getDefaultClient(server);
		assertNotNull(client);
		server.setCurrentClient(client);
		List<IFileSpec> syncFiles = this.forceSyncFiles(client, filePath + "/...");
		assertTrue(syncFiles.size() > 0);
		assertEquals(syncFiles.get(0).getStatusMessage(), 0, FileSpecBuilder.getInvalidFileSpecs(syncFiles).size());
		FileStatAncilliaryOptions fsaOpts = new FileStatAncilliaryOptions();
		fsaOpts.setShowAttributes(true);
		GetExtendedFilesOptions gefOpts = new GetExtendedFilesOptions();
		gefOpts.setAncilliaryOptions(fsaOpts);
		List<IExtendedFileSpec> fileSpecs = server.getExtendedFiles(
												FileSpecBuilder.makeFileSpecList(fileName),
												gefOpts);
		assertNotNull(fileSpecs);
		assertEquals(1, fileSpecs.size());
		IExtendedFileSpec fSpec = fileSpecs.get(0);
		Map<String,byte[]> expectedAttributes = new HashMap<String, byte[]>();
		expectedAttributes.put(attr1Name, attr1Value.getBytes());
		expectedAttributes.put(attr2Name, attr2Value);
		checkAttributes(fSpec, expectedAttributes, false);

		fsaOpts.setShowHexAttributes(true);
		fileSpecs = server.getExtendedFiles(
											FileSpecBuilder.makeFileSpecList(fileName),
											gefOpts);
		assertNotNull(fileSpecs);
		assertEquals(1, fileSpecs.size());
		expectedAttributes.clear();
		checkAttributes(fileSpecs.get(0), expectedAttributes, false);
		expectedAttributes.put(attr1Name, attr1HexValue.getBytes());
		expectedAttributes.put(attr2Name, attr2HexValue.getBytes());
	} catch (Exception exc) {
		fail("Unexpected exception: " + exc.getLocalizedMessage());
	} finally {
		if (server != null) {
			this.endServerSession(server);
		}
	}
}
 
Example 15
Source File: ConcurrentMapTest.java    From concurrentlinkedhashmap with Apache License 2.0 4 votes vote down vote up
@Test(dataProvider = "warmedMap")
public void clear_whenPopulated(Map<Integer, Integer> map) {
  map.clear();
  assertThat(map, is(emptyMap()));
}
 
Example 16
Source File: TestPerTableCFReplication.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Test
public void testTableCFsHelperConverter() {

  ReplicationProtos.TableCF[] tableCFs = null;
  Map<TableName, List<String>> tabCFsMap = null;

  // 1. null or empty string, result should be null
  assertNull(ReplicationPeerConfigUtil.convert(tabCFsMap));

  tabCFsMap = new HashMap<>();
  tableCFs = ReplicationPeerConfigUtil.convert(tabCFsMap);
  assertEquals(0, tableCFs.length);

  final TableName tableName1 = TableName.valueOf(name.getMethodName() + "1");
  final TableName tableName2 = TableName.valueOf(name.getMethodName() + "2");
  final TableName tableName3 = TableName.valueOf(name.getMethodName() + "3");

  // 2. single table: "tab1" / "tab2:cf1" / "tab3:cf1,cf3"
  tabCFsMap.clear();
  tabCFsMap.put(tableName1, null);
  tableCFs = ReplicationPeerConfigUtil.convert(tabCFsMap);
  assertEquals(1, tableCFs.length); // only one table
  assertEquals(tableName1.toString(),
      tableCFs[0].getTableName().getQualifier().toStringUtf8());
  assertEquals(0, tableCFs[0].getFamiliesCount());

  tabCFsMap.clear();
  tabCFsMap.put(tableName2, new ArrayList<>());
  tabCFsMap.get(tableName2).add("cf1");
  tableCFs = ReplicationPeerConfigUtil.convert(tabCFsMap);
  assertEquals(1, tableCFs.length); // only one table
  assertEquals(tableName2.toString(),
      tableCFs[0].getTableName().getQualifier().toStringUtf8());
  assertEquals(1, tableCFs[0].getFamiliesCount());
  assertEquals("cf1", tableCFs[0].getFamilies(0).toStringUtf8());

  tabCFsMap.clear();
  tabCFsMap.put(tableName3, new ArrayList<>());
  tabCFsMap.get(tableName3).add("cf1");
  tabCFsMap.get(tableName3).add("cf3");
  tableCFs = ReplicationPeerConfigUtil.convert(tabCFsMap);
  assertEquals(1, tableCFs.length);
  assertEquals(tableName3.toString(),
      tableCFs[0].getTableName().getQualifier().toStringUtf8());
  assertEquals(2, tableCFs[0].getFamiliesCount());
  assertEquals("cf1", tableCFs[0].getFamilies(0).toStringUtf8());
  assertEquals("cf3", tableCFs[0].getFamilies(1).toStringUtf8());

  tabCFsMap.clear();
  tabCFsMap.put(tableName1, null);
  tabCFsMap.put(tableName2, new ArrayList<>());
  tabCFsMap.get(tableName2).add("cf1");
  tabCFsMap.put(tableName3, new ArrayList<>());
  tabCFsMap.get(tableName3).add("cf1");
  tabCFsMap.get(tableName3).add("cf3");

  tableCFs = ReplicationPeerConfigUtil.convert(tabCFsMap);
  assertEquals(3, tableCFs.length);
  assertNotNull(ReplicationPeerConfigUtil.getTableCF(tableCFs, tableName1.toString()));
  assertNotNull(ReplicationPeerConfigUtil.getTableCF(tableCFs, tableName2.toString()));
  assertNotNull(ReplicationPeerConfigUtil.getTableCF(tableCFs, tableName3.toString()));

  assertEquals(0,
      ReplicationPeerConfigUtil.getTableCF(tableCFs, tableName1.toString()).getFamiliesCount());

  assertEquals(1, ReplicationPeerConfigUtil.getTableCF(tableCFs, tableName2.toString())
      .getFamiliesCount());
  assertEquals("cf1", ReplicationPeerConfigUtil.getTableCF(tableCFs, tableName2.toString())
      .getFamilies(0).toStringUtf8());

  assertEquals(2, ReplicationPeerConfigUtil.getTableCF(tableCFs, tableName3.toString())
      .getFamiliesCount());
  assertEquals("cf1", ReplicationPeerConfigUtil.getTableCF(tableCFs, tableName3.toString())
      .getFamilies(0).toStringUtf8());
  assertEquals("cf3", ReplicationPeerConfigUtil.getTableCF(tableCFs, tableName3.toString())
      .getFamilies(1).toStringUtf8());

  tabCFsMap = ReplicationPeerConfigUtil.convert2Map(tableCFs);
  assertEquals(3, tabCFsMap.size());
  assertTrue(tabCFsMap.containsKey(tableName1));
  assertTrue(tabCFsMap.containsKey(tableName2));
  assertTrue(tabCFsMap.containsKey(tableName3));
  // 3.2 table "tab1" : null cf-list
  assertEquals(null, tabCFsMap.get(tableName1));
  // 3.3 table "tab2" : cf-list contains a single cf "cf1"
  assertEquals(1, tabCFsMap.get(tableName2).size());
  assertEquals("cf1", tabCFsMap.get(tableName2).get(0));
  // 3.4 table "tab3" : cf-list contains "cf1" and "cf3"
  assertEquals(2, tabCFsMap.get(tableName3).size());
  assertTrue(tabCFsMap.get(tableName3).contains("cf1"));
  assertTrue(tabCFsMap.get(tableName3).contains("cf3"));
}
 
Example 17
Source File: LearningSwitch.java    From floodlight_with_topoguard with Apache License 2.0 4 votes vote down vote up
/**
 * Clears the MAC/VLAN -> SwitchPort map for a single switch
 * @param sw The switch to clear the mapping for
 */
public void clearLearnedTable(IOFSwitch sw) {
    Map<MacVlanPair, Short> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null)
        swMap.clear();
}
 
Example 18
Source File: SpringController.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 4 votes vote down vote up
@RequestMapping("/embed/calendar/{id}")
public String embedCalendar(Map<String, Object> model, HttpServletRequest req, @PathVariable String id) {
	model.clear();
	model.putAll(DiscordAccountHandler.getHandler().getAccountForGuildEmbed(req, id));
	return "embed/calendar";
}
 
Example 19
Source File: RaidsPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void updateMap(Map<String, List<Integer>> map, String input)
{
	map.clear();

	Matcher m = ROTATION_REGEX.matcher(input);
	while (m.find())
	{
		String everything = m.group(1).toLowerCase();
		int split = everything.indexOf(',');
		if (split < 0)
		{
			continue;
		}
		String key = everything.substring(0, split);
		if (key.length() < 1)
		{
			continue;
		}
		List<String> itemNames = Text.fromCSV(everything.substring(split));

		map.computeIfAbsent(key, k -> new ArrayList<>());

		for (String itemName : itemNames)
		{
			if (itemName.equals(""))
			{
				continue;
			}
			if (itemName.equals("ice barrage"))
			{
				map.get(key).add(SpriteID.SPELL_ICE_BARRAGE);
			}
			if (itemName.equals("vengeance"))
			{
				map.get(key).add(SpriteID.SPELL_VENGEANCE);
			}
			if (itemName.equals("fire surge"))
			{
				map.get(key).add(SpriteID.SPELL_FIRE_SURGE);
			}
			else if (itemName.startsWith("salve"))
			{
				map.get(key).add(ItemID.SALVE_AMULETEI);
			}
			else if (itemManager.search(itemName).size() > 0)
			{
				map.get(key).add(itemManager.search(itemName).get(0).getId());
			}
			else
			{
				log.info("RaidsPlugin: Could not find an item ID for item: " + itemName);
			}
		}
	}
}
 
Example 20
Source File: AttributesHelper.java    From neoscada with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * merges the attribute differences. But respects the initial flag sent by
 * many events.
 * in the case the difference is flagged initial the target will be cleared
 * first. This
 * is a convenient method to easy the merge.
 * 
 * @param target
 *            the attributes to merge the difference in
 * @param diff
 *            the difference attributes
 * @param initial
 *            initial flag
 */
public static void mergeAttributes ( final Map<String, Variant> target, final Map<String, Variant> diff, final boolean initial )
{
    if ( initial )
    {
        target.clear ();
    }

    mergeAttributes ( target, diff );
}