java.lang.Object
org.springframework.data.rest.webmvc.json.patch.Patch
All Implemented Interfaces:
Iterable<PatchOperation>, Supplier<Stream<PatchOperation>>, org.springframework.data.util.Streamable<PatchOperation>

public class Patch extends Object implements org.springframework.data.util.Streamable<PatchOperation>

Represents a Patch.

This class (and PatchOperation capture the definition of a patch, but are not coupled to any specific patch representation.

Author:
Craig Walls, Oliver Gierke
  • Constructor Details

  • Method Details

    • size

      public int size()
      Returns:
      the number of operations that make up this patch.
    • apply

      public <T> T apply(T in, Class<T> type) throws PatchException
      Applies the Patch to a given Object graph. Makes a copy of the given object so that it will remain unchanged after application of the patch and in case any errors occur while performing the patch.
      Type Parameters:
      T - the object type.
      Parameters:
      in - The object graph to apply the patch to.
      type - The object type.
      Returns:
      An object graph modified by the patch.
      Throws:
      PatchException - if there are any errors while applying the patch.
    • apply

      public <T> List<T> apply(List<T> in, Class<T> type) throws PatchException
      Applies the Patch to a given List of objects. Makes a copy of the given list so that it will remain unchanged after application of the patch and in case any errors occur while performing the patch.
      Type Parameters:
      T - the list's generic type.
      Parameters:
      in - The list to apply the patch to.
      type - The list's generic type.
      Returns:
      An list modified by the patch.
      Throws:
      PatchException - if there are any errors while applying the patch.
    • iterator

      public Iterator<PatchOperation> iterator()
      Specified by:
      iterator in interface Iterable<PatchOperation>