/** * Creates a new instance of a parameters object for file-based * configuration properties. * * @return the new parameters object */ public FileBasedBuilderParameters fileBased() { return createParametersProxy(new FileBasedBuilderParametersImpl(), FileBasedBuilderParameters.class); }
/** * Looks up an instance of this class in the specified parameters map and * optionally creates a new one if none is found. This method can be used to * obtain an instance of this class which has been stored in a parameters * map. It is compatible with the {@code getParameters()} method. * * @param params the map with parameters (must not be <b>null</b> * @param createIfMissing determines the behavior if no instance is found in * the map; if <b>true</b>, a new instance with default settings is * created; if <b>false</b>, <b>null</b> is returned * @return the instance obtained from the map or <b>null</b> * @throws IllegalArgumentException if the map is <b>null</b> */ public static FileBasedBuilderParametersImpl fromParameters( final Map<String, ?> params, final boolean createIfMissing) { if (params == null) { throw new IllegalArgumentException( "Parameters map must not be null!"); } FileBasedBuilderParametersImpl instance = (FileBasedBuilderParametersImpl) params.get(PARAM_KEY); if (instance == null && createIfMissing) { instance = new FileBasedBuilderParametersImpl(); } return instance; }
/** * Creates a new {@code FileBasedBuilderParametersImpl} object from the * content of the given map. While {@code fromParameters()} expects that an * object already exists and is stored in the given map, this method creates * a new instance based on the content of the map. The map can contain * properties of a {@code FileHandler} and some additional settings which * are stored directly in the newly created object. If the map is * <b>null</b>, an uninitialized instance is returned. * * @param map the map with properties (must not be <b>null</b>) * @return the newly created instance * @throws ClassCastException if the map contains invalid data */ public static FileBasedBuilderParametersImpl fromMap(final Map<String, ?> map) { final FileBasedBuilderParametersImpl params = new FileBasedBuilderParametersImpl(FileHandler.fromMap(map)); if (map != null) { params.setReloadingRefreshDelay((Long) map.get(PROP_REFRESH_DELAY)); params.setReloadingDetectorFactory((ReloadingDetectorFactory) map .get(PROP_DETECTOR_FACTORY)); } return params; }
/** * Obtains the {@code FileHandler} from this builder's parameters. If no * {@code FileBasedBuilderParametersImpl} object is found in this builder's * parameters, a new one is created now and stored. This makes it possible * to change the location of the associated file even if no parameters * object was provided. * * @return the {@code FileHandler} from initialization parameters */ private FileHandler fetchFileHandlerFromParameters() { FileBasedBuilderParametersImpl fileParams = FileBasedBuilderParametersImpl.fromParameters(getParameters(), false); if (fileParams == null) { fileParams = new FileBasedBuilderParametersImpl(); addParameters(fileParams.getParameters()); } return fileParams.getFileHandler(); }