30
30
import java .util .Set ;
31
31
import java .util .TreeSet ;
32
32
33
+ import org .springframework .lang .Nullable ;
34
+
33
35
/**
34
36
* Specialization of {@link Properties} that sorts properties alphanumerically
35
37
* based on their keys.
@@ -49,19 +51,17 @@ class SortedProperties extends Properties {
49
51
50
52
static final String EOL = System .lineSeparator ();
51
53
52
- private static final Comparator <Object > keyComparator = //
53
- (key1 , key2 ) -> String .valueOf (key1 ).compareTo (String .valueOf (key2 ));
54
+ private static final Comparator <Object > keyComparator = Comparator .comparing (String ::valueOf );
55
+
56
+ private static final Comparator <Entry <Object , Object >> entryComparator = Entry .comparingByKey (keyComparator );
54
57
55
- private static final Comparator <Entry <Object , Object >> entryComparator = //
56
- Entry .comparingByKey (keyComparator );
57
58
58
59
private final boolean omitComments ;
59
60
60
61
61
62
/**
62
63
* Construct a new {@code SortedProperties} instance that honors the supplied
63
64
* {@code omitComments} flag.
64
- *
65
65
* @param omitComments {@code true} if comments should be omitted when
66
66
* storing properties in a file
67
67
*/
@@ -73,10 +73,8 @@ class SortedProperties extends Properties {
73
73
* Construct a new {@code SortedProperties} instance with properties populated
74
74
* from the supplied {@link Properties} object and honoring the supplied
75
75
* {@code omitComments} flag.
76
- *
77
76
* <p>Default properties from the supplied {@code Properties} object will
78
77
* not be copied.
79
- *
80
78
* @param properties the {@code Properties} object from which to copy the
81
79
* initial properties
82
80
* @param omitComments {@code true} if comments should be omitted when
@@ -87,8 +85,9 @@ class SortedProperties extends Properties {
87
85
putAll (properties );
88
86
}
89
87
88
+
90
89
@ Override
91
- public void store (OutputStream out , String comments ) throws IOException {
90
+ public void store (OutputStream out , @ Nullable String comments ) throws IOException {
92
91
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
93
92
super .store (baos , (this .omitComments ? null : comments ));
94
93
String contents = new String (baos .toByteArray (), StandardCharsets .ISO_8859_1 );
@@ -100,7 +99,7 @@ public void store(OutputStream out, String comments) throws IOException {
100
99
}
101
100
102
101
@ Override
103
- public void store (Writer writer , String comments ) throws IOException {
102
+ public void store (Writer writer , @ Nullable String comments ) throws IOException {
104
103
StringWriter stringWriter = new StringWriter ();
105
104
super .store (stringWriter , (this .omitComments ? null : comments ));
106
105
String contents = stringWriter .toString ();
@@ -112,12 +111,12 @@ public void store(Writer writer, String comments) throws IOException {
112
111
}
113
112
114
113
@ Override
115
- public void storeToXML (OutputStream out , String comments ) throws IOException {
114
+ public void storeToXML (OutputStream out , @ Nullable String comments ) throws IOException {
116
115
super .storeToXML (out , (this .omitComments ? null : comments ));
117
116
}
118
117
119
118
@ Override
120
- public void storeToXML (OutputStream out , String comments , String encoding ) throws IOException {
119
+ public void storeToXML (OutputStream out , @ Nullable String comments , String encoding ) throws IOException {
121
120
super .storeToXML (out , (this .omitComments ? null : comments ), encoding );
122
121
}
123
122
0 commit comments