java.lang.Object
net.ygbstudio.powerwp4j.base.extension.builders.AbstractPayloadBuilder<T>
Type Parameters:
T - the concrete payload builder subtype
Direct Known Subclasses:
WPBasicPayloadBuilder
public abstract class AbstractPayloadBuilder<T extends AbstractPayloadBuilder<T>>
extends Object
Abstract class for payload builders that can be used to simplify the process of building payloads
for the WordPress REST API. From this class, you can create your own payload builders that can be
used to interact with the methods provided by the
HttpRequestService class.
Methods that return the payload builder are chainable and inherited by all subclasses, so that
builders can relay on the same behaviour or specialize it for their specific needs.
Note that it is possible to reuse the same builder in cases where your flow requires it. To do
that, call clear() before building a new payload. The
clear operation is chainable so you can start your builder with it and chain the elements you
need after a clean start.
See Also:
Field Summary
Fields
Category IDs associated with the payload.
WordPress comment status value.
Taxonomy description for taxonomy payloads.
Featured media attachment ID.
WordPress post format value.
Taxonomy name for taxonomy payloads.
Password for password-protected content.
URL slug for the payload.
WordPress post status value.
Whether the post is sticky.
Tag IDs associated with the payload.
WordPress post type value.
Constructor Summary
Constructors
protected
Creates an empty payload builder base.
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods
abstract tools.jackson.databind.JsonNode
Builds the payload as a JsonNode.
Resets all fields of the builder to their initial state.
Returns the current instance of the payload builder.
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
Field Details
author
WordPress author ID.
status
WordPress post status value.
type
WordPress post type value.
categories
Category IDs associated with the payload.
slug
URL slug for the payload.
name
Taxonomy name for taxonomy payloads.
description
Taxonomy description for taxonomy payloads.
password
Password for password-protected content.
sticky
Whether the post is sticky.
Constructor Details
AbstractPayloadBuilder
protected AbstractPayloadBuilder ()
Creates an empty payload builder base.
Method Details
self
Returns the current instance of the payload builder. This is a protected method used for
chaining method calls.
The cast to type T is safe because the method is only called within the class hierarchy and
this class is parameterized with the type of the subclass.
Returns:
the current instance of the payload builder
status
Sets the post status.
Parameters:
postStatus - the post status to set
Returns:
the payload builder
type
Sets the post type.
Parameters:
postType - the post type to set
Returns:
the payload builder
format
Sets the post format.
Parameters:
postFormat - the post format to set
Returns:
the payload builder
categories
public T categories (@NotNull
@NotNull List <Integer > categories)
Sets the categories.
Parameters:
categories - the categories to set
Returns:
the payload builder
slug
public T slug (@NotNull
@NotNull String slug)
Sets the slug.
Parameters:
slug - the slug to set
Returns:
the payload builder
name
public T name (@NotNull
@NotNull String name)
Sets the name.
Parameters:
name - the name to set
Returns:
the payload builder
description
public T description (@NotNull
@NotNull String description)
Sets the description.
Parameters:
description - the description to set
Returns:
the payload builder
title
public T title (@NotNull
@NotNull String title)
Sets the title.
Parameters:
title - the title to set
Returns:
the payload builder
content
public T content (@NotNull
@NotNull String content)
Sets the content.
Parameters:
content - the content to set
Returns:
the payload builder
excerpt
public T excerpt (@NotNull
@NotNull String excerpt)
Sets the excerpt.
Parameters:
excerpt - the excerpt to set
Returns:
the payload builder
author
public T author (@NotNull
@NotNull Integer author)
Sets the author.
Parameters:
author - the author to set
Returns:
the payload builder
password
public T password (@NotNull
@NotNull String password)
Sets the password.
Parameters:
password - the password to set
Returns:
the payload builder
sticky
public T sticky (@NotNull
@NotNull Boolean sticky)
Sets the sticky status.
Parameters:
sticky - the sticky status to set
Returns:
the payload builder
clear
Resets all fields of the builder to their initial state. This method is marked as final to
ensure consistent behavior across all subclasses. Collections are cleared rather than set to
null to prevent memory leaks.
Returns:
the current builder instance for method chaining
See Also:
build
public abstract tools.jackson.databind.JsonNode build ()
Builds the payload as a JsonNode.
Returns:
the built payload as a JsonNode