Class ResourceUtils

java.lang.Object
org.springframework.geode.core.io.support.ResourceUtils

public abstract class ResourceUtils extends Object
Abstract utility class containing functionality to work with Resources.
Since:
1.3.1
See Also:
  • Resource
  • WritableResource
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.springframework.core.io.WritableResource
    asStrictlyWritableResource(org.springframework.core.io.Resource resource)
    Returns the Resource as a WritableResource if possible.
    static Optional<org.springframework.core.io.WritableResource>
    asWritableResource(org.springframework.core.io.Resource resource)
    Optionally return the Resource as a WritableResource.
    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 given Resource is readable.
    static boolean
    isWritable(org.springframework.core.io.Resource resource)
    Null-safe operation to determine whether the given Resource is writable.
    static String
    nullSafeGetDescription(org.springframework.core.io.Resource resource)
    Null-safe method to get the description of the given Resource.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 the Resource as a WritableResource if possible. This method makes a best effort to determine whether the target Resource is actually writable. Even still, it may be possible that a write to the target Resource will fail. The Resource is writable if the Resource is an instance of WritableResource and WritableResource.isWritable() returns true.
      Parameters:
      resource - Resource to cast to a WritableResource.
      Returns:
      a WritableResource from the target Resource if possible; never null.
      Throws:
      IllegalStateException - if the target Resource 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 the Resource as a WritableResource. The Resource must be an instance of WritableResource.
      Parameters:
      resource - Resource to cast to a WritableResource.
      Returns:
      the Resource as a WritableResource if the Resource is an instance of WritableResource, otherwise returns Optional.empty().
      See Also:
    • 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 given Resource 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 given Resource 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 the description of the given Resource.
      Parameters:
      resource - Resource to describe.
      Returns:
      a description of the Resource, or null if the Resource handle is null.
      See Also:
      • Resource