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.
23
23
import com .diffplug .spotless .FormatterStep ;
24
24
import com .diffplug .spotless .JarState ;
25
25
import com .diffplug .spotless .Provisioner ;
26
+ import com .diffplug .spotless .RoundedStep ;
26
27
27
28
/** A step for <a href="https://github.com/vsch/flexmark-java">flexmark-java</a>. */
28
- public class FlexmarkStep {
29
- // prevent direct instantiation
30
- private FlexmarkStep () {}
31
-
29
+ public class FlexmarkStep implements RoundedStep {
30
+ private static final long serialVersionUID = 1L ;
32
31
private static final String DEFAULT_VERSION = "0.64.8" ;
33
- private static final String NAME = "flexmark-java" ;
34
32
private static final String MAVEN_COORDINATE = "com.vladsch.flexmark:flexmark-all:" ;
33
+ public static final String NAME = "flexmark-java" ;
34
+
35
+ private final JarState .Promised jarState ;
36
+
37
+ private FlexmarkStep (JarState .Promised jarState ) {
38
+ this .jarState = jarState ;
39
+ }
35
40
36
41
/** Creates a formatter step for the default version. */
37
42
public static FormatterStep create (Provisioner provisioner ) {
@@ -42,20 +47,24 @@ public static FormatterStep create(Provisioner provisioner) {
42
47
public static FormatterStep create (String version , Provisioner provisioner ) {
43
48
Objects .requireNonNull (version , "version" );
44
49
Objects .requireNonNull (provisioner , "provisioner" );
45
- return FormatterStep .createLazy (NAME ,
46
- () -> new State (JarState .from (MAVEN_COORDINATE + version , provisioner )),
50
+ return FormatterStep .create (NAME ,
51
+ new FlexmarkStep (JarState .promise (() -> JarState .from (MAVEN_COORDINATE + version , provisioner ))),
52
+ FlexmarkStep ::equalityState ,
47
53
State ::createFormat );
48
54
}
49
55
50
56
public static String defaultVersion () {
51
57
return DEFAULT_VERSION ;
52
58
}
53
59
60
+ private State equalityState () {
61
+ return new State (jarState .get ());
62
+ }
63
+
54
64
private static class State implements Serializable {
55
65
private static final long serialVersionUID = 1L ;
56
66
57
- /** The jar that contains the formatter. */
58
- final JarState jarState ;
67
+ private final JarState jarState ;
59
68
60
69
State (JarState jarState ) {
61
70
this .jarState = jarState ;
@@ -67,6 +76,5 @@ FormatterFunc createFormat() throws Exception {
67
76
final Constructor <?> constructor = formatterFunc .getConstructor ();
68
77
return (FormatterFunc ) constructor .newInstance ();
69
78
}
70
-
71
79
}
72
80
}
0 commit comments