001package com.box.sdkgen.schemas.weblinkbase; 002 003import com.box.sdkgen.internal.NullableFieldTracker; 004import com.box.sdkgen.internal.SerializableObject; 005import com.box.sdkgen.serialization.json.EnumWrapper; 006import com.fasterxml.jackson.annotation.JsonFilter; 007import com.fasterxml.jackson.annotation.JsonProperty; 008import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 009import com.fasterxml.jackson.databind.annotation.JsonSerialize; 010import java.util.Objects; 011 012/** 013 * Web links are objects that point to URLs. These objects are also known as bookmarks within the 014 * Box web application. 015 * 016 * <p>Web link objects are treated similarly to file objects, they will also support most actions 017 * that apply to regular files. 018 */ 019@JsonFilter("nullablePropertyFilter") 020public class WebLinkBase extends SerializableObject { 021 022 /** The unique identifier for this web link. */ 023 protected final String id; 024 025 /** The value will always be `web_link`. */ 026 @JsonDeserialize(using = WebLinkBaseTypeField.WebLinkBaseTypeFieldDeserializer.class) 027 @JsonSerialize(using = WebLinkBaseTypeField.WebLinkBaseTypeFieldSerializer.class) 028 protected EnumWrapper<WebLinkBaseTypeField> type; 029 030 /** The entity tag of this web link. Used with `If-Match` headers. */ 031 protected String etag; 032 033 public WebLinkBase(@JsonProperty("id") String id) { 034 super(); 035 this.id = id; 036 this.type = new EnumWrapper<WebLinkBaseTypeField>(WebLinkBaseTypeField.WEB_LINK); 037 } 038 039 protected WebLinkBase(Builder builder) { 040 super(); 041 this.id = builder.id; 042 this.type = builder.type; 043 this.etag = builder.etag; 044 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 045 } 046 047 public String getId() { 048 return id; 049 } 050 051 public EnumWrapper<WebLinkBaseTypeField> getType() { 052 return type; 053 } 054 055 public String getEtag() { 056 return etag; 057 } 058 059 @Override 060 public boolean equals(Object o) { 061 if (this == o) { 062 return true; 063 } 064 if (o == null || getClass() != o.getClass()) { 065 return false; 066 } 067 WebLinkBase casted = (WebLinkBase) o; 068 return Objects.equals(id, casted.id) 069 && Objects.equals(type, casted.type) 070 && Objects.equals(etag, casted.etag); 071 } 072 073 @Override 074 public int hashCode() { 075 return Objects.hash(id, type, etag); 076 } 077 078 @Override 079 public String toString() { 080 return "WebLinkBase{" 081 + "id='" 082 + id 083 + '\'' 084 + ", " 085 + "type='" 086 + type 087 + '\'' 088 + ", " 089 + "etag='" 090 + etag 091 + '\'' 092 + "}"; 093 } 094 095 public static class Builder extends NullableFieldTracker { 096 097 protected final String id; 098 099 protected EnumWrapper<WebLinkBaseTypeField> type; 100 101 protected String etag; 102 103 public Builder(String id) { 104 super(); 105 this.id = id; 106 } 107 108 public Builder type(WebLinkBaseTypeField type) { 109 this.type = new EnumWrapper<WebLinkBaseTypeField>(type); 110 return this; 111 } 112 113 public Builder type(EnumWrapper<WebLinkBaseTypeField> type) { 114 this.type = type; 115 return this; 116 } 117 118 public Builder etag(String etag) { 119 this.etag = etag; 120 return this; 121 } 122 123 public WebLinkBase build() { 124 if (this.type == null) { 125 this.type = new EnumWrapper<WebLinkBaseTypeField>(WebLinkBaseTypeField.WEB_LINK); 126 } 127 return new WebLinkBase(this); 128 } 129 } 130}