Class WPPayloadNodeBuilder


public class WPPayloadNodeBuilder extends AbstractPayloadNodeBuilder<WPPayloadNodeBuilder>
This class is a specialized builder for constructing JSON payloads in the format used by the WordPress REST API. It provides a fluent interface for creating JSON payloads by adding properties to the internal ObjectNode.

This class is parameterized with the type of the concrete subclass. This allows subclasses to define their own type while still being able to use the common functionality provided by this class.

This class is an extension of AbstractPayloadNodeBuilder and provides additional methods for setting properties specific to the WordPress REST API.

  • Method Details

    • builder

      @Contract(" -> new") @NotNull public static @NotNull WPPayloadNodeBuilder builder()
      Returns a new instance of the payload node builder.
      Returns:
      a new instance of the payload node builder
    • author

      public WPPayloadNodeBuilder author(int authorInt)
      Sets the author.
      Parameters:
      authorInt - the author to set
      Returns:
      the payload node builder
    • status

      public WPPayloadNodeBuilder status(PostStatusEnum status)
      Sets the post status.
      Parameters:
      status - the post status to set
      Returns:
      the payload node builder
    • type

      public WPPayloadNodeBuilder type(PostTypeEnum type)
      Sets the post type.
      Parameters:
      type - the post type to set
      Returns:
      the payload node builder
    • format

      public WPPayloadNodeBuilder format(PostFormatEnum format)
      Sets the post format.
      Parameters:
      format - the post format to set
      Returns:
      the payload node builder
    • commentStatus

      public WPPayloadNodeBuilder commentStatus(CommentStatusEnum status)
      Sets the comment status.
      Parameters:
      status - the comment status to set
      Returns:
      the payload node builder
    • categories

      public <T extends Number> WPPayloadNodeBuilder categories(@NotNull @NotNull List<T> categories)
      Sets the categories.
      Type Parameters:
      T - the numeric type of the categories
      Parameters:
      categories - the categories to set
      Returns:
      the payload node builder
    • tags

      public <T extends Number> WPPayloadNodeBuilder tags(@NotNull @NotNull List<T> tags)
      Sets the tags.
      Type Parameters:
      T - the numeric type of the tags
      Parameters:
      tags - the tags to set
      Returns:
      the payload node builder
    • categories

      public <T, U extends Number> WPPayloadNodeBuilder categories(@NotNull @NotNull Set<WPClassMapping<T,U>> categoriesMappingSet)
      Sets the categories using a set of WPClassMapping objects.
      Type Parameters:
      T - the type of the key in each class mapping object
      U - the numeric type of the category values in the WPClassMapping objects
      Parameters:
      categoriesMappingSet - the set of WPClassMapping objects representing the categories
      Returns:
      the payload node builder
    • tags

      public <T, U extends Number> WPPayloadNodeBuilder tags(@NotNull @NotNull Set<WPClassMapping<T,U>> tagsMappingSet)
      Sets the tags using a set of WPClassMapping objects.
      Type Parameters:
      T - the type of the key in each class mapping object
      U - the numeric type of the tag values in the WPClassMapping objects
      Parameters:
      tagsMappingSet - the set of WPClassMapping objects representing the tags
      Returns:
      the payload node builder
    • slug

      public WPPayloadNodeBuilder slug(String slug)
      Sets the slug.
      Parameters:
      slug - the slug to set
      Returns:
      the payload node builder
    • description

      public WPPayloadNodeBuilder description(String description)
      Sets the description.
      Parameters:
      description - the description to set
      Returns:
      the payload node builder
    • title

      public WPPayloadNodeBuilder title(String title)
      Sets the title.
      Parameters:
      title - the title to set
      Returns:
      the payload node builder
    • content

      public WPPayloadNodeBuilder content(String content)
      Sets the content.
      Parameters:
      content - the content to set
      Returns:
      the payload node builder
    • excerpt

      public WPPayloadNodeBuilder excerpt(String excerpt)
      Sets the excerpt.
      Parameters:
      excerpt - the excerpt to set
      Returns:
      the payload node builder
    • sticky

      public WPPayloadNodeBuilder sticky(boolean sticky)
      Sets the sticky flag.
      Parameters:
      sticky - the sticky flag to set
      Returns:
      the payload node builder
    • featuredMedia

      public WPPayloadNodeBuilder featuredMedia(int featuredMediaId)
      Sets the featured media.
      Parameters:
      featuredMediaId - the featured media to set
      Returns:
      the payload node builder