ResourceRegion fits better in core.io.support (next to EncodedResource)
Issue: SPR-14221
This commit is contained in:
@@ -14,15 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core.io;
|
||||
package org.springframework.core.io.support;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Region of a {@link Resource} implementation, materialized by a {@code position}
|
||||
* within the {@link Resource} and a byte {@code count} for the length of that region.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.3.0
|
||||
* @since 4.3
|
||||
*/
|
||||
public class ResourceRegion {
|
||||
|
||||
@@ -32,16 +34,17 @@ public class ResourceRegion {
|
||||
|
||||
private final long count;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new {@code ResourceRegion} from a given {@link Resource}.
|
||||
* This region of a resource is reprensented by a start {@code position}
|
||||
* This region of a resource is represented by a start {@code position}
|
||||
* and a byte {@code count} within the given {@code Resource}.
|
||||
* @param resource a Resource
|
||||
* @param position the start position of the region in that resource
|
||||
* @param count the byte count of the region in that resource
|
||||
*/
|
||||
public ResourceRegion(Resource resource, long position, long count) {
|
||||
Assert.notNull(resource, "'resource' must not be null");
|
||||
Assert.notNull(resource, "Resource must not be null");
|
||||
Assert.isTrue(position >= 0, "'position' must be larger than or equal to 0");
|
||||
Assert.isTrue(count >= 0, "'count' must be larger than or equal to 0");
|
||||
this.resource = resource;
|
||||
@@ -49,6 +52,7 @@ public class ResourceRegion {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the underlying {@link Resource} for this {@code ResourceRegion}
|
||||
*/
|
||||
@@ -69,4 +73,5 @@ public class ResourceRegion {
|
||||
public long getCount() {
|
||||
return this.count;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user