001 002package com.commercetools.ml.models.category_recommendations; 003 004import java.util.*; 005import java.util.function.Function; 006 007import io.vrap.rmf.base.client.Builder; 008import io.vrap.rmf.base.client.utils.Generated; 009 010/** 011 * ProjectCategoryRecommendationBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * ProjectCategoryRecommendation projectCategoryRecommendation = ProjectCategoryRecommendation.builder() 017 * .category(categoryBuilder -> categoryBuilder) 018 * .confidence(0.3) 019 * .path("{path}") 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 ProjectCategoryRecommendationBuilder implements Builder<ProjectCategoryRecommendation> { 026 027 private com.commercetools.ml.models.common.CategoryReference category; 028 029 private Double confidence; 030 031 private String path; 032 033 /** 034 * <p>A category that is recommended for a product.</p> 035 * @param builder function to build the category value 036 * @return Builder 037 */ 038 039 public ProjectCategoryRecommendationBuilder category( 040 Function<com.commercetools.ml.models.common.CategoryReferenceBuilder, com.commercetools.ml.models.common.CategoryReferenceBuilder> builder) { 041 this.category = builder.apply(com.commercetools.ml.models.common.CategoryReferenceBuilder.of()).build(); 042 return this; 043 } 044 045 /** 046 * <p>A category that is recommended for a product.</p> 047 * @param builder function to build the category value 048 * @return Builder 049 */ 050 051 public ProjectCategoryRecommendationBuilder withCategory( 052 Function<com.commercetools.ml.models.common.CategoryReferenceBuilder, com.commercetools.ml.models.common.CategoryReference> builder) { 053 this.category = builder.apply(com.commercetools.ml.models.common.CategoryReferenceBuilder.of()); 054 return this; 055 } 056 057 /** 058 * <p>A category that is recommended for a product.</p> 059 * @param category value to be set 060 * @return Builder 061 */ 062 063 public ProjectCategoryRecommendationBuilder category( 064 final com.commercetools.ml.models.common.CategoryReference category) { 065 this.category = category; 066 return this; 067 } 068 069 /** 070 * <p>Probability score for the category recommendation.</p> 071 * @param confidence value to be set 072 * @return Builder 073 */ 074 075 public ProjectCategoryRecommendationBuilder confidence(final Double confidence) { 076 this.confidence = confidence; 077 return this; 078 } 079 080 /** 081 * <p>Breadcrumb path to the recommended category. This only picks up one language, not all available languages for the category. English is prioritized, but if English data is not available, an arbitrary language is selected. Do not use this to identify a category,use the category ID from the category reference instead.</p> 082 * @param path value to be set 083 * @return Builder 084 */ 085 086 public ProjectCategoryRecommendationBuilder path(final String path) { 087 this.path = path; 088 return this; 089 } 090 091 /** 092 * <p>A category that is recommended for a product.</p> 093 * @return category 094 */ 095 096 public com.commercetools.ml.models.common.CategoryReference getCategory() { 097 return this.category; 098 } 099 100 /** 101 * <p>Probability score for the category recommendation.</p> 102 * @return confidence 103 */ 104 105 public Double getConfidence() { 106 return this.confidence; 107 } 108 109 /** 110 * <p>Breadcrumb path to the recommended category. This only picks up one language, not all available languages for the category. English is prioritized, but if English data is not available, an arbitrary language is selected. Do not use this to identify a category,use the category ID from the category reference instead.</p> 111 * @return path 112 */ 113 114 public String getPath() { 115 return this.path; 116 } 117 118 /** 119 * builds ProjectCategoryRecommendation with checking for non-null required values 120 * @return ProjectCategoryRecommendation 121 */ 122 public ProjectCategoryRecommendation build() { 123 Objects.requireNonNull(category, ProjectCategoryRecommendation.class + ": category is missing"); 124 Objects.requireNonNull(confidence, ProjectCategoryRecommendation.class + ": confidence is missing"); 125 Objects.requireNonNull(path, ProjectCategoryRecommendation.class + ": path is missing"); 126 return new ProjectCategoryRecommendationImpl(category, confidence, path); 127 } 128 129 /** 130 * builds ProjectCategoryRecommendation without checking for non-null required values 131 * @return ProjectCategoryRecommendation 132 */ 133 public ProjectCategoryRecommendation buildUnchecked() { 134 return new ProjectCategoryRecommendationImpl(category, confidence, path); 135 } 136 137 /** 138 * factory method for an instance of ProjectCategoryRecommendationBuilder 139 * @return builder 140 */ 141 public static ProjectCategoryRecommendationBuilder of() { 142 return new ProjectCategoryRecommendationBuilder(); 143 } 144 145 /** 146 * create builder for ProjectCategoryRecommendation instance 147 * @param template instance with prefilled values for the builder 148 * @return builder 149 */ 150 public static ProjectCategoryRecommendationBuilder of(final ProjectCategoryRecommendation template) { 151 ProjectCategoryRecommendationBuilder builder = new ProjectCategoryRecommendationBuilder(); 152 builder.category = template.getCategory(); 153 builder.confidence = template.getConfidence(); 154 builder.path = template.getPath(); 155 return builder; 156 } 157 158}