Skip to content

Commit

Permalink
TEXT-126: WIP fixing checkstyle order
Browse files Browse the repository at this point in the history
  • Loading branch information
kinow committed Nov 2, 2024
1 parent 2401af9 commit e8b9370
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
*/
package org.apache.commons.text.similarity;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;

import org.apache.commons.lang3.StringUtils;

/**
* A similarity algorithm indicating the percentage of matched characters
* between two character sequences.
Expand Down Expand Up @@ -120,7 +120,7 @@ public Double apply(final CharSequence left, final CharSequence right) {
/**
* Converter class for creating Bigrams for SorensenDice similarity.
*/
private static class SorensenDiceConverter implements Function<CharSequence, Collection<Integer>> {
private static final class SorensenDiceConverter implements Function<CharSequence, Collection<Integer>> {
@Override
public Collection<Integer> apply(CharSequence cs) {
final int length = cs.length();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*/
package org.apache.commons.text.similarity;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.math.RoundingMode;
import java.text.DecimalFormat;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

/**
* Unit tests for {@link SorensenDiceSimilarity}.
Expand Down Expand Up @@ -85,6 +85,12 @@ public void testGetSorensenDicesSimilarity_NullString() {
assertThrows(IllegalArgumentException.class, () -> similarity.apply(null, "clear"));
}

/**
* Format the double to two decimal places rounding it down.
*
* @param value the double value
* @return double formatted to two places rounding it down
*/
public static double printTwoDecimals(double value) {
DecimalFormat df = new DecimalFormat("#.##");
df.setRoundingMode(RoundingMode.DOWN);
Expand Down

0 comments on commit e8b9370

Please sign in to comment.