001 002package com.commercetools.ml.models.similar_products; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007import java.util.stream.Collectors; 008 009import javax.annotation.Nullable; 010import javax.validation.Valid; 011import javax.validation.constraints.NotNull; 012 013import com.fasterxml.jackson.annotation.*; 014import com.fasterxml.jackson.databind.annotation.*; 015 016import io.vrap.rmf.base.client.utils.Generated; 017 018/** 019 * <p>A pair of SimilarProducts</p> 020 * 021 * <hr> 022 * Example to create an instance using the builder pattern 023 * <div class=code-example> 024 * <pre><code class='java'> 025 * SimilarProductPair similarProductPair = SimilarProductPair.builder() 026 * .confidence(0.3) 027 * .plusProducts(productsBuilder -> productsBuilder) 028 * .build() 029 * </code></pre> 030 * </div> 031 */ 032@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 033@JsonDeserialize(as = SimilarProductPairImpl.class) 034public interface SimilarProductPair { 035 036 /** 037 * <p>The probability of product similarity.</p> 038 * @return confidence 039 */ 040 @NotNull 041 @JsonProperty("confidence") 042 public Double getConfidence(); 043 044 /** 045 * 046 * @return products 047 */ 048 @NotNull 049 @Valid 050 @JsonProperty("products") 051 public List<SimilarProduct> getProducts(); 052 053 /** 054 * <p>The probability of product similarity.</p> 055 * @param confidence value to be set 056 */ 057 058 public void setConfidence(final Double confidence); 059 060 /** 061 * set products 062 * @param products values to be set 063 */ 064 065 @JsonIgnore 066 public void setProducts(final SimilarProduct... products); 067 068 /** 069 * set products 070 * @param products values to be set 071 */ 072 073 public void setProducts(final List<SimilarProduct> products); 074 075 /** 076 * factory method 077 * @return instance of SimilarProductPair 078 */ 079 public static SimilarProductPair of() { 080 return new SimilarProductPairImpl(); 081 } 082 083 /** 084 * factory method to create a shallow copy SimilarProductPair 085 * @param template instance to be copied 086 * @return copy instance 087 */ 088 public static SimilarProductPair of(final SimilarProductPair template) { 089 SimilarProductPairImpl instance = new SimilarProductPairImpl(); 090 instance.setConfidence(template.getConfidence()); 091 instance.setProducts(template.getProducts()); 092 return instance; 093 } 094 095 /** 096 * factory method to create a deep copy of SimilarProductPair 097 * @param template instance to be copied 098 * @return copy instance 099 */ 100 @Nullable 101 public static SimilarProductPair deepCopy(@Nullable final SimilarProductPair template) { 102 if (template == null) { 103 return null; 104 } 105 SimilarProductPairImpl instance = new SimilarProductPairImpl(); 106 instance.setConfidence(template.getConfidence()); 107 instance.setProducts(Optional.ofNullable(template.getProducts()) 108 .map(t -> t.stream() 109 .map(com.commercetools.ml.models.similar_products.SimilarProduct::deepCopy) 110 .collect(Collectors.toList())) 111 .orElse(null)); 112 return instance; 113 } 114 115 /** 116 * builder factory method for SimilarProductPair 117 * @return builder 118 */ 119 public static SimilarProductPairBuilder builder() { 120 return SimilarProductPairBuilder.of(); 121 } 122 123 /** 124 * create builder for SimilarProductPair instance 125 * @param template instance with prefilled values for the builder 126 * @return builder 127 */ 128 public static SimilarProductPairBuilder builder(final SimilarProductPair template) { 129 return SimilarProductPairBuilder.of(template); 130 } 131 132 /** 133 * accessor map function 134 * @param <T> mapped type 135 * @param helper function to map the object 136 * @return mapped value 137 */ 138 default <T> T withSimilarProductPair(Function<SimilarProductPair, T> helper) { 139 return helper.apply(this); 140 } 141 142 /** 143 * gives a TypeReference for usage with Jackson DataBind 144 * @return TypeReference 145 */ 146 public static com.fasterxml.jackson.core.type.TypeReference<SimilarProductPair> typeReference() { 147 return new com.fasterxml.jackson.core.type.TypeReference<SimilarProductPair>() { 148 @Override 149 public String toString() { 150 return "TypeReference<SimilarProductPair>"; 151 } 152 }; 153 } 154}