Use ComparisonChain here.
Does anyone know if these colorization names can indeed be null? Otherwise we can remove the null-safe comparator. It was previously calling ObjectUtil.compareTo() which leads me to think it needed null-safety. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@939 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
package com.threerings.stage.tools.editor;
|
package com.threerings.stage.tools.editor;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
@@ -30,8 +31,9 @@ import javax.swing.JPanel;
|
|||||||
import javax.swing.JSlider;
|
import javax.swing.JSlider;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
import com.samskivert.util.Comparators;
|
import com.google.common.collect.ComparisonChain;
|
||||||
import com.samskivert.util.ObjectUtil;
|
import com.google.common.collect.Ordering;
|
||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import com.samskivert.swing.HGroupLayout;
|
import com.samskivert.swing.HGroupLayout;
|
||||||
@@ -220,15 +222,18 @@ public class ObjectEditorDialog extends EditorDialog
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo (ZationChoice that) {
|
public int compareTo (ZationChoice that) {
|
||||||
return Comparators.combine(
|
return ComparisonChain.start()
|
||||||
ObjectUtil.compareTo(this.name, that.name),
|
.compare(this.name, that.name, NULLS_OK)
|
||||||
Comparators.compare(this.colorId, that.colorId));
|
.compare(this.colorId, that.colorId)
|
||||||
|
.result();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static final Comparator<String> NULLS_OK = Ordering.natural().nullsFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JTextField _action;
|
protected JTextField _action;
|
||||||
|
|||||||
Reference in New Issue
Block a user