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

com.mindee.parsing.standard.CompanyRegistrationField Maven / Gradle / Ivy

The newest version!
package com.mindee.parsing.standard;

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

/**
 * Represent a company registration.
 */
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
public final class CompanyRegistrationField extends BaseField implements LineItemField {

  /**
   * The value of the field.
   */
  private final String value;

  /**
   * Type of the company registration number.
   */
  private final String type;

  public CompanyRegistrationField(
      @JsonProperty("type")
      String type,
      @JsonProperty("value")
      String value
  ) {
    this.type = type;
    this.value = value;
  }

  public boolean isEmpty() {
    return (
        (value == null || value.isEmpty())
        && (type == null || type.isEmpty())
      );
  }

  /**
   * Output the line in a format suitable for inclusion in an rST table.
   */
  public String toTableLine() {
    Map printable = this.printableValues();
    return String.format("| %-15s ", printable.get("type"))
      + String.format("| %-20s ", printable.get("value"));
  }

  @Override
  public String toString() {
    Map printable = this.printableValues();
    return String.format("Type: %s", printable.get("type"))
      + String.format(", Value: %s", printable.get("value"));
  }

  private Map printableValues() {
    Map printable = new HashMap<>();
    printable.put("type", SummaryHelper.formatForDisplay(this.type, null));
    printable.put("value", SummaryHelper.formatForDisplay(this.value, null));
    return printable;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy