Skip to content

Commit

Permalink
Add Google Java Format
Browse files Browse the repository at this point in the history
Signed-off-by: Jarno Elovirta <[email protected]>
  • Loading branch information
jelovirt committed Nov 13, 2019
1 parent 42c2cc5 commit b352c0a
Show file tree
Hide file tree
Showing 29 changed files with 2,333 additions and 2,386 deletions.
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
*
* See the accompanying LICENSE file for applicable license.
*/
plugins {
id "com.diffplug.gradle.spotless" version "3.26.0"
}

apply plugin: 'java'
apply plugin: 'maven'

Expand Down Expand Up @@ -67,3 +71,9 @@ task dist(type: Zip) {
}
archiveName "org.dita.${project.name}-${project.version}.zip"
}

spotless {
java {
googleJavaFormat()
}
}
26 changes: 13 additions & 13 deletions src/main/java/org/dita/index/IndexCollator.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ RELIANCE, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF

public class IndexCollator {

private Comparator collator;

public IndexCollator(final Locale locale) {
try {
collator = com.ibm.icu.text.Collator.getInstance(locale);
} catch (final NoClassDefFoundError ex) {
System.out.println("[INFO] IBM ICU4J Collator is not found. Default Java Collator will be used");
collator = java.text.Collator.getInstance(locale);
}
}

public int compare(final Object o1, final Object o2) {
return collator.compare(o1, o2);
private Comparator collator;

public IndexCollator(final Locale locale) {
try {
collator = com.ibm.icu.text.Collator.getInstance(locale);
} catch (final NoClassDefFoundError ex) {
System.out.println(
"[INFO] IBM ICU4J Collator is not found. Default Java Collator will be used");
collator = java.text.Collator.getInstance(locale);
}
}

public int compare(final Object o1, final Object o2) {
return collator.compare(o1, o2);
}
}
36 changes: 18 additions & 18 deletions src/main/java/org/dita/index/IndexComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ RELIANCE, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF

class IndexComparator implements Comparator<IndexEntry> {

private final IndexCollator collator;

public IndexComparator(final Locale locale) {
this.collator = new IndexCollator(locale);
}

public int compare(final IndexEntry o1, final IndexEntry o2) {
final String value1 = getSortString(o1);
final String value2 = getSortString(o2);
return collator.compare(value1, value2);
}

private String getSortString(final IndexEntry entry) {
if (entry.getSortString() != null) {
return entry.getSortString();
} else {
return entry.getValue();
}
private final IndexCollator collator;

public IndexComparator(final Locale locale) {
this.collator = new IndexCollator(locale);
}

public int compare(final IndexEntry o1, final IndexEntry o2) {
final String value1 = getSortString(o1);
final String value2 = getSortString(o2);
return collator.compare(value1, value2);
}

private String getSortString(final IndexEntry entry) {
if (entry.getSortString() != null) {
return entry.getSortString();
} else {
return entry.getValue();
}
}
}
Loading

0 comments on commit b352c0a

Please sign in to comment.