| 68 | //~ Methoden ---------------------------------------------------------- |
| 69 | |
| 70 | @Override |
| 71 | public T apply(T entity) { |
| 72 | |
| 73 | double value = entity.get(this.element).doubleValue(); |
| 74 | double nv; |
| 75 | |
| 76 | if (this.up == null) { |
| 77 | double high = Math.ceil(value / this.stepwidth) * this.stepwidth; |
| 78 | double low = Math.floor(value / this.stepwidth) * this.stepwidth; |
| 79 | nv = ((value - low < high - value) ? low : high); |
| 80 | } else if (this.up.booleanValue()) { |
| 81 | nv = Math.ceil(value / this.stepwidth) * this.stepwidth; |
| 82 | } else { |
| 83 | nv = Math.floor(value / this.stepwidth) * this.stepwidth; |
| 84 | } |
| 85 | |
| 86 | Number num; |
| 87 | |
| 88 | if (this.longBased) { |
| 89 | num = Long.valueOf((long) nv); |
| 90 | } else { |
| 91 | num = Integer.valueOf((int) nv); |
| 92 | } |
| 93 | |
| 94 | return entity.with(lenient(this.element, num)); |
| 95 | |
| 96 | } |
| 97 | |
| 98 | private static <V extends Number, T extends ChronoEntity<T>> |
| 99 | ChronoOperator<T> lenient( |