<commit_before>package com.ning.billing.entitlement.api;

import com.ning.billing.catalog.api.BillingActionPolicy;
import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.Plan;
import com.ning.billing.catalog.api.PlanPhase;
import com.ning.billing.catalog.api.PriceList;
import com.ning.billing.catalog.api.Product;
import com.ning.billing.catalog.api.ProductCategory;
import com.ning.billing.util.callcontext.CallContext;
import com.ning.billing.util.entity.Entity;
import org.joda.time.LocalDate;

import java.util.UUID;

/**
 * An Entitlement is created using the <code>EntitlementApi</code>
 * <p/>
 * It contains all the catalog information and current state that answers the entitlement question.
 * <p>
 * The users of that API will control all the entitlement behavior when making changes such as the effectiveDate, catalog info,...
 * By default the system will use system wide policies to control the billing aspect, but specific APIs also allow to override those.
 * <p>
 * @see com.ning.billing.entitlement.api.EntitlementApi
 */
public interface Entitlement extends Entity {

    /**
     * Used to control the effective date that should be used on Plan change or on cancellation.
     */
    public enum EntitlementActionPolicy {
        /* Start of Term. */
        SOT,
        /* End of Term */
        EOT
    }

    /**
     * Possible states of an <code>Entitlement</code>
     */
    public enum EntitlementState {
        /* The entitlement was created in that initial state */
        ACTIVE,
        /* The system blocked the entitlement */
        BLOCKED,
        /* The user cancelled the entitlement */
        CANCELLED
    }

    /**
     * Possible <code>Entitlement</code> source types.
     */
    public enum EntitlementSourceType {
        NATIVE,
        MIGRATED,
        TRANSFERRED
    }

    /**
     * @return the unique id of the base entitlement
     */
    public UUID getBaseEntitlementId();


    /**
     *
     * @return the unique Id of the SubscriptionBundle
     */
    public UUID getBundleId();
    /**
     *
     * @return the account id
     */
    public UUID getAccountId();

    /**
     *
     * @return the external key that was supplied when creating the base entitlement
     */
    public String getExternalKey();

    /**
     * @return the state of the entitlement
     */
    public EntitlementState getState();

    /**
     * @return the entitlement source type
     */
    public EntitlementSourceType getSourceType();

    /**
     * @return the start date of the entitlement
     */
    public LocalDate getEffectiveStartDate();

    /**
     * @return the end date of the entitlement, that is the date at which it got cancelled.
     */
    public LocalDate getEffectiveEndDate();

    /**
     * @return the requested end date of the entitlement, that is the date at which the user submitted the cancellation.
     */
    public LocalDate getRequestedEndDate();

    /**
     * @return the current <code>Product</code>
     */
    public Product getProduct();

    /**
     * @return the current <code>Plan</code>
     */
    public Plan getPlan();

    /**
     * @return the current <code>PriceList></code>
     */
    public PriceList getPriceList();

    /**
     * @return the current <Phase></Phase>
     */
    public PlanPhase getCurrentPhase();

    /**
     * @return the current <code>ProductCategory</code>
     */
    public ProductCategory getProductCategory();

    /**
     * @return the last <code>Product</code> prior to cancellation
     */
    public Product getLastActiveProduct();

    /**
     * @return the last <code>Plan</code> prior to cancellation
     */
    public Plan getLastActivePlan();

    /**
     * @return the last active PriceList
     */
    public PriceList getLastActivePriceList();

    /**
     * @return the last active ProductCategory
     */
    public String getLastActiveProductCategory();


    /**
     * Cancels the <code>Entitlement</code> at the specified date
     * <p/>
     * The date is interpreted by the system to be in the timezone specified at the <code>Account</code>
     *
     * @param effectiveDate the date at which the entitlement should be cancelled
     * @param context       the context
     * @return true if the entitlement is in the <tt>CANCELLED</tt> state
     * @throws EntitlementApiException if cancellation failed
     */
    public boolean cancelEntitlementWithDate(final LocalDate effectiveDate, final CallContext context)
            throws EntitlementApiException;


    /**
     * Cancel the <code>Entitlement</code> with a policy.
     *
     * @param policy  the policy that is used by the system to calculate the cancellation date
     * @param context the context
     * @return true if the entitlement is in the <tt>CANCELLED</tt> state
     * @throws EntitlementApiException if cancellation failed
     */
    public boolean cancelEntitlementWithPolicy(final EntitlementActionPolicy policy, final CallContext context)
            throws EntitlementApiException;


    /**
     * Cancels the <code>Entitlement</code> at the specified date<commit_msg>Api return code mistake<commit_after>package com.ning.billing.entitlement.api;

import com.ning.billing.catalog.api.BillingActionPolicy;
import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.Plan;
import com.ning.billing.catalog.api.PlanPhase;
import com.ning.billing.catalog.api.PriceList;
import com.ning.billing.catalog.api.Product;
import com.ning.billing.catalog.api.ProductCategory;
import com.ning.billing.util.callcontext.CallContext;
import com.ning.billing.util.entity.Entity;
import org.joda.time.LocalDate;

import java.util.UUID;

/**
 * An Entitlement is created using the <code>EntitlementApi</code>
 * <p/>
 * It contains all the catalog information and current state that answers the entitlement question.
 * <p>
 * The users of that API will control all the entitlement behavior when making changes such as the effectiveDate, catalog info,...
 * By default the system will use system wide policies to control the billing aspect, but specific APIs also allow to override those.
 * <p>
 * @see com.ning.billing.entitlement.api.EntitlementApi
 */
public interface Entitlement extends Entity {

    /**
     * Used to control the effective date that should be used on Plan change or on cancellation.
     */
    public enum EntitlementActionPolicy {
        /* Start of Term. */
        SOT,
        /* End of Term */
        EOT
    }

    /**
     * Possible states of an <code>Entitlement</code>
     */
    public enum EntitlementState {
        /* The entitlement was created in that initial state */
        ACTIVE,
        /* The system blocked the entitlement */
        BLOCKED,
        /* The user cancelled the entitlement */
        CANCELLED
    }

    /**
     * Possible <code>Entitlement</code> source types.
     */
    public enum EntitlementSourceType {
        NATIVE,
        MIGRATED,
        TRANSFERRED
    }

    /**
     * @return the unique id of the base entitlement
     */
    public UUID getBaseEntitlementId();


    /**
     *
     * @return the unique Id of the SubscriptionBundle
     */
    public UUID getBundleId();
    /**
     *
     * @return the account id
     */
    public UUID getAccountId();

    /**
     *
     * @return the external key that was supplied when creating the base entitlement
     */
    public String getExternalKey();

    /**
     * @return the state of the entitlement
     */
    public EntitlementState getState();

    /**
     * @return the entitlement source type
     */
    public EntitlementSourceType getSourceType();

    /**
     * @return the start date of the entitlement
     */
    public LocalDate getEffectiveStartDate();

    /**
     * @return the end date of the entitlement, that is the date at which it got cancelled.
     */
    public LocalDate getEffectiveEndDate();

    /**
     * @return the requested end date of the entitlement, that is the date at which the user submitted the cancellation.
     */
    public LocalDate getRequestedEndDate();

    /**
     * @return the current <code>Product</code>
     */
    public Product getProduct();

    /**
     * @return the current <code>Plan</code>
     */
    public Plan getPlan();

    /**
     * @return the current <code>PriceList></code>
     */
    public PriceList getPriceList();

    /**
     * @return the current <Phase></Phase>
     */
    public PlanPhase getCurrentPhase();

    /**
     * @return the current <code>ProductCategory</code>
     */
    public ProductCategory getProductCategory();

    /**
     * @return the last <code>Product</code> prior to cancellation
     */
    public Product getLastActiveProduct();

    /**
     * @return the last <code>Plan</code> prior to cancellation
     */
    public Plan getLastActivePlan();

    /**
     * @return the last active PriceList
     */
    public PriceList getLastActivePriceList();

    /**
     * @return the last active ProductCategory
     */
    public ProductCategory getLastActiveProductCategory();


    /**
     * Cancels the <code>Entitlement</code> at the specified date
     * <p/>
     * The date is interpreted by the system to be in the timezone specified at the <code>Account</code>
     *
     * @param effectiveDate the date at which the entitlement should be cancelled
     * @param context       the context
     * @return true if the entitlement is in the <tt>CANCELLED</tt> state
     * @throws EntitlementApiException if cancellation failed
     */
    public boolean cancelEntitlementWithDate(final LocalDate effectiveDate, final CallContext context)
            throws EntitlementApiException;


    /**
     * Cancel the <code>Entitlement</code> with a policy.
     *
     * @param policy  the policy that is used by the system to calculate the cancellation date
     * @param context the context
     * @return true if the entitlement is in the <tt>CANCELLED</tt> state
     * @throws EntitlementApiException if cancellation failed
     */
    public boolean cancelEntitlementWithPolicy(final EntitlementActionPolicy policy, final CallContext context)
            throws EntitlementApiException;


    /**
     * Cancels the <code>Entitlement</code> at the specified date
{'fraction_non_alphanumeric': 0.09149946689929243, 'fraction_numerical': 0.0, 'mean_word_length': 2.656272147413182, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2891566', 'n_tokens_mistral': 2861, 'n_tokens_neox': 2734, 'n_words': 934}