001 002package com.commercetools.api.models.product; 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 * TermFacetResult 020 * 021 * <hr> 022 * Example to create an instance using the builder pattern 023 * <div class=code-example> 024 * <pre><code class='java'> 025 * TermFacetResult termFacetResult = TermFacetResult.builder() 026 * .dataType(TermFacetResultType.TEXT) 027 * .missing(0.3) 028 * .total(0.3) 029 * .other(0.3) 030 * .plusTerms(termsBuilder -> termsBuilder) 031 * .build() 032 * </code></pre> 033 * </div> 034 */ 035@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 036@JsonDeserialize(as = TermFacetResultImpl.class) 037public interface TermFacetResult extends FacetResult { 038 039 /** 040 * discriminator value for TermFacetResult 041 */ 042 String TERMS = "terms"; 043 044 /** 045 * 046 * @return dataType 047 */ 048 @NotNull 049 @JsonProperty("dataType") 050 public TermFacetResultType getDataType(); 051 052 /** 053 * 054 * @return missing 055 */ 056 @NotNull 057 @JsonProperty("missing") 058 public Long getMissing(); 059 060 /** 061 * 062 * @return total 063 */ 064 @NotNull 065 @JsonProperty("total") 066 public Long getTotal(); 067 068 /** 069 * 070 * @return other 071 */ 072 @NotNull 073 @JsonProperty("other") 074 public Long getOther(); 075 076 /** 077 * 078 * @return terms 079 */ 080 @NotNull 081 @Valid 082 @JsonProperty("terms") 083 public List<FacetTerm> getTerms(); 084 085 /** 086 * set dataType 087 * @param dataType value to be set 088 */ 089 090 public void setDataType(final TermFacetResultType dataType); 091 092 /** 093 * set missing 094 * @param missing value to be set 095 */ 096 097 public void setMissing(final Long missing); 098 099 /** 100 * set total 101 * @param total value to be set 102 */ 103 104 public void setTotal(final Long total); 105 106 /** 107 * set other 108 * @param other value to be set 109 */ 110 111 public void setOther(final Long other); 112 113 /** 114 * set terms 115 * @param terms values to be set 116 */ 117 118 @JsonIgnore 119 public void setTerms(final FacetTerm... terms); 120 121 /** 122 * set terms 123 * @param terms values to be set 124 */ 125 126 public void setTerms(final List<FacetTerm> terms); 127 128 /** 129 * factory method 130 * @return instance of TermFacetResult 131 */ 132 public static TermFacetResult of() { 133 return new TermFacetResultImpl(); 134 } 135 136 /** 137 * factory method to create a shallow copy TermFacetResult 138 * @param template instance to be copied 139 * @return copy instance 140 */ 141 public static TermFacetResult of(final TermFacetResult template) { 142 TermFacetResultImpl instance = new TermFacetResultImpl(); 143 instance.setDataType(template.getDataType()); 144 instance.setMissing(template.getMissing()); 145 instance.setTotal(template.getTotal()); 146 instance.setOther(template.getOther()); 147 instance.setTerms(template.getTerms()); 148 return instance; 149 } 150 151 /** 152 * factory method to create a deep copy of TermFacetResult 153 * @param template instance to be copied 154 * @return copy instance 155 */ 156 @Nullable 157 public static TermFacetResult deepCopy(@Nullable final TermFacetResult template) { 158 if (template == null) { 159 return null; 160 } 161 TermFacetResultImpl instance = new TermFacetResultImpl(); 162 instance.setDataType(template.getDataType()); 163 instance.setMissing(template.getMissing()); 164 instance.setTotal(template.getTotal()); 165 instance.setOther(template.getOther()); 166 instance.setTerms(Optional.ofNullable(template.getTerms()) 167 .map(t -> t.stream() 168 .map(com.commercetools.api.models.product.FacetTerm::deepCopy) 169 .collect(Collectors.toList())) 170 .orElse(null)); 171 return instance; 172 } 173 174 /** 175 * builder factory method for TermFacetResult 176 * @return builder 177 */ 178 public static TermFacetResultBuilder builder() { 179 return TermFacetResultBuilder.of(); 180 } 181 182 /** 183 * create builder for TermFacetResult instance 184 * @param template instance with prefilled values for the builder 185 * @return builder 186 */ 187 public static TermFacetResultBuilder builder(final TermFacetResult template) { 188 return TermFacetResultBuilder.of(template); 189 } 190 191 /** 192 * accessor map function 193 * @param <T> mapped type 194 * @param helper function to map the object 195 * @return mapped value 196 */ 197 default <T> T withTermFacetResult(Function<TermFacetResult, T> helper) { 198 return helper.apply(this); 199 } 200 201 /** 202 * gives a TypeReference for usage with Jackson DataBind 203 * @return TypeReference 204 */ 205 public static com.fasterxml.jackson.core.type.TypeReference<TermFacetResult> typeReference() { 206 return new com.fasterxml.jackson.core.type.TypeReference<TermFacetResult>() { 207 @Override 208 public String toString() { 209 return "TypeReference<TermFacetResult>"; 210 } 211 }; 212 } 213}