JDK 13 RFR of JDK-8223178: Improve FileSystems.newFileSystem example with map factory methods
Joe Darcy
joe.darcy at oracle.com
Wed May 1 20:48:25 UTC 2019
On 5/1/2019 11:43 AM, Alan Bateman wrote:
>
>
> On 01/05/2019 17:53, Joe Darcy wrote:
>> :
>>
>> Keeping env to one line also gives a comparably long line length:
>>
>> --- a/src/java.base/share/classes/java/nio/file/FileSystems.java Tue
>> Apr 30 16:11:42 2019 -0700
>> +++ b/src/java.base/share/classes/java/nio/file/FileSystems.java Wed
>> May 01 09:50:15 2019 -0700
>> @@ -252,9 +252,7 @@
>> * Suppose there is a provider identified by the scheme {@code
>> "memory"}
>> * installed:
>> * <pre>
>> - * Map<String,String> env = new HashMap<>();
>> - * env.put("capacity", "16G");
>> - * env.put("blockSize", "4k");
>> + * Map<String,String> env = Map.of("capacity", "16G",
>> "blockSize", "4k");
>> * FileSystem fs =
>> FileSystems.newFileSystem(URI.create("memory:///?name=logfs"), env);
>> * </pre>
>> *
>> The {"capacity", "16G"} and {"blockSize", "4k"} can be put on
>> different lines to provide a stronger visual hint of grouping.
>>
>> Which of these alternatives do you prefer?
> This looks okay. Brian's suggestion looks good too (I don't want to
> waste your time on this one).
>
I'd prefer to push a version without the explicit map variable, but the
max line length is slightly longer:
* <pre>
- * Map<String,String> env = new HashMap<>();
- * env.put("capacity", "16G");
- * env.put("blockSize", "4k");
- * FileSystem fs =
FileSystems.newFileSystem(URI.create("memory:///?name=logfs"), env);
+ * FileSystem fs =
FileSystems.newFileSystem(URI.create("memory:///?name=logfs"),
+ * Map.of("capacity", "16G", "blockSize", "4k"));
* </pre>
-Joe
More information about the core-libs-dev
mailing list