< prev index next >
src/org/netbeans/jemmy/operators/JSpinnerOperator.java
Print this page
@@ -26,11 +26,10 @@
import java.awt.Container;
import java.text.ParseException;
import java.util.Date;
import java.util.Hashtable;
import java.util.List;
-import java.util.Objects;
import javax.swing.JComponent;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;
import javax.swing.SpinnerListModel;
@@ -965,11 +964,11 @@
}
}
/**
* Abstract class for a scrolling of a spinner having unknown model type. A
- * subclass needs to override {@code equals(Object)} value to specify a
+ * subclass needs to override {@code reached(Object)} method to specify a
* criteria of successful scrolling.
*/
public abstract static class ObjectScrollAdjuster implements ScrollAdjuster {
SpinnerModel model;
@@ -987,11 +986,11 @@
model = oper.getModel();
}
@Override
public int getScrollDirection() {
- if (equals(model.getValue())) {
+ if (reached(model.getValue())) {
return ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION;
} else if (direction == ScrollAdjuster.INCREASE_SCROLL_DIRECTION
&& model.getNextValue() != null
|| direction == ScrollAdjuster.DECREASE_SCROLL_DIRECTION
&& model.getPreviousValue() != null) {
@@ -999,11 +998,11 @@
} else {
return ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION;
}
}
- public abstract boolean equals(Object curvalue);
+ public abstract boolean reached(Object curvalue);
@Override
public int getScrollOrientation() {
return SwingConstants.VERTICAL;
}
@@ -1027,19 +1026,13 @@
public ExactScrollAdjuster(JSpinnerOperator oper, Object obj, int direction) {
super(oper, direction);
this.obj = obj;
}
- public boolean equals(Object curvalue) {
- return curvalue != null && curvalue.equals(obj);
- }
-
@Override
- public int hashCode() {
- int hash = 7;
- hash = 79 * hash + Objects.hashCode(this.obj);
- return hash;
+ public boolean reached(Object curvalue) {
+ return curvalue != null && curvalue.equals(obj);
}
@Override
public String getDescription() {
return "Spin to " + obj.toString() + " value";
@@ -1091,22 +1084,13 @@
*/
public ToStringScrollAdjuster(JSpinnerOperator oper, String pattern, int direction) {
this(oper, pattern, oper.getComparator(), direction);
}
- public boolean equals(Object curvalue) {
-
- // TODO: This abuses the semantics of Object.equals()
- return curvalue != null && comparator.equals(curvalue.toString(), pattern);
- }
-
@Override
- public int hashCode() {
- int hash = 7;
- hash = 97 * hash + Objects.hashCode(this.pattern);
- hash = 97 * hash + Objects.hashCode(this.comparator);
- return hash;
+ public boolean reached(Object curvalue) {
+ return curvalue != null && comparator.equals(curvalue.toString(), pattern);
}
@Override
public String getDescription() {
return "Spin to \"" + pattern + "\" value";
< prev index next >