001package com.box.sdkgen.schemas.group; 002 003import com.box.sdkgen.internal.utils.DateTimeUtils; 004import com.box.sdkgen.schemas.groupbase.GroupBaseTypeField; 005import com.box.sdkgen.schemas.groupmini.GroupMini; 006import com.box.sdkgen.schemas.groupmini.GroupMiniGroupTypeField; 007import com.box.sdkgen.serialization.json.EnumWrapper; 008import com.fasterxml.jackson.annotation.JsonFilter; 009import com.fasterxml.jackson.annotation.JsonProperty; 010import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 011import com.fasterxml.jackson.databind.annotation.JsonSerialize; 012import java.time.OffsetDateTime; 013import java.util.Objects; 014 015/** A standard representation of a group, as returned from any group API endpoints by default. */ 016@JsonFilter("nullablePropertyFilter") 017public class Group extends GroupMini { 018 019 /** When the group object was created. */ 020 @JsonProperty("created_at") 021 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 022 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 023 protected OffsetDateTime createdAt; 024 025 /** When the group object was last modified. */ 026 @JsonProperty("modified_at") 027 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 028 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 029 protected OffsetDateTime modifiedAt; 030 031 public Group(@JsonProperty("id") String id) { 032 super(id); 033 } 034 035 protected Group(Builder builder) { 036 super(builder); 037 this.createdAt = builder.createdAt; 038 this.modifiedAt = builder.modifiedAt; 039 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 040 } 041 042 public OffsetDateTime getCreatedAt() { 043 return createdAt; 044 } 045 046 public OffsetDateTime getModifiedAt() { 047 return modifiedAt; 048 } 049 050 @Override 051 public boolean equals(Object o) { 052 if (this == o) { 053 return true; 054 } 055 if (o == null || getClass() != o.getClass()) { 056 return false; 057 } 058 Group casted = (Group) o; 059 return Objects.equals(id, casted.id) 060 && Objects.equals(type, casted.type) 061 && Objects.equals(name, casted.name) 062 && Objects.equals(groupType, casted.groupType) 063 && Objects.equals(createdAt, casted.createdAt) 064 && Objects.equals(modifiedAt, casted.modifiedAt); 065 } 066 067 @Override 068 public int hashCode() { 069 return Objects.hash(id, type, name, groupType, createdAt, modifiedAt); 070 } 071 072 @Override 073 public String toString() { 074 return "Group{" 075 + "id='" 076 + id 077 + '\'' 078 + ", " 079 + "type='" 080 + type 081 + '\'' 082 + ", " 083 + "name='" 084 + name 085 + '\'' 086 + ", " 087 + "groupType='" 088 + groupType 089 + '\'' 090 + ", " 091 + "createdAt='" 092 + createdAt 093 + '\'' 094 + ", " 095 + "modifiedAt='" 096 + modifiedAt 097 + '\'' 098 + "}"; 099 } 100 101 public static class Builder extends GroupMini.Builder { 102 103 protected OffsetDateTime createdAt; 104 105 protected OffsetDateTime modifiedAt; 106 107 public Builder(String id) { 108 super(id); 109 } 110 111 public Builder createdAt(OffsetDateTime createdAt) { 112 this.createdAt = createdAt; 113 return this; 114 } 115 116 public Builder modifiedAt(OffsetDateTime modifiedAt) { 117 this.modifiedAt = modifiedAt; 118 return this; 119 } 120 121 @Override 122 public Builder type(GroupBaseTypeField type) { 123 this.type = new EnumWrapper<GroupBaseTypeField>(type); 124 return this; 125 } 126 127 @Override 128 public Builder type(EnumWrapper<GroupBaseTypeField> type) { 129 this.type = type; 130 return this; 131 } 132 133 @Override 134 public Builder name(String name) { 135 this.name = name; 136 return this; 137 } 138 139 @Override 140 public Builder groupType(GroupMiniGroupTypeField groupType) { 141 this.groupType = new EnumWrapper<GroupMiniGroupTypeField>(groupType); 142 return this; 143 } 144 145 @Override 146 public Builder groupType(EnumWrapper<GroupMiniGroupTypeField> groupType) { 147 this.groupType = groupType; 148 return this; 149 } 150 151 public Group build() { 152 if (this.type == null) { 153 this.type = new EnumWrapper<GroupBaseTypeField>(GroupBaseTypeField.GROUP); 154 } 155 return new Group(this); 156 } 157 } 158}