From 55d0920a9c0c98e98fa1938c6903151647811ef2 Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 5 Dec 2019 22:20:13 -0800 Subject: [PATCH] Added JavaDoc to AddonRequestBuilder --- .../addons/request/AddonRequestBuilder.java | 99 ++++++++++--------- 1 file changed, 53 insertions(+), 46 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/addons/request/AddonRequestBuilder.java b/src/main/java/world/bentobox/bentobox/api/addons/request/AddonRequestBuilder.java index 8ac383913..e5fde808e 100644 --- a/src/main/java/world/bentobox/bentobox/api/addons/request/AddonRequestBuilder.java +++ b/src/main/java/world/bentobox/bentobox/api/addons/request/AddonRequestBuilder.java @@ -9,57 +9,64 @@ import org.apache.commons.lang.Validate; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.addons.Addon; +/** + * API to enable plugins to request data from addons. + * Addons can expose data that they want to expose. To access it, call this class with the appropriate addon name, the label for the + * data that is requested and if required, a map of key-value pairs that will be given to the addon. + * @author HyKurtis + * + */ public class AddonRequestBuilder { - private String addonName; - private String requestLabel; - private Map metaData = new HashMap<>(); + private String addonName; + private String requestLabel; + private Map metaData = new HashMap<>(); - /** - * Define the addon you wish to request. - * - * @param addonName addon name - */ - public AddonRequestBuilder addon(String addonName) { - this.addonName = addonName; - return this; - } + /** + * Define the addon you wish to request. + * + * @param addonName addon name + */ + public AddonRequestBuilder addon(String addonName) { + this.addonName = addonName; + return this; + } - /** - * Define label for addon request. - * - * @param requestLabel request label - */ - public AddonRequestBuilder label(String requestLabel) { - this.requestLabel = requestLabel; - return this; - } + /** + * Define label for addon request. + * + * @param requestLabel request label + */ + public AddonRequestBuilder label(String requestLabel) { + this.requestLabel = requestLabel; + return this; + } - /** - * Add meta data to addon request. - * - * @param key key - * @param value value - */ - public AddonRequestBuilder addMetaData(String key, Object value) { - metaData.put(key, value); - return this; - } + /** + * Add meta data to addon request. + * + * @param key key + * @param value value + */ + public AddonRequestBuilder addMetaData(String key, Object value) { + metaData.put(key, value); + return this; + } - /** - * Send request to addon. - * - * @return request response, null if no response. - */ - public Object request() { - Validate.notNull(addonName); - Validate.notNull(requestLabel); + /** + * Send request to addon. + * + * @return request response, null if no response. + */ + public Object request() { + Validate.notNull(addonName); + Validate.notNull(requestLabel); - Optional addonOptional = BentoBox.getInstance().getAddonsManager().getAddonByName(addonName); - if(addonOptional.isPresent()) { - Addon addon = addonOptional.get(); - return addon.request(requestLabel, metaData); - } - return null; - } + Optional addonOptional = BentoBox.getInstance().getAddonsManager().getAddonByName(addonName); + if(addonOptional.isPresent()) { + Addon addon = addonOptional.get(); + return addon.request(requestLabel, metaData); + } + return null; + } }