Changeset 7725 in josm for trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionItemPriority.java
- Timestamp:
- 2014-11-15T21:45:22+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionItemPriority.java
r6830 r7725 37 37 public static final AutoCompletionItemPriority UNKNOWN = new AutoCompletionItemPriority(false, false, false); 38 38 39 private final static int NO_USER_INPUT = Integer.MAX_VALUE; 40 41 private final int userInput; 39 42 private final boolean inDataSet; 40 43 private final boolean inStandard; 41 44 private final boolean selected; 45 42 46 43 public AutoCompletionItemPriority(boolean inDataSet, boolean inStandard, boolean selected) { 47 /** 48 * Create new AutoCompletionItemPriority object. 49 * 50 * @param inDataSet true, if the item is found in the currently active data layer 51 * @param inStandard true, if the item is a standard tag, e.g. from the presets. 52 * @param selected true, if it is found on an object that is currently selected 53 * @param userInput null, if the user hasn't entered this tag so far. A number when 54 * the tag key / value has been entered by the user before. A lower number means 55 * this happened more recently and beats a higher number in priority. 56 */ 57 public AutoCompletionItemPriority(boolean inDataSet, boolean inStandard, boolean selected, Integer userInput) { 44 58 this.inDataSet = inDataSet; 45 59 this.inStandard = inStandard; 46 60 this.selected = selected; 61 this.userInput = userInput == null ? NO_USER_INPUT : userInput; 62 } 63 64 public AutoCompletionItemPriority(boolean inDataSet, boolean inStandard, boolean selected) { 65 this(inDataSet, inStandard, selected, NO_USER_INPUT); 47 66 } 48 67 … … 59 78 } 60 79 80 public Integer getUserInput() { 81 return userInput == NO_USER_INPUT ? null : userInput; 82 } 83 61 84 /** 62 85 * Imposes an ordering on the priorities. … … 65 88 @Override 66 89 public int compareTo(AutoCompletionItemPriority other) { 90 int ui = -Integer.compare(userInput, other.userInput); 91 if (ui != 0) return ui; 92 67 93 int sel = Boolean.valueOf(selected).compareTo(other.selected); 68 94 if (sel != 0) return sel; … … 85 111 inDataSet || other.inDataSet, 86 112 inStandard || other.inStandard, 87 selected || other.selected); 113 selected || other.selected, 114 Math.min(userInput, other.userInput)); 88 115 } 89 116 90 117 @Override public String toString() { 91 return String.format("<Priority; inDataSet: %b, inStandard: %b, selected: %b>", inDataSet, inStandard, selected); 118 return String.format("<Priority; userInput: %s, inDataSet: %b, inStandard: %b, selected: %b>", 119 userInput == NO_USER_INPUT ? "no" : Integer.toString(userInput), inDataSet, inStandard, selected); 92 120 } 93 121 }
Note:
See TracChangeset
for help on using the changeset viewer.