001 002package com.commercetools.ml.models.image_search; 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>Response format from image search endpoint.</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 * ImageSearchResponse imageSearchResponse = ImageSearchResponse.builder() 026 * .count(0.3) 027 * .offset(0.3) 028 * .total(0.3) 029 * .plusResults(resultsBuilder -> resultsBuilder) 030 * .build() 031 * </code></pre> 032 * </div> 033 */ 034@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 035@JsonDeserialize(as = ImageSearchResponseImpl.class) 036public interface ImageSearchResponse { 037 038 /** 039 * <p>The maximum number of results to return from a query.</p> 040 * @return count 041 */ 042 @NotNull 043 @JsonProperty("count") 044 public Integer getCount(); 045 046 /** 047 * <p>Number of elements skipped.</p> 048 * @return offset 049 */ 050 @NotNull 051 @JsonProperty("offset") 052 public Double getOffset(); 053 054 /** 055 * <p>The total number of product images that were have been analyzed.</p> 056 * @return total 057 */ 058 @NotNull 059 @JsonProperty("total") 060 public Integer getTotal(); 061 062 /** 063 * <p>An array of image URLs of images that are similar to the query image. If no matching images are found, results is empty.</p> 064 * @return results 065 */ 066 @NotNull 067 @Valid 068 @JsonProperty("results") 069 public List<ResultItem> getResults(); 070 071 /** 072 * <p>The maximum number of results to return from a query.</p> 073 * @param count value to be set 074 */ 075 076 public void setCount(final Integer count); 077 078 /** 079 * <p>Number of elements skipped.</p> 080 * @param offset value to be set 081 */ 082 083 public void setOffset(final Double offset); 084 085 /** 086 * <p>The total number of product images that were have been analyzed.</p> 087 * @param total value to be set 088 */ 089 090 public void setTotal(final Integer total); 091 092 /** 093 * <p>An array of image URLs of images that are similar to the query image. If no matching images are found, results is empty.</p> 094 * @param results values to be set 095 */ 096 097 @JsonIgnore 098 public void setResults(final ResultItem... results); 099 100 /** 101 * <p>An array of image URLs of images that are similar to the query image. If no matching images are found, results is empty.</p> 102 * @param results values to be set 103 */ 104 105 public void setResults(final List<ResultItem> results); 106 107 /** 108 * factory method 109 * @return instance of ImageSearchResponse 110 */ 111 public static ImageSearchResponse of() { 112 return new ImageSearchResponseImpl(); 113 } 114 115 /** 116 * factory method to create a shallow copy ImageSearchResponse 117 * @param template instance to be copied 118 * @return copy instance 119 */ 120 public static ImageSearchResponse of(final ImageSearchResponse template) { 121 ImageSearchResponseImpl instance = new ImageSearchResponseImpl(); 122 instance.setCount(template.getCount()); 123 instance.setOffset(template.getOffset()); 124 instance.setTotal(template.getTotal()); 125 instance.setResults(template.getResults()); 126 return instance; 127 } 128 129 /** 130 * factory method to create a deep copy of ImageSearchResponse 131 * @param template instance to be copied 132 * @return copy instance 133 */ 134 @Nullable 135 public static ImageSearchResponse deepCopy(@Nullable final ImageSearchResponse template) { 136 if (template == null) { 137 return null; 138 } 139 ImageSearchResponseImpl instance = new ImageSearchResponseImpl(); 140 instance.setCount(template.getCount()); 141 instance.setOffset(template.getOffset()); 142 instance.setTotal(template.getTotal()); 143 instance.setResults(Optional.ofNullable(template.getResults()) 144 .map(t -> t.stream() 145 .map(com.commercetools.ml.models.image_search.ResultItem::deepCopy) 146 .collect(Collectors.toList())) 147 .orElse(null)); 148 return instance; 149 } 150 151 /** 152 * builder factory method for ImageSearchResponse 153 * @return builder 154 */ 155 public static ImageSearchResponseBuilder builder() { 156 return ImageSearchResponseBuilder.of(); 157 } 158 159 /** 160 * create builder for ImageSearchResponse instance 161 * @param template instance with prefilled values for the builder 162 * @return builder 163 */ 164 public static ImageSearchResponseBuilder builder(final ImageSearchResponse template) { 165 return ImageSearchResponseBuilder.of(template); 166 } 167 168 /** 169 * accessor map function 170 * @param <T> mapped type 171 * @param helper function to map the object 172 * @return mapped value 173 */ 174 default <T> T withImageSearchResponse(Function<ImageSearchResponse, T> helper) { 175 return helper.apply(this); 176 } 177 178 /** 179 * gives a TypeReference for usage with Jackson DataBind 180 * @return TypeReference 181 */ 182 public static com.fasterxml.jackson.core.type.TypeReference<ImageSearchResponse> typeReference() { 183 return new com.fasterxml.jackson.core.type.TypeReference<ImageSearchResponse>() { 184 @Override 185 public String toString() { 186 return "TypeReference<ImageSearchResponse>"; 187 } 188 }; 189 } 190}