001 002package com.commercetools.api.models.extension; 003 004import java.util.*; 005import java.util.function.Function; 006 007import javax.annotation.Nullable; 008 009import io.vrap.rmf.base.client.Builder; 010import io.vrap.rmf.base.client.utils.Generated; 011 012/** 013 * HttpDestinationBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * HttpDestination httpDestination = HttpDestination.builder() 019 * .url("{url}") 020 * .build() 021 * </code></pre> 022 * </div> 023 */ 024@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 025public class HttpDestinationBuilder implements Builder<HttpDestination> { 026 027 private String url; 028 029 @Nullable 030 private com.commercetools.api.models.extension.HttpDestinationAuthentication authentication; 031 032 /** 033 * <p>URL to the target destination. If the Project is hosted in the China (AWS, Ningxia) Region, verify that the URL is not blocked due to firewall restrictions.</p> 034 * @param url value to be set 035 * @return Builder 036 */ 037 038 public HttpDestinationBuilder url(final String url) { 039 this.url = url; 040 return this; 041 } 042 043 /** 044 * <p>Authentication methods (such as <code>Basic</code> or <code>Bearer</code>).</p> 045 * @param authentication value to be set 046 * @return Builder 047 */ 048 049 public HttpDestinationBuilder authentication( 050 @Nullable final com.commercetools.api.models.extension.HttpDestinationAuthentication authentication) { 051 this.authentication = authentication; 052 return this; 053 } 054 055 /** 056 * <p>Authentication methods (such as <code>Basic</code> or <code>Bearer</code>).</p> 057 * @param builder function to build the authentication value 058 * @return Builder 059 */ 060 061 public HttpDestinationBuilder authentication( 062 Function<com.commercetools.api.models.extension.HttpDestinationAuthenticationBuilder, Builder<? extends com.commercetools.api.models.extension.HttpDestinationAuthentication>> builder) { 063 this.authentication = builder 064 .apply(com.commercetools.api.models.extension.HttpDestinationAuthenticationBuilder.of()) 065 .build(); 066 return this; 067 } 068 069 /** 070 * <p>URL to the target destination. If the Project is hosted in the China (AWS, Ningxia) Region, verify that the URL is not blocked due to firewall restrictions.</p> 071 * @return url 072 */ 073 074 public String getUrl() { 075 return this.url; 076 } 077 078 /** 079 * <p>Authentication methods (such as <code>Basic</code> or <code>Bearer</code>).</p> 080 * @return authentication 081 */ 082 083 @Nullable 084 public com.commercetools.api.models.extension.HttpDestinationAuthentication getAuthentication() { 085 return this.authentication; 086 } 087 088 /** 089 * builds HttpDestination with checking for non-null required values 090 * @return HttpDestination 091 */ 092 public HttpDestination build() { 093 Objects.requireNonNull(url, HttpDestination.class + ": url is missing"); 094 return new HttpDestinationImpl(url, authentication); 095 } 096 097 /** 098 * builds HttpDestination without checking for non-null required values 099 * @return HttpDestination 100 */ 101 public HttpDestination buildUnchecked() { 102 return new HttpDestinationImpl(url, authentication); 103 } 104 105 /** 106 * factory method for an instance of HttpDestinationBuilder 107 * @return builder 108 */ 109 public static HttpDestinationBuilder of() { 110 return new HttpDestinationBuilder(); 111 } 112 113 /** 114 * create builder for HttpDestination instance 115 * @param template instance with prefilled values for the builder 116 * @return builder 117 */ 118 public static HttpDestinationBuilder of(final HttpDestination template) { 119 HttpDestinationBuilder builder = new HttpDestinationBuilder(); 120 builder.url = template.getUrl(); 121 builder.authentication = template.getAuthentication(); 122 return builder; 123 } 124 125}