Spring Boot for VMware GemFire
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:
-
ResourceWritableResource
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.core.io.WritableResourceasStrictlyWritableResource(org.springframework.core.io.Resource resource) Returns theResourceas aWritableResourceif possible.static Optional<org.springframework.core.io.WritableResource>asWritableResource(org.springframework.core.io.Resource resource) static booleanisNotEmpty(byte[] array) Determines whether the given byte array is null or empty.static booleanisReadable(org.springframework.core.io.Resource resource) Null-safe operation to determine whether the givenResourceis readable.static booleanisWritable(org.springframework.core.io.Resource resource) Null-safe operation to determine whether the givenResourceis writable.static StringnullSafeGetDescription(org.springframework.core.io.Resource resource) Null-safe method to get thedescriptionof 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 theResourceas aWritableResourceif possible. This method makes a best effort to determine whether the targetResourceis actually writable. Even still, it may be possible that a write to the targetResourcewill fail. TheResourceis writable if theResourceis an instance ofWritableResourceandWritableResource.isWritable()returns true.- Parameters:
resource-Resourceto cast to aWritableResource.- Returns:
- a
WritableResourcefrom the targetResourceif possible; never null. - Throws:
IllegalStateException- if the targetResourceis not writable.- See Also:
-
WritableResourceResource
-
asWritableResource
public static Optional<org.springframework.core.io.WritableResource> asWritableResource(@Nullable org.springframework.core.io.Resource resource) Optionallyreturn theResourceas aWritableResource. TheResourcemust be an instance ofWritableResource.- Parameters:
resource-Resourceto cast to aWritableResource.- Returns:
- the
Resourceas aWritableResourceif theResourceis an instance ofWritableResource, otherwise returnsOptional.empty(). - See Also:
-
WritableResourceResourceOptional
-
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 givenResourceis readable.- Parameters:
resource-Resourceto evaluate.- Returns:
- a boolean value indicating whether the given
Resourceis 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 givenResourceis writable.- Parameters:
resource-Resourceto evaluate.- Returns:
- a boolean value indicating whether the given
Resourceis writable. - See Also:
-
WritableResource.isWritable()WritableResourceResource
-
nullSafeGetDescription
@Nullable public static String nullSafeGetDescription(@Nullable org.springframework.core.io.Resource resource) Null-safe method to get thedescriptionof the givenResource.- Parameters:
resource-Resourceto describe.- Returns:
- a
descriptionof theResource, or null if theResourcehandle is null. - See Also:
-
Resource
-