Class ResourceUtils
java.lang.Object
org.springframework.geode.core.io.support.ResourceUtils
Abstract utility class containing functionality to work with
Resources
.- Since:
- 1.3.1
- See Also:
-
Resource
WritableResource
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.core.io.WritableResource
asStrictlyWritableResource
(org.springframework.core.io.Resource resource) Returns theResource
as aWritableResource
if possible.static Optional<org.springframework.core.io.WritableResource>
asWritableResource
(org.springframework.core.io.Resource resource) static boolean
isNotEmpty
(byte[] array) Determines whether the given byte array is null or empty.static boolean
isReadable
(org.springframework.core.io.Resource resource) Null-safe operation to determine whether the givenResource
is readable.static boolean
isWritable
(org.springframework.core.io.Resource resource) Null-safe operation to determine whether the givenResource
is writable.static String
nullSafeGetDescription
(org.springframework.core.io.Resource resource) Null-safe method to get thedescription
of the givenResource
.
-
Constructor Details
-
ResourceUtils
public ResourceUtils()
-
-
Method Details
-
asStrictlyWritableResource
@NonNull public static org.springframework.core.io.WritableResource asStrictlyWritableResource(@Nullable org.springframework.core.io.Resource resource) Returns theResource
as aWritableResource
if possible. This method makes a best effort to determine whether the targetResource
is actually writable. Even still, it may be possible that a write to the targetResource
will fail. TheResource
is writable if theResource
is an instance ofWritableResource
andWritableResource.isWritable()
returns true.- Parameters:
resource
-Resource
to cast to aWritableResource
.- Returns:
- a
WritableResource
from the targetResource
if possible; never null. - Throws:
IllegalStateException
- if the targetResource
is not writable.- See Also:
-
WritableResource
Resource
-
asWritableResource
public static Optional<org.springframework.core.io.WritableResource> asWritableResource(@Nullable org.springframework.core.io.Resource resource) Optionally
return theResource
as aWritableResource
. TheResource
must be an instance ofWritableResource
.- Parameters:
resource
-Resource
to cast to aWritableResource
.- Returns:
- the
Resource
as aWritableResource
if theResource
is an instance ofWritableResource
, otherwise returnsOptional.empty()
. - See Also:
-
WritableResource
Resource
Optional
-
isNotEmpty
public static boolean isNotEmpty(@Nullable byte[] array) Determines whether the given byte array is null or empty.- Parameters:
array
- byte array to evaluate.- Returns:
- a boolean value indicating whether the given byte array is null or empty.
-
isReadable
public static boolean isReadable(@Nullable org.springframework.core.io.Resource resource) Null-safe operation to determine whether the givenResource
is readable.- Parameters:
resource
-Resource
to evaluate.- Returns:
- a boolean value indicating whether the given
Resource
is readable. - See Also:
-
Resource.isReadable()
Resource
-
isWritable
public static boolean isWritable(@Nullable org.springframework.core.io.Resource resource) Null-safe operation to determine whether the givenResource
is writable.- Parameters:
resource
-Resource
to evaluate.- Returns:
- a boolean value indicating whether the given
Resource
is writable. - See Also:
-
WritableResource.isWritable()
WritableResource
Resource
-
nullSafeGetDescription
@Nullable public static String nullSafeGetDescription(@Nullable org.springframework.core.io.Resource resource) Null-safe method to get thedescription
of the givenResource
.- Parameters:
resource
-Resource
to describe.- Returns:
- a
description
of theResource
, or null if theResource
handle is null. - See Also:
-
Resource
-