|
1 | 1 | /*
|
2 |
| - * Copyright 2016-2023 DiffPlug |
| 2 | + * Copyright 2016-2024 DiffPlug |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
34 | 34 | import java.util.stream.Collectors;
|
35 | 35 | import java.util.stream.Stream;
|
36 | 36 |
|
| 37 | +import javax.annotation.Nullable; |
| 38 | + |
37 | 39 | import com.diffplug.spotless.FormatterFunc;
|
38 | 40 | import com.diffplug.spotless.FormatterStep;
|
| 41 | +import com.diffplug.spotless.RoundedStep; |
39 | 42 |
|
40 | 43 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
41 | 44 |
|
42 |
| -public final class ImportOrderStep { |
| 45 | +public final class ImportOrderStep implements RoundedStep { |
| 46 | + private static final long serialVersionUID = 1L; |
43 | 47 | private static final boolean WILDCARDS_LAST_DEFAULT = false;
|
44 | 48 | private static final boolean SEMANTIC_SORT_DEFAULT = false;
|
45 | 49 | private static final Set<String> TREAT_AS_PACKAGE_DEFAULT = Set.of();
|
@@ -84,9 +88,8 @@ public FormatterStep createFrom(boolean wildcardsLast, boolean semanticSort, Set
|
84 | 88 |
|
85 | 89 | private FormatterStep createFrom(boolean wildcardsLast, boolean semanticSort, Set<String> treatAsPackage,
|
86 | 90 | Set<String> treatAsClass, Supplier<List<String>> importOrder) {
|
87 |
| - return FormatterStep.createLazy("importOrder", |
88 |
| - () -> new State(importOrder.get(), lineFormat, wildcardsLast, semanticSort, treatAsPackage, |
89 |
| - treatAsClass), |
| 91 | + return FormatterStep.create("importOrder", |
| 92 | + new State(importOrder.get(), lineFormat, wildcardsLast, semanticSort, treatAsPackage, treatAsClass), |
90 | 93 | State::toFormatter);
|
91 | 94 | }
|
92 | 95 |
|
@@ -121,8 +124,12 @@ private static final class State implements Serializable {
|
121 | 124 | private final TreeSet<String> treatAsPackage;
|
122 | 125 | private final TreeSet<String> treatAsClass;
|
123 | 126 |
|
124 |
| - State(List<String> importOrder, String lineFormat, boolean wildcardsLast, boolean semanticSort, |
125 |
| - Set<String> treatAsPackage, Set<String> treatAsClass) { |
| 127 | + State(List<String> importOrder, |
| 128 | + String lineFormat, |
| 129 | + boolean wildcardsLast, |
| 130 | + boolean semanticSort, |
| 131 | + @Nullable Set<String> treatAsPackage, |
| 132 | + @Nullable Set<String> treatAsClass) { |
126 | 133 | this.importOrder = importOrder;
|
127 | 134 | this.lineFormat = lineFormat;
|
128 | 135 | this.wildcardsLast = wildcardsLast;
|
|
0 commit comments