<commit_before>/*
 * This program is part of the OpenLMIS logistics management information system platform software.
 * Copyright © 2017 VillageReach
 *
 * This program is free software: you can redistribute it and/or modify it under the terms
 * of the GNU Affero General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 *  
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU Affero General Public License for more details. You should have received a copy of
 * the GNU Affero General Public License along with this program. If not, see
 * http://www.gnu.org/licenses.  For additional information contact <EMAIL>. 
 */

package org.openlmis.fulfillment.domain;

import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import org.hibernate.annotations.Type;
import org.javers.core.metamodel.annotation.TypeName;

@Entity
@Table(name = "shipment_line_items")
@TypeName("ShipmentLineItem")
@AllArgsConstructor
@ToString
public class ShipmentLineItem extends BaseEntity {

  @Type(type = UUID_TYPE)
  @Column(nullable = false)
  @Getter
  private UUID orderableId;

  @Type(type = UUID_TYPE)
  @Getter
  private UUID lotId;

  @Column(nullable = false)
  @Getter(AccessLevel.PACKAGE)
  private Long quantityShipped;

  // Constructor needed by framework. Use all args constructor to create new instance.
  private ShipmentLineItem() {}

  public ShipmentLineItem(UUID orderableId, Long quantityShipped) {
    this(orderableId, null, quantityShipped);
  }

  /**
   * Creates new instance based on data from {@link Importer}
   *
   * @param importer instance of {@link Importer}
   * @return new instance of shipment line item.
   */
  protected static ShipmentLineItem newInstance(Importer importer) {
    ShipmentLineItem shipmentLineItem = new ShipmentLineItem(
        importer.getOrderableId(), importer.getLotId(), importer.getQuantityShipped());
    shipmentLineItem.setId(importer.getId());
    return shipmentLineItem;
  }

  /**
   * Verifies if the given line item has something to shipped.
   */
  public boolean isShipped() {
    return null != quantityShipped && quantityShipped > 0;
  }

  /**
   * Exports data from the given shipment to the instance that implement
   * {@link Exporter} interface.
   */
  public void export(Exporter exporter) {
    exporter.setId(getId());
    exporter.setOrderableId(orderableId);
    exporter.setLotId(lotId);
    exporter.setQuantityShipped(quantityShipped);
  }

  /**
   * Returns a copy of line item.
   */
  public ShipmentLineItem copy() {
    ShipmentLineItem clone = new ShipmentLineItem(orderableId, lotId, quantityShipped);<commit_msg>OLMIS-4477: Update Javadoc (FEOLMIS-2829)<commit_after>/*
 * This program is part of the OpenLMIS logistics management information system platform software.
 * Copyright © 2017 VillageReach
 *
 * This program is free software: you can redistribute it and/or modify it under the terms
 * of the GNU Affero General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 *  
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU Affero General Public License for more details. You should have received a copy of
 * the GNU Affero General Public License along with this program. If not, see
 * http://www.gnu.org/licenses.  For additional information contact <EMAIL>. 
 */

package org.openlmis.fulfillment.domain;

import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import org.hibernate.annotations.Type;
import org.javers.core.metamodel.annotation.TypeName;

@Entity
@Table(name = "shipment_line_items")
@TypeName("ShipmentLineItem")
@AllArgsConstructor
@ToString
public class ShipmentLineItem extends BaseEntity {

  @Type(type = UUID_TYPE)
  @Column(nullable = false)
  @Getter
  private UUID orderableId;

  @Type(type = UUID_TYPE)
  @Getter
  private UUID lotId;

  @Column(nullable = false)
  @Getter(AccessLevel.PACKAGE)
  private Long quantityShipped;

  // Constructor needed by framework. Use all args constructor to create new instance.
  private ShipmentLineItem() {}

  public ShipmentLineItem(UUID orderableId, Long quantityShipped) {
    this(orderableId, null, quantityShipped);
  }

  /**
   * Creates new instance based on data from {@link Importer}
   *
   * @param importer instance of {@link Importer}
   * @return new instance of shipment line item.
   */
  protected static ShipmentLineItem newInstance(Importer importer) {
    ShipmentLineItem shipmentLineItem = new ShipmentLineItem(
        importer.getOrderableId(), importer.getLotId(), importer.getQuantityShipped());
    shipmentLineItem.setId(importer.getId());
    return shipmentLineItem;
  }

  /**
   * Verifies if the given line item has something to be shipped.
   */
  public boolean isShipped() {
    return null != quantityShipped && quantityShipped > 0;
  }

  /**
   * Exports data from the given shipment to the instance that implement
   * {@link Exporter} interface.
   */
  public void export(Exporter exporter) {
    exporter.setId(getId());
    exporter.setOrderableId(orderableId);
    exporter.setLotId(lotId);
    exporter.setQuantityShipped(quantityShipped);
  }

  /**
   * Returns a copy of line item.
   */
  public ShipmentLineItem copy() {
    ShipmentLineItem clone = new ShipmentLineItem(orderableId, lotId, quantityShipped);
{'fraction_non_alphanumeric': 0.0825475599669148, 'fraction_numerical': 0.0033085194375516956, 'mean_word_length': 4.271142109851787, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3140720', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1717, 'n_words': 587}