001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.vfs2; 018 019import java.nio.charset.Charset; 020import java.time.Duration; 021import java.util.Objects; 022import java.util.function.Function; 023 024import org.apache.commons.lang3.StringUtils; 025import org.apache.commons.lang3.time.DurationUtils; 026 027/** 028 * Abstracts configuring {@link FileSystemOptions}s. 029 */ 030public abstract class FileSystemConfigBuilder { 031 032 /** Default prefix to use when resolving system properties */ 033 private static final String PREFIX = "vfs."; 034 035 /** The root URI of the file system */ 036 private static final String ROOTURI = "rootURI"; 037 038 /** The prefix to use when resolving system properties */ 039 private final String prefix; 040 041 /** 042 * Constructs builder with default prefix. 043 * 044 * @since 1.0 045 */ 046 protected FileSystemConfigBuilder() { 047 prefix = PREFIX; 048 } 049 050 /** 051 * Constructs builder with specified component name. 052 * 053 * @param component component name to be used in prefix 054 * @since 2.0 055 */ 056 protected FileSystemConfigBuilder(final String component) { 057 prefix = PREFIX + component; 058 } 059 060 /** 061 * Gets a named option as a Boolean. 062 * 063 * @param fileSystemOptions file system options to query, may be null. 064 * @param name the option name 065 * @return the option in {@code opts} or system properties, otherwise null 066 * @see #getBoolean(FileSystemOptions, String, Boolean) 067 * @since 2.0 068 */ 069 protected Boolean getBoolean(final FileSystemOptions fileSystemOptions, final String name) { 070 return getBoolean(fileSystemOptions, name, null); 071 } 072 073 /** 074 * Gets a named option as a Boolean. 075 * 076 * @param fileSystemOptions file system options to query, may be null. 077 * @param name the option name 078 * @param defaultValue value to return if option is not present 079 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 080 * @see #getBoolean(FileSystemOptions, String, Boolean) 081 * @since 2.0 082 */ 083 protected boolean getBoolean(final FileSystemOptions fileSystemOptions, final String name, 084 final boolean defaultValue) { 085 return getBoolean(fileSystemOptions, name, Boolean.valueOf(defaultValue)).booleanValue(); 086 } 087 088 /** 089 * Gets a named option as a Boolean. 090 * 091 * @param fileSystemOptions file system options to query, may be null. 092 * @param name the option name 093 * @param defaultValue value to return if option is not present 094 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 095 * @see #getBoolean(FileSystemOptions, String, Boolean) 096 * @since 2.0 097 */ 098 protected Boolean getBoolean(final FileSystemOptions fileSystemOptions, final String name, 099 final Boolean defaultValue) { 100 return getParam(fileSystemOptions, name, defaultValue, Boolean::valueOf, Boolean.class); 101 } 102 103 /** 104 * Gets a named option as a Byte. 105 * 106 * @param fileSystemOptions file system options to query, may be null. 107 * @param name the option name 108 * @return the option in {@code opts} or system properties, otherwise null 109 * @see #getByte(FileSystemOptions, String, Byte) 110 * @since 2.0 111 */ 112 protected Byte getByte(final FileSystemOptions fileSystemOptions, final String name) { 113 return getByte(fileSystemOptions, name, null); 114 } 115 116 /** 117 * Gets a named option as a Byte. 118 * 119 * @param fileSystemOptions file system options to query, may be null. 120 * @param name the option name 121 * @param defaultValue value to return if option is not present 122 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 123 * @see #getByte(FileSystemOptions, String, Byte) 124 * @since 2.0 125 */ 126 protected byte getByte(final FileSystemOptions fileSystemOptions, final String name, final byte defaultValue) { 127 return getByte(fileSystemOptions, name, Byte.valueOf(defaultValue)).byteValue(); 128 } 129 130 /** 131 * Gets a named option as a Byte. 132 * 133 * @param fileSystemOptions file system options to query, may be null. 134 * @param name the option name 135 * @param defaultValue value to return if option is not present 136 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 137 * @since 2.0 138 */ 139 protected Byte getByte(final FileSystemOptions fileSystemOptions, final String name, final Byte defaultValue) { 140 return getParam(fileSystemOptions, name, defaultValue, Byte::valueOf, Byte.class); 141 } 142 143 /** 144 * Gets a named option as a Character. 145 * 146 * @param fileSystemOptions file system options to query, may be null. 147 * @param name the option name 148 * @return the option in {@code opts} or system properties, otherwise null 149 * @see #getCharacter(FileSystemOptions, String, Character) 150 * @since 2.0 151 */ 152 protected Character getCharacter(final FileSystemOptions fileSystemOptions, final String name) { 153 return getCharacter(fileSystemOptions, name, null); 154 } 155 156 /** 157 * Gets a named option as a Character. 158 * 159 * @param fileSystemOptions file system options to query, may be null. 160 * @param name the option name 161 * @param defaultValue value to return if option is not present 162 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 163 * @see #getCharacter(FileSystemOptions, String, Character) 164 * @since 2.0 165 */ 166 protected char getCharacter(final FileSystemOptions fileSystemOptions, final String name, final char defaultValue) { 167 return getCharacter(fileSystemOptions, name, Character.valueOf(defaultValue)).charValue(); 168 } 169 170 /** 171 * Gets a named option as a Character. 172 * 173 * @param fileSystemOptions file system options to query, may be null. 174 * @param name the option name 175 * @param defaultValue value to return if option is not present 176 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 177 * @since 2.0 178 */ 179 protected Character getCharacter(final FileSystemOptions fileSystemOptions, final String name, 180 final Character defaultValue) { 181 Character value = getParam(fileSystemOptions, name); 182 if (value == null) { 183 final String str = getProperty(name); 184 if (StringUtils.isEmpty(str)) { 185 return defaultValue; 186 } 187 value = Character.valueOf(str.charAt(0)); 188 } 189 return value; 190 } 191 192 /** 193 * Gets a named option as a Charset. 194 * 195 * @param fileSystemOptions file system options to query, may be null. 196 * @param name the option name 197 * @return the option in {@code opts} or system properties, otherwise null 198 * @see #getCharset(FileSystemOptions, String, Charset) 199 * @since 2.11.0 200 */ 201 protected Charset getCharset(final FileSystemOptions fileSystemOptions, final String name) { 202 return getCharset(fileSystemOptions, name, null); 203 } 204 205 /** 206 * Gets a named option as a Charset. 207 * 208 * @param fileSystemOptions file system options to query, may be null. 209 * @param name the option name 210 * @param defaultValue value to return if option is not present 211 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 212 * @since 2.11.0 213 */ 214 protected Charset getCharset(final FileSystemOptions fileSystemOptions, final String name, final Charset defaultValue) { 215 return getParam(fileSystemOptions, name, defaultValue, Charset::forName, Charset.class); 216 } 217 218 /** 219 * Gets the target of this configuration. 220 * 221 * @return the specific file system class 222 * @since 1.0 223 */ 224 protected abstract Class<? extends FileSystem> getConfigClass(); 225 226 /** 227 * Gets a named option as a Double. 228 * 229 * @param fileSystemOptions file system options to query, may be null. 230 * @param name the option name 231 * @return the option in {@code opts} or system properties, otherwise null 232 * @see #getDouble(FileSystemOptions, String, Double) 233 * @since 2.0 234 */ 235 protected Double getDouble(final FileSystemOptions fileSystemOptions, final String name) { 236 return getDouble(fileSystemOptions, name, null); 237 } 238 239 /** 240 * Gets a named option as a Double. 241 * 242 * @param fileSystemOptions file system options to query, may be null. 243 * @param name the option name 244 * @param defaultValue value to return if option is not present 245 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 246 * @see #getDouble(FileSystemOptions, String, Double) 247 * @since 2.0 248 */ 249 protected double getDouble(final FileSystemOptions fileSystemOptions, final String name, 250 final double defaultValue) { 251 return getDouble(fileSystemOptions, name, Double.valueOf(defaultValue)).doubleValue(); 252 } 253 254 /** 255 * Gets a named option as a Double. 256 * 257 * @param fileSystemOptions file system options to query, may be null. 258 * @param name the option name 259 * @param defaultValue value to return if option is not present 260 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 261 * @since 2.0 262 */ 263 protected Double getDouble(final FileSystemOptions fileSystemOptions, final String name, 264 final Double defaultValue) { 265 return getParam(fileSystemOptions, name, defaultValue, Double::valueOf, Double.class); 266 } 267 268 /** 269 * Gets a named option as a Duration. 270 * 271 * @param fileSystemOptions file system options to query, may be null. 272 * @param name the option name 273 * @return the option in {@code opts} or system properties, otherwise null 274 * @see #getLong(FileSystemOptions, String, Long) 275 * @since 2.8.0 276 */ 277 protected Duration getDuration(final FileSystemOptions fileSystemOptions, final String name) { 278 return getDuration(fileSystemOptions, name, null); 279 } 280 281 /** 282 * Gets a named option as a Duration. 283 * 284 * @param fileSystemOptions file system options to query, may be null. 285 * @param name the option name 286 * @param defaultValue value to return if option is not present 287 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 288 * @since 2.8.0 289 */ 290 protected Duration getDuration(final FileSystemOptions fileSystemOptions, final String name, 291 final Duration defaultValue) { 292 return getParam(fileSystemOptions, name, defaultValue, Duration::parse, Duration.class); 293 } 294 295 /** 296 * Gets a named option as a Duration bound to the integer range. 297 * 298 * @param fileSystemOptions file system options to query, may be null. 299 * @param name the option name 300 * @return the option in {@code opts} or system properties, otherwise null 301 * @see #getLong(FileSystemOptions, String, Long) 302 * @since 2.8.0 303 */ 304 protected Integer getDurationInteger(final FileSystemOptions fileSystemOptions, final String name) { 305 return getDurationInteger(fileSystemOptions, name, null); 306 } 307 308 /** 309 * Gets a named option as a Duration bound to the integer range. 310 * 311 * @param fileSystemOptions file system options to query, may be null. 312 * @param name the option name 313 * @param defaultValue value to return if option is not present 314 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 315 * @since 2.8.0 316 */ 317 protected Integer getDurationInteger(final FileSystemOptions fileSystemOptions, final String name, 318 final Duration defaultValue) { 319 return DurationUtils.toMillisInt(getParam(fileSystemOptions, name, defaultValue, Duration::parse, Duration.class)); 320 } 321 322 /** 323 *Gets a named option as a Double. 324 * 325 * @param <E> enumeration type 326 * @param enumClass class of enumeration type 327 * @param fileSystemOptions file system options to query, may be null. 328 * @param name the option name * 329 * @return the option in {@code opts} or system properties, otherwise null 330 * @see #getEnum(Class, FileSystemOptions, String, Enum) 331 * @throws IllegalArgumentException if option value is not a known enumeration. 332 * @since 2.1 333 */ 334 protected <E extends Enum<E>> E getEnum(final Class<E> enumClass, final FileSystemOptions fileSystemOptions, 335 final String name) { 336 return this.getEnum(enumClass, fileSystemOptions, name, null); 337 } 338 339 /** 340 * Gets a named option as an Enum. 341 * 342 * @param <E> enumeration type 343 * @param enumClass class of enumeration type 344 * @param fileSystemOptions file system options to query, may be null. 345 * @param name the option name 346 * @param defaultValue value to return if option is not present 347 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 348 * @see #getEnum(Class, FileSystemOptions, String, Enum) 349 * @throws IllegalArgumentException if option value is not a known enumeration. 350 * @since 2.1 351 */ 352 protected <E extends Enum<E>> E getEnum(final Class<E> enumClass, final FileSystemOptions fileSystemOptions, 353 final String name, final E defaultValue) { 354 E value = getParam(fileSystemOptions, name); 355 if (value == null) { 356 final String str = getProperty(name); 357 if (str == null) { 358 return defaultValue; 359 } 360 value = Enum.valueOf(enumClass, str); 361 } 362 return value; 363 } 364 365 /** 366 * Gets a named option as a Float. 367 * 368 * @param fileSystemOptions file system options to query, may be null. 369 * @param name the option name 370 * @return the option in {@code opts} or system properties, otherwise null 371 * @see #getFloat(FileSystemOptions, String, Float) 372 * @throws NumberFormatException if option value is not a valid float. 373 * @since 2.0 374 */ 375 protected Float getFloat(final FileSystemOptions fileSystemOptions, final String name) { 376 return getFloat(fileSystemOptions, name, null); 377 } 378 379 /** 380 * Gets a named option as a Float. 381 * 382 * @param fileSystemOptions file system options to query, may be null. 383 * @param name the option name 384 * @param defaultValue value to return if option is not present 385 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 386 * @see #getFloat(FileSystemOptions, String, Float) 387 * @throws NumberFormatException if option value is not a valid float. 388 * @since 2.0 389 */ 390 protected float getFloat(final FileSystemOptions fileSystemOptions, final String name, final float defaultValue) { 391 return getFloat(fileSystemOptions, name, Float.valueOf(defaultValue)).floatValue(); 392 } 393 394 /** 395 * Gets a named option as a Float. 396 * 397 * @param fileSystemOptions file system options to query, may be null. 398 * @param name the option name 399 * @param defaultValue value to return if option is not present 400 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 401 * @throws NumberFormatException if option value is not a valid float. 402 * @since 2.0 403 */ 404 protected Float getFloat(final FileSystemOptions fileSystemOptions, final String name, final Float defaultValue) { 405 return getParam(fileSystemOptions, name, defaultValue, Float::valueOf, Float.class); 406 } 407 408 /** 409 * Gets a named option as an Integer. 410 * 411 * @param fileSystemOptions file system options to query, may be null. 412 * @param name the option name 413 * @return the option in {@code opts} or system properties, otherwise null 414 * @see #getInteger(FileSystemOptions, String, Integer) 415 * @throws NumberFormatException if option value is not a valid integer. 416 * @since 2.0 417 */ 418 protected Integer getInteger(final FileSystemOptions fileSystemOptions, final String name) { 419 return getInteger(fileSystemOptions, name, null); 420 } 421 422 /** 423 * Gets a named option as an Integer. 424 * 425 * @param fileSystemOptions file system options to query, may be null. 426 * @param name the option name 427 * @param defaultValue value to return if option is not present 428 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 429 * @see #getInteger(FileSystemOptions, String, Integer) 430 * @throws NumberFormatException if option value is not a valid integer. 431 * @since 2.0 432 */ 433 protected int getInteger(final FileSystemOptions fileSystemOptions, final String name, final int defaultValue) { 434 return getInteger(fileSystemOptions, name, Integer.valueOf(defaultValue)).intValue(); 435 } 436 437 /** 438 * Gets a named option as an Integer. 439 * 440 * @param fileSystemOptions file system options to query, may be null. 441 * @param name the option name 442 * @param defaultValue value to return if option is not present 443 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 444 * @throws NumberFormatException if option value is not a valid integer. 445 * @since 2.0 446 */ 447 protected Integer getInteger(final FileSystemOptions fileSystemOptions, final String name, 448 final Integer defaultValue) { 449 return getParam(fileSystemOptions, name, defaultValue, Integer::valueOf, Integer.class); 450 } 451 452 /** 453 * Gets a named option as a Long. 454 * 455 * @param fileSystemOptions file system options to query, may be null. 456 * @param name the option name 457 * @return the option in {@code opts} or system properties, otherwise null 458 * @see #getLong(FileSystemOptions, String, Long) 459 * @throws NumberFormatException if option value is not a valid long. 460 * @since 2.0 461 */ 462 protected Long getLong(final FileSystemOptions fileSystemOptions, final String name) { 463 return getLong(fileSystemOptions, name, null); 464 } 465 466 /** 467 * Gets a named option as a Long. 468 * 469 * @param fileSystemOptions file system options to query, may be null. 470 * @param name the option name 471 * @param defaultValue value to return if option is not present 472 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 473 * @see #getLong(FileSystemOptions, String, Long) 474 * @throws NumberFormatException if option value is not a valid long. 475 * @since 2.0 476 */ 477 protected long getLong(final FileSystemOptions fileSystemOptions, final String name, final long defaultValue) { 478 return getLong(fileSystemOptions, name, Long.valueOf(defaultValue)).longValue(); 479 } 480 481 /** 482 * Gets a named option as a Long. 483 * 484 * @param fileSystemOptions file system options to query, may be null. 485 * @param name the option name 486 * @param defaultValue value to return if option is not present 487 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 488 * @throws NumberFormatException if option value is not a valid long. 489 * @since 2.0 490 */ 491 protected Long getLong(final FileSystemOptions fileSystemOptions, final String name, final Long defaultValue) { 492 return getParam(fileSystemOptions, name, defaultValue, Long::valueOf, Long.class); 493 } 494 495 /** 496 * Gets a named parameter. 497 * 498 * @param <T> The expected return type. 499 * @param fileSystemOptions file system options to query, may be null. 500 * @param name get option with this name 501 * @return the named option or null 502 * @since 1.0 503 */ 504 protected <T> T getParam(final FileSystemOptions fileSystemOptions, final String name) { 505 return fileSystemOptions == null ? null : fileSystemOptions.getOption(getConfigClass(), name); 506 } 507 508 /** 509 * Gets a named parameter. 510 * 511 * @param <T> The expected return type. 512 * @param fileSystemOptions file system options to query, may be null. 513 * @param name get option with this name 514 * @param defaultValue value to use if the system property value is null. 515 * @param function Builds an instance of T from a system property String value. 516 * @param returnType TODO 517 * @return the named option or null 518 * @since 2.8.0 519 */ 520 private <T> T getParam(final FileSystemOptions fileSystemOptions, final String name, final T defaultValue, final Function<String, T> function, 521 final Class<T> returnType) { 522 T value = getParam(fileSystemOptions, name); 523 if (value == null) { 524 final String str = getProperty(name); 525 if (str == null) { 526 return defaultValue; 527 } 528 value = function.apply(str); 529 } 530 return returnType == null ? null : returnType.isInstance(value) ? value : function.apply(Objects.toString(value)); 531 } 532 533 /** 534 * Gets a named parameter. 535 * 536 * @param <T> The expected return type. 537 * @param fileSystemOptions file system options to query, may be null. 538 * @param name get option with this name 539 * @param defaultValue The default value if absent. 540 * @return the named option or {@code defaultValue}. 541 * @since 2.10.0 542 */ 543 protected <T> T getParamOrDefault(final FileSystemOptions fileSystemOptions, final String name, final T defaultValue) { 544 return fileSystemOptions == null ? defaultValue : fileSystemOptions.getOptionOrDefault(getConfigClass(), name, defaultValue); 545 } 546 547 /** 548 * Gets the system property for the given name. 549 * 550 * @param name The name to lookup combined with the prefix. 551 * @return a system property or null 552 * @since 2.1 553 */ 554 private String getProperty(final String name) { 555 return System.getProperty(toPropertyKey(name)); 556 } 557 558 /** 559 * Gets the root URI of the file system. 560 * 561 * @param fileSystemOptions file system options to query, may be null. 562 * @return The root URI, or null. 563 * @since 2.0 564 */ 565 public String getRootURI(final FileSystemOptions fileSystemOptions) { 566 return getString(fileSystemOptions, ROOTURI); 567 } 568 569 /** 570 * Gets a named option as a Short. 571 * 572 * @param fileSystemOptions file system options to query, may be null. 573 * @param name the option name 574 * @return the option in {@code opts} or system properties, otherwise null 575 * @see #getShort(FileSystemOptions, String, Short) 576 * @throws NumberFormatException if option value is not a valid short. 577 * @since 2.0 578 */ 579 protected Short getShort(final FileSystemOptions fileSystemOptions, final String name) { 580 return getShort(fileSystemOptions, name, null); 581 } 582 583 /** 584 * Gets a named option as a Short. 585 * 586 * @param fileSystemOptions file system options to query, may be null. 587 * @param name the option name 588 * @param defaultValue value to return if option is not present 589 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 590 * @see #getShort(FileSystemOptions, String, Short) 591 * @throws NumberFormatException if option value is not a valid short 592 * @since 2.0 593 */ 594 protected short getShort(final FileSystemOptions fileSystemOptions, final String name, final short defaultValue) { 595 return getShort(fileSystemOptions, name, Short.valueOf(defaultValue)).shortValue(); 596 } 597 598 /** 599 * Gets a named option as a Short. 600 * 601 * @param fileSystemOptions file system options to query, may be null. 602 * @param name the option name 603 * @param defaultValue value to return if option is not present 604 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 605 * @throws NumberFormatException if option value is not a valid short 606 * @since 2.0 607 */ 608 protected Short getShort(final FileSystemOptions fileSystemOptions, final String name, final Short defaultValue) { 609 return getParam(fileSystemOptions, name, defaultValue, Short::valueOf, Short.class); 610 } 611 612 /** 613 * Gets a named option as a String. 614 * 615 * @param fileSystemOptions file system options to query, may be null. 616 * @param name the option name 617 * @return the option in {@code opts} or system properties, otherwise null 618 * @see #getString(FileSystemOptions, String, String) 619 * @since 2.0 620 */ 621 protected String getString(final FileSystemOptions fileSystemOptions, final String name) { 622 return getString(fileSystemOptions, name, null); 623 } 624 625 /** 626 * Gets a named option as a String. 627 * 628 * @param fileSystemOptions file system options to query, may be null. 629 * @param name the option name 630 * @param defaultValue value to return if option is not present 631 * @return the option in {@code opts} or system properties, otherwise {@code defaultValue} 632 * @since 2.0 633 */ 634 protected String getString(final FileSystemOptions fileSystemOptions, final String name, 635 final String defaultValue) { 636 return getParam(fileSystemOptions, name, defaultValue, String::valueOf, String.class); 637 } 638 639 /** 640 * Checks the named setting specified. 641 * 642 * @param fileSystemOptions file system options to query, may be null. 643 * @param name the option to check in {@code opts} or system properties 644 * @return true if option exists 645 * @since 2.0 646 */ 647 protected boolean hasObject(final FileSystemOptions fileSystemOptions, final String name) { 648 return hasParam(fileSystemOptions, name) || System.getProperties().containsKey(toPropertyKey(name)); 649 } 650 651 /** 652 * Checks if option exists. 653 * 654 * @param fileSystemOptions file system options to query, may be null. 655 * @param name the name to look up in {@code opts} 656 * @return true if opts have the named parameter 657 * @since 1.0 658 */ 659 protected boolean hasParam(final FileSystemOptions fileSystemOptions, final String name) { 660 return fileSystemOptions != null && fileSystemOptions.hasOption(getConfigClass(), name); 661 } 662 663 /** 664 * Sets the named parameter. 665 * 666 * @param fileSystemOptions the file system options to modify 667 * @param name set option with this name 668 * @param value boolean value to set 669 * @since 2.1 670 */ 671 protected void setParam(final FileSystemOptions fileSystemOptions, final String name, final boolean value) { 672 setParam(fileSystemOptions, name, Boolean.valueOf(value)); 673 } 674 675 /** 676 * Sets the named parameter. 677 * 678 * @param fileSystemOptions the file system options to modify 679 * @param name set option with this name 680 * @param value object value to set 681 * @since 1.0 682 */ 683 protected void setParam(final FileSystemOptions fileSystemOptions, final String name, final Object value) { 684 Objects.requireNonNull(fileSystemOptions, "fileSystemOptions").setOption(getConfigClass(), name, value); 685 } 686 687 /** 688 * Sets the root URI of the file system. 689 * 690 * @param fileSystemOptions the file system options to modify 691 * @param rootURI The creator name to be associated with the file. 692 * @since 2.0 693 */ 694 public void setRootURI(final FileSystemOptions fileSystemOptions, final String rootURI) { 695 setParam(fileSystemOptions, ROOTURI, rootURI); 696 } 697 698 /** 699 * Converts the given primitive boolean to a Boolean object. 700 * 701 * @param value a primitive boolean. 702 * @return the given primitive boolean as Boolean object. 703 * @since 2.7.0 704 */ 705 protected Boolean toBooleanObject(final boolean value) { 706 return value ? Boolean.TRUE : Boolean.FALSE; 707 } 708 709 /** 710 * Converts the given name into a System property key. 711 * 712 * @param name a name to combine with the builder prefix 713 * @return name of system property 714 * @since 2.1 715 */ 716 private String toPropertyKey(final String name) { 717 return prefix + name; 718 } 719 720}