001package com.box.sdkgen.schemas.metadataquery;
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@JsonFilter("nullablePropertyFilter")
013public class MetadataQueryOrderByField extends SerializableObject {
014
015  /**
016   * The metadata template field to order by.
017   *
018   * <p>The `field_key` represents the `key` value of a field from the metadata template being
019   * searched for.
020   */
021  @JsonProperty("field_key")
022  protected String fieldKey;
023
024  /**
025   * The direction to order by, either ascending or descending.
026   *
027   * <p>The `ordering` direction must be the same for each item in the array.
028   */
029  @JsonDeserialize(
030      using =
031          MetadataQueryOrderByDirectionField.MetadataQueryOrderByDirectionFieldDeserializer.class)
032  @JsonSerialize(
033      using = MetadataQueryOrderByDirectionField.MetadataQueryOrderByDirectionFieldSerializer.class)
034  protected EnumWrapper<MetadataQueryOrderByDirectionField> direction;
035
036  public MetadataQueryOrderByField() {
037    super();
038  }
039
040  protected MetadataQueryOrderByField(Builder builder) {
041    super();
042    this.fieldKey = builder.fieldKey;
043    this.direction = builder.direction;
044    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
045  }
046
047  public String getFieldKey() {
048    return fieldKey;
049  }
050
051  public EnumWrapper<MetadataQueryOrderByDirectionField> getDirection() {
052    return direction;
053  }
054
055  @Override
056  public boolean equals(Object o) {
057    if (this == o) {
058      return true;
059    }
060    if (o == null || getClass() != o.getClass()) {
061      return false;
062    }
063    MetadataQueryOrderByField casted = (MetadataQueryOrderByField) o;
064    return Objects.equals(fieldKey, casted.fieldKey) && Objects.equals(direction, casted.direction);
065  }
066
067  @Override
068  public int hashCode() {
069    return Objects.hash(fieldKey, direction);
070  }
071
072  @Override
073  public String toString() {
074    return "MetadataQueryOrderByField{"
075        + "fieldKey='"
076        + fieldKey
077        + '\''
078        + ", "
079        + "direction='"
080        + direction
081        + '\''
082        + "}";
083  }
084
085  public static class Builder extends NullableFieldTracker {
086
087    protected String fieldKey;
088
089    protected EnumWrapper<MetadataQueryOrderByDirectionField> direction;
090
091    public Builder fieldKey(String fieldKey) {
092      this.fieldKey = fieldKey;
093      return this;
094    }
095
096    public Builder direction(MetadataQueryOrderByDirectionField direction) {
097      this.direction = new EnumWrapper<MetadataQueryOrderByDirectionField>(direction);
098      return this;
099    }
100
101    public Builder direction(EnumWrapper<MetadataQueryOrderByDirectionField> direction) {
102      this.direction = direction;
103      return this;
104    }
105
106    public MetadataQueryOrderByField build() {
107      return new MetadataQueryOrderByField(this);
108    }
109  }
110}