Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2021-08-18 13:10:00 -04:00
commit 224283e98f
5 changed files with 124 additions and 50 deletions

View file

@ -19,8 +19,7 @@ import java.awt.Color;
import java.awt.Font;
import java.beans.PropertyEditor;
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.*;
import javax.swing.KeyStroke;
@ -530,4 +529,29 @@ public interface Options {
*/
public abstract String getDefaultValueAsString(String optionName);
/**
* Returns true if the two options objects have the same set of options and values
* @param options1 the first options object to test
* @param options2 the second options object to test
* @return true if the two options objects have the same set of options and values
*/
public static boolean hasSameOptionsAndValues(Options options1, Options options2) {
List<String> leafOptionNames1 = options1.getOptionNames();
List<String> leafOptionNames2 = options2.getOptionNames();
Collections.sort(leafOptionNames1);
Collections.sort(leafOptionNames2);
if (!leafOptionNames1.equals(leafOptionNames2)) {
return false;
}
for (String optionName : leafOptionNames1) {
Object value1 = options1.getObject(optionName, null);
Object value2 = options2.getObject(optionName, null);
if (!Objects.equals(value1, value2)) {
return false;
}
}
return true;
}
}

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,8 +15,6 @@
*/
package ghidra.framework.options;
import ghidra.util.HelpLocation;
import java.awt.Color;
import java.awt.Font;
import java.beans.PropertyEditor;
@ -26,6 +23,8 @@ import java.util.*;
import javax.swing.KeyStroke;
import ghidra.util.HelpLocation;
public class SubOptions implements Options {
private AbstractOptions options;
@ -369,5 +368,4 @@ public class SubOptions implements Options {
Set<String> leaves = AbstractOptions.getLeaves(optionPaths);
return new ArrayList<String>(leaves);
}
}