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

com.mindee.product.fr.energybill.EnergyBillV1EnergyConsumer Maven / Gradle / Ivy

The newest version!
package com.mindee.product.fr.energybill;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.mindee.parsing.SummaryHelper;
import com.mindee.parsing.standard.BaseField;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;

/**
 * The entity that consumes the energy.
 */
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
public class EnergyBillV1EnergyConsumer extends BaseField {

  /**
   * The address of the energy consumer.
   */
  @JsonProperty("address")
  String address;
  /**
   * The name of the energy consumer.
   */
  @JsonProperty("name")
  String name;

  public boolean isEmpty() {
    return (
        (address == null || address.isEmpty())
        && (name == null || name.isEmpty())
      );
  }

  /**
   * Output the object in a format suitable for inclusion in an rST field list.
   */
  public String toFieldList() {
    Map printable = this.printableValues();
    return String.format("  :Address: %s%n", printable.get("address"))
        + String.format("  :Name: %s%n", printable.get("name"));
  }

  @Override
  public String toString() {
    Map printable = this.printableValues();
    return String.format("Address: %s", printable.get("address"))
      + String.format(", Name: %s", printable.get("name"));
  }

  private Map printableValues() {
    Map printable = new HashMap<>();

    printable.put("address", SummaryHelper.formatForDisplay(this.address, null));
    printable.put("name", SummaryHelper.formatForDisplay(this.name, null));
    return printable;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy