001package com.box.sdkgen.schemas.metadatataxonomynode; 002 003import com.box.sdkgen.internal.NullableFieldTracker; 004import com.box.sdkgen.internal.SerializableObject; 005import com.box.sdkgen.schemas.metadatataxonomyancestor.MetadataTaxonomyAncestor; 006import com.fasterxml.jackson.annotation.JsonFilter; 007import com.fasterxml.jackson.annotation.JsonProperty; 008import java.util.List; 009import java.util.Objects; 010 011/** A node object for metadata taxonomy that can be used in metadata templates. */ 012@JsonFilter("nullablePropertyFilter") 013public class MetadataTaxonomyNode extends SerializableObject { 014 015 /** A unique identifier of the metadata taxonomy node. */ 016 protected final String id; 017 018 /** The display name of the metadata taxonomy node. */ 019 protected final String displayName; 020 021 /** An index of the level to which the node belongs. */ 022 protected final long level; 023 024 /** The identifier of the parent node. */ 025 protected String parentId; 026 027 /** An array of identifiers for all ancestor nodes. Not returned for root-level nodes. */ 028 protected List<String> nodePath; 029 030 /** An array of objects for all ancestor nodes. Not returned for root-level nodes. */ 031 protected List<MetadataTaxonomyAncestor> ancestors; 032 033 public MetadataTaxonomyNode( 034 @JsonProperty("id") String id, 035 @JsonProperty("displayName") String displayName, 036 @JsonProperty("level") long level) { 037 super(); 038 this.id = id; 039 this.displayName = displayName; 040 this.level = level; 041 } 042 043 protected MetadataTaxonomyNode(Builder builder) { 044 super(); 045 this.id = builder.id; 046 this.displayName = builder.displayName; 047 this.level = builder.level; 048 this.parentId = builder.parentId; 049 this.nodePath = builder.nodePath; 050 this.ancestors = builder.ancestors; 051 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 052 } 053 054 public String getId() { 055 return id; 056 } 057 058 public String getDisplayName() { 059 return displayName; 060 } 061 062 public long getLevel() { 063 return level; 064 } 065 066 public String getParentId() { 067 return parentId; 068 } 069 070 public List<String> getNodePath() { 071 return nodePath; 072 } 073 074 public List<MetadataTaxonomyAncestor> getAncestors() { 075 return ancestors; 076 } 077 078 @Override 079 public boolean equals(Object o) { 080 if (this == o) { 081 return true; 082 } 083 if (o == null || getClass() != o.getClass()) { 084 return false; 085 } 086 MetadataTaxonomyNode casted = (MetadataTaxonomyNode) o; 087 return Objects.equals(id, casted.id) 088 && Objects.equals(displayName, casted.displayName) 089 && Objects.equals(level, casted.level) 090 && Objects.equals(parentId, casted.parentId) 091 && Objects.equals(nodePath, casted.nodePath) 092 && Objects.equals(ancestors, casted.ancestors); 093 } 094 095 @Override 096 public int hashCode() { 097 return Objects.hash(id, displayName, level, parentId, nodePath, ancestors); 098 } 099 100 @Override 101 public String toString() { 102 return "MetadataTaxonomyNode{" 103 + "id='" 104 + id 105 + '\'' 106 + ", " 107 + "displayName='" 108 + displayName 109 + '\'' 110 + ", " 111 + "level='" 112 + level 113 + '\'' 114 + ", " 115 + "parentId='" 116 + parentId 117 + '\'' 118 + ", " 119 + "nodePath='" 120 + nodePath 121 + '\'' 122 + ", " 123 + "ancestors='" 124 + ancestors 125 + '\'' 126 + "}"; 127 } 128 129 public static class Builder extends NullableFieldTracker { 130 131 protected final String id; 132 133 protected final String displayName; 134 135 protected final long level; 136 137 protected String parentId; 138 139 protected List<String> nodePath; 140 141 protected List<MetadataTaxonomyAncestor> ancestors; 142 143 public Builder(String id, String displayName, long level) { 144 super(); 145 this.id = id; 146 this.displayName = displayName; 147 this.level = level; 148 } 149 150 public Builder parentId(String parentId) { 151 this.parentId = parentId; 152 return this; 153 } 154 155 public Builder nodePath(List<String> nodePath) { 156 this.nodePath = nodePath; 157 return this; 158 } 159 160 public Builder ancestors(List<MetadataTaxonomyAncestor> ancestors) { 161 this.ancestors = ancestors; 162 return this; 163 } 164 165 public MetadataTaxonomyNode build() { 166 return new MetadataTaxonomyNode(this); 167 } 168 } 169}