document.put("distanceMultiplier", metric.getMultiplier());
document.put("distanceMultiplier", metric.getMultiplier());
/** * Returns the normalized value regarding the underlying {@link Metric}. * * @return */ public double getNormalizedValue() { return value / metric.getMultiplier(); }
/** * Adds the given {@link Distance} to the current one and forces the result to be in a given {@link Metric}. * * @param other must not be {@literal null}. * @param metric must not be {@literal null}. * @return */ public Distance add(Distance other, Metric metric) { Assert.notNull(other, "Distance to must not be null!"); Assert.notNull(metric, "Result metric must not be null!"); double newLeft = getNormalizedValue() * metric.getMultiplier(); double newRight = other.getNormalizedValue() * metric.getMultiplier(); return new Distance(newLeft + newRight, metric); }
/** * Returns a new {@link Distance} in the given {@link Metric}. This means that the returned instance will have the * same normalized value as the original instance. * * @param metric must not be {@literal null}. * @return */ public Distance in(Metric metric) { Assert.notNull(metric, "Metric must not be null!"); return this.metric.equals(metric) ? this : new Distance(getNormalizedValue() * metric.getMultiplier(), metric); }
/** * Adds the given distance to the current one. The resulting {@link Distance} will be in the same metric as the * current one. * * @param other must not be {@literal null}. * @return */ public Distance add(Distance other) { Assert.notNull(other, "Distance to add must not be null!"); double newNormalizedValue = getNormalizedValue() + other.getNormalizedValue(); return new Distance(newNormalizedValue * metric.getMultiplier(), metric); }