Skip to content

Commit bdc5b5e

Browse files
PropertyFile: import clean up
1 parent 8aeb964 commit bdc5b5e

File tree

1 file changed

+62
-63
lines changed

1 file changed

+62
-63
lines changed
Lines changed: 62 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,62 @@
1-
/*
2-
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3-
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4-
*
5-
* This code is free software; you can redistribute it and/or modify it
6-
* under the terms of the GNU General Public License version 2 only, as
7-
* published by the Free Software Foundation. Oracle designates this
8-
* particular file as subject to the "Classpath" exception as provided
9-
* by Oracle in the LICENSE file that accompanied this code.
10-
*
11-
* This code is distributed in the hope that it will be useful, but WITHOUT
12-
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13-
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14-
* version 2 for more details (a copy is included in the LICENSE file that
15-
* accompanied this code).
16-
*
17-
* You should have received a copy of the GNU General Public License version
18-
* 2 along with this work; if not, write to the Free Software Foundation,
19-
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20-
*
21-
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22-
* or visit www.oracle.com if you need additional information or have any
23-
* questions.
24-
*/
25-
package jdk.jpackage.test;
26-
27-
import java.io.IOException;
28-
import java.io.UncheckedIOException;
29-
import java.nio.file.Files;
30-
import java.nio.file.Path;
31-
import java.util.Map;
32-
import java.util.Objects;
33-
import java.util.Optional;
34-
import java.util.Properties;
35-
import java.util.function.Supplier;
36-
37-
public final class PropertyFile {
38-
39-
PropertyFile(Map<String, String> data) {
40-
this.data = new Properties();
41-
this.data.putAll(data);
42-
}
43-
44-
PropertyFile(Path path) {
45-
data = new Properties();
46-
try (var reader = Files.newBufferedReader(path)) {
47-
data.load(reader);
48-
} catch (IOException ex) {
49-
throw new UncheckedIOException(ex);
50-
}
51-
}
52-
53-
public Optional<String> findProperty(String name) {
54-
Objects.requireNonNull(name);
55-
return Optional.ofNullable(data.getProperty(name));
56-
}
57-
58-
public Optional<Boolean> findBooleanProperty(String name) {
59-
return findProperty(name).map(Boolean::parseBoolean);
60-
}
61-
62-
private final Properties data;
63-
}
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package jdk.jpackage.test;
26+
27+
import java.io.IOException;
28+
import java.io.UncheckedIOException;
29+
import java.nio.file.Files;
30+
import java.nio.file.Path;
31+
import java.util.Map;
32+
import java.util.Objects;
33+
import java.util.Optional;
34+
import java.util.Properties;
35+
36+
public final class PropertyFile {
37+
38+
PropertyFile(Map<String, String> data) {
39+
this.data = new Properties();
40+
this.data.putAll(data);
41+
}
42+
43+
PropertyFile(Path path) {
44+
data = new Properties();
45+
try (var reader = Files.newBufferedReader(path)) {
46+
data.load(reader);
47+
} catch (IOException ex) {
48+
throw new UncheckedIOException(ex);
49+
}
50+
}
51+
52+
public Optional<String> findProperty(String name) {
53+
Objects.requireNonNull(name);
54+
return Optional.ofNullable(data.getProperty(name));
55+
}
56+
57+
public Optional<Boolean> findBooleanProperty(String name) {
58+
return findProperty(name).map(Boolean::parseBoolean);
59+
}
60+
61+
private final Properties data;
62+
}

0 commit comments

Comments
 (0)