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

com.geotab.http.request.BaseRequest Maven / Gradle / Ivy

/*
 *
 * 2020 Copyright (C) Geotab Inc. All rights reserved.
 */

package com.geotab.http.request;

import com.geotab.http.request.param.EmptyParameters;
import com.geotab.http.request.param.Parameters;
import java.util.Optional;
import lombok.Builder;
import lombok.Data;

@Data
@Builder(builderMethodName = "requestBuilder")
public class BaseRequest {

  public static final Parameters EMPTY_PARAMETERS = new EmptyParameters();

  protected Integer id;

  protected String method;

  protected T params;

  public BaseRequest() {
    this(null, null, (T) EMPTY_PARAMETERS);
  }

  public BaseRequest(Integer id, String method, T params) {
    this.id = id;
    this.method = method;
    this.params = Optional.ofNullable(params).orElse((T) EMPTY_PARAMETERS);
  }

  public void validate() {
    if (method == null) {
      throw new IllegalArgumentException("Method must be provided");
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy