package com.capgemini.reports.bomlineholder;

import com.capgemini.reports.bomlineholder.processor.IBOMLineHolderProcessor;
import com.capgemini.reports.bomlineholder.visitor.IBOMLineHolderExtractor;
import com.capgemini.reports.snecmaobjects.ISnecmaObject;
import com.teamcenter.soa.client.model.strong.BOMLine;
import com.teamcenter.soa.client.model.strong.ItemRevision;

import java.io.Serializable;
import java.util.List;

/**
 * Common interface for tree structure like BOM lines.
 **/
public interface IBOMTree extends Serializable {

    /**
     * All the BOMLineHolder must accept a Processor which may alter its content (i.e. load extra data, or remove some branches, etc).
     *
     * @param aBOMLineHolderProcessor aBOMLineHolderProcessor
     */
    void process(final IBOMLineHolderProcessor aBOMLineHolderProcessor);

    /**
     * All the BOMLineHolder must accept an Extractor object to make the different reports.
     *
     * @param <T>                     any kind of output expected from the extractor
     * @param aBOMLineHolderExtractor aBOMLineHolderExtractor<T>
     * @return an object of type T
     */
    <T> T accept(final IBOMLineHolderExtractor<T> aBOMLineHolderExtractor);

    /**
     * Getter for the parent BOM line of the current BOM node.
     *
     * @return The parent BOM line
     */
    IBOMTree getParentBomLine();

    /**
     * Getter for the list of children BOM lines.
     *
     * @return {@link List} of children BOM lines
     */
    List<BOMLineHolder> getBomChilds();

    /**
     * Assign a child BOM line to the current line and create a reference to its parent.
     *
     * @param aChild New child BOM line.
     */
    void addChild(final BOMLineHolder aChild);

    /**
     * Assign a parent BOM line to the current line.
     *
     * @param aParentBomLine New parent BOM line.
     */
    void setParent(final BOMLineHolder aParentBomLine);

    /**
     * Getter for the managed BOM Model object of the current BOM line.
     *
     * @return BOM Model Object
     */
    BOMLine getBomLineObject();

    /**
     * Generate unique key using item_id + item_revision_id for children BOM lines.
     *
     * @return Unique key for sorting purpose
     */
    String getKey();

    /**
     * Getter for the SnecmaObject.
     *
     * @return the SnecmaObject
     */
    ISnecmaObject getSnecmaObject();

    /**
     * Getter for the unique identifier.
     *
     * @return the uid
     */
    String getUid();

    String getObjectType();

    ItemRevision getItemRevision();
}
