001 002package com.commercetools.history.models.common; 003 004import java.util.*; 005 006import io.vrap.rmf.base.client.Builder; 007import io.vrap.rmf.base.client.utils.Generated; 008 009/** 010 * GeoLocationBuilder 011 * <hr> 012 * Example to create an instance using the builder pattern 013 * <div class=code-example> 014 * <pre><code class='java'> 015 * GeoLocation geoLocation = GeoLocation.builder() 016 * .type("{type}") 017 * .plusCoordinates(coordinatesBuilder -> coordinatesBuilder) 018 * .build() 019 * </code></pre> 020 * </div> 021 */ 022@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 023public class GeoLocationBuilder implements Builder<GeoLocation> { 024 025 private String type; 026 027 private java.util.List<Integer> coordinates; 028 029 /** 030 * set the value to the type 031 * @param type value to be set 032 * @return Builder 033 */ 034 035 public GeoLocationBuilder type(final String type) { 036 this.type = type; 037 return this; 038 } 039 040 /** 041 * set values to the coordinates 042 * @param coordinates value to be set 043 * @return Builder 044 */ 045 046 public GeoLocationBuilder coordinates(final Integer... coordinates) { 047 this.coordinates = new ArrayList<>(Arrays.asList(coordinates)); 048 return this; 049 } 050 051 /** 052 * set value to the coordinates 053 * @param coordinates value to be set 054 * @return Builder 055 */ 056 057 public GeoLocationBuilder coordinates(final java.util.List<Integer> coordinates) { 058 this.coordinates = coordinates; 059 return this; 060 } 061 062 /** 063 * add values to the coordinates 064 * @param coordinates value to be set 065 * @return Builder 066 */ 067 068 public GeoLocationBuilder plusCoordinates(final Integer... coordinates) { 069 if (this.coordinates == null) { 070 this.coordinates = new ArrayList<>(); 071 } 072 this.coordinates.addAll(Arrays.asList(coordinates)); 073 return this; 074 } 075 076 /** 077 * value of type} 078 * @return type 079 */ 080 081 public String getType() { 082 return this.type; 083 } 084 085 /** 086 * value of coordinates} 087 * @return coordinates 088 */ 089 090 public java.util.List<Integer> getCoordinates() { 091 return this.coordinates; 092 } 093 094 /** 095 * builds GeoLocation with checking for non-null required values 096 * @return GeoLocation 097 */ 098 public GeoLocation build() { 099 Objects.requireNonNull(type, GeoLocation.class + ": type is missing"); 100 Objects.requireNonNull(coordinates, GeoLocation.class + ": coordinates is missing"); 101 return new GeoLocationImpl(type, coordinates); 102 } 103 104 /** 105 * builds GeoLocation without checking for non-null required values 106 * @return GeoLocation 107 */ 108 public GeoLocation buildUnchecked() { 109 return new GeoLocationImpl(type, coordinates); 110 } 111 112 /** 113 * factory method for an instance of GeoLocationBuilder 114 * @return builder 115 */ 116 public static GeoLocationBuilder of() { 117 return new GeoLocationBuilder(); 118 } 119 120 /** 121 * create builder for GeoLocation instance 122 * @param template instance with prefilled values for the builder 123 * @return builder 124 */ 125 public static GeoLocationBuilder of(final GeoLocation template) { 126 GeoLocationBuilder builder = new GeoLocationBuilder(); 127 builder.type = template.getType(); 128 builder.coordinates = template.getCoordinates(); 129 return builder; 130 } 131 132}