forked from jbossas/console
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8da5c7
commit 0c91b11
Showing
3 changed files
with
42 additions
and
26 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
gui/src/main/java/org/jboss/as/console/client/tools/DMR.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.jboss.as.console.client.tools; | ||
|
||
import org.jboss.dmr.client.ModelNode; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author Heiko Braun | ||
* @date 7/24/12 | ||
*/ | ||
public class DMR { | ||
|
||
public static void mergeChanges(ModelNode target, Map<String,Object> changeset) | ||
{ | ||
final Set<String> changesetKeys = changeset.keySet(); | ||
final Set<String> attributeNames = target.keys(); | ||
|
||
for(String key : changesetKeys) | ||
{ | ||
boolean matched = false; | ||
for(String attribute : attributeNames) | ||
{ | ||
if(key.equals(attribute)) | ||
{ | ||
final Object o = changeset.get(key); | ||
final ModelNode node = Types.toDMR(o); | ||
target.get(attribute).set(node); | ||
matched = true; | ||
break; | ||
} | ||
} | ||
|
||
if(!matched) | ||
throw new RuntimeException("Unmatched attribute name in changeset: "+key); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters