/** * Obtains a non <b>null</b> {@code FileLocationStrategy} object from the * passed in {@code FileLocator}. If the {@code FileLocator} is not * <b>null</b> and has a {@code FileLocationStrategy} defined, this strategy * is returned. Otherwise, result is the default * {@code FileLocationStrategy}. * * @param locator the {@code FileLocator} * @return the {@code FileLocationStrategy} for this {@code FileLocator} */ static FileLocationStrategy obtainLocationStrategy(final FileLocator locator) { return (locator != null) ? ObjectUtils.defaultIfNull( locator.getLocationStrategy(), DEFAULT_LOCATION_STRATEGY) : DEFAULT_LOCATION_STRATEGY; }
/** * Returns a hash code for this object. * * @return a hash code for this object */ @Override public int hashCode() { return new HashCodeBuilder().append(getFileName()) .append(getBasePath()).append(sourceURLAsString()) .append(getEncoding()).append(getFileSystem()) .append(getLocationStrategy()).toHashCode(); }
/** * Returns a string representation of this object. This string contains the * values of all properties. * * @return a string for this object */ @Override public String toString() { return new ToStringBuilder(this).append("fileName", getFileName()) .append("basePath", getBasePath()) .append("sourceURL", sourceURLAsString()) .append("encoding", getEncoding()) .append("fileSystem", getFileSystem()) .append("locationStrategy", getLocationStrategy()).toString(); }
/** * Stores the specified {@code FileLocator} in the given map. With the * {@link #fromMap(Map)} method a new {@code FileLocator} with the same * properties as the original one can be created. * * @param locator the {@code FileLocator} to be stored * @param map the map in which to store the {@code FileLocator} (must not be * <b>null</b>) * @throws IllegalArgumentException if the map is <b>null</b> */ public static void put(final FileLocator locator, final Map<String, Object> map) { if (map == null) { throw new IllegalArgumentException("Map must not be null!"); } if (locator != null) { map.put(PROP_BASE_PATH, locator.getBasePath()); map.put(PROP_ENCODING, locator.getEncoding()); map.put(PROP_FILE_NAME, locator.getFileName()); map.put(PROP_FILE_SYSTEM, locator.getFileSystem()); map.put(PROP_SOURCE_URL, locator.getSourceURL()); map.put(PROP_STRATEGY, locator.getLocationStrategy()); } }
/** * Compares this object with another one. Two instances of * {@code FileLocatorImpl} are considered equal if all of their properties * are equal. * * @param obj the object to compare to * @return a flag whether these objects are equal */ @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (!(obj instanceof FileLocator)) { return false; } final FileLocator c = (FileLocator) obj; return new EqualsBuilder().append(getFileName(), c.getFileName()) .append(getBasePath(), c.getBasePath()) .append(sourceURLAsString(), c.sourceURLAsString()) .append(getEncoding(), c.getEncoding()) .append(getFileSystem(), c.getFileSystem()) .append(getLocationStrategy(), c.getLocationStrategy()) .isEquals(); }
/** * Initializes the properties of this builder from the passed in locator * object. * * @param src the source {@code FileLocator} */ private void initBuilder(final FileLocator src) { basePath = src.getBasePath(); fileName = src.getFileName(); sourceURL = src.getSourceURL(); encoding = src.getEncoding(); fileSystem = src.getFileSystem(); locationStrategy = src.getLocationStrategy(); } }