All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.polyapi.client.api.VariableChangeEvent Maven / Gradle / Ivy

The newest version!
package io.polyapi.client.api;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
public class VariableChangeEvent {

  private Type type;
  private boolean secret;
  private String id;
  private T previousValue;
  private T currentValue;
  private long updateTime;
  private String updatedBy;
  private List updatedFields;

  public enum Type {
    UPDATE("update"),
    DELETE("delete");

    private final String jsonValue;

    Type(String jsonValue) {
      this.jsonValue = jsonValue;
    }

    @JsonValue
    public String jsonValue() {
      return this.jsonValue;
    }

    @JsonCreator
    public static Type fromJsonValue(String jsonValue) {
      for (Type type : Type.values()) {
        if (type.jsonValue.equalsIgnoreCase(jsonValue)) {
          return type;
        }
      }
      throw new IllegalArgumentException("Unexpected value '" + jsonValue + "'");
    }
  }

  public enum UpdatedField {
    VALUE("value"),
    SECRET("secret");

    private final String jsonValue;

    UpdatedField(String jsonValue) {
      this.jsonValue = jsonValue;
    }

    @JsonValue
    public String jsonValue() {
      return this.jsonValue;
    }

    @JsonCreator
    public static UpdatedField fromJsonValue(String jsonValue) {
      for (UpdatedField type : UpdatedField.values()) {
        if (type.jsonValue.equalsIgnoreCase(jsonValue)) {
          return type;
        }
      }
      throw new IllegalArgumentException("Unexpected value '" + jsonValue + "'");
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy