congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
PlanSpecifier
Code IndexAdd Tabnine to your IDE (free)

How to use
PlanSpecifier
in
org.killbill.billing.catalog.api

Best Java code snippets using org.killbill.billing.catalog.api.PlanSpecifier (Showing top 20 results out of 315)

origin: killbill/killbill

public PlanChangeResult planChange(final PlanPhaseSpecifier from, final PlanSpecifier to, final StaticCatalog catalog) throws CatalogApiException {
  final DefaultPriceList toPriceList = to.getPriceListName() != null ?
                     (DefaultPriceList) catalog.findCurrentPricelist(to.getPriceListName()) :
                     findPriceList(from, catalog);
  // If we use old scheme {product, billingPeriod, pricelist}, ensure pricelist is correct
  // (Pricelist may be null because if it is unspecified this is the principal use-case)
  final PlanSpecifier toWithPriceList = to.getPlanName() == null ?
                     new PlanSpecifier(to.getProductName(), to.getBillingPeriod(), toPriceList.getName()) :
                     to;
  final BillingActionPolicy policy = getPlanChangePolicy(from, toWithPriceList, catalog);
  if (policy == BillingActionPolicy.ILLEGAL) {
    throw new IllegalPlanChange(from, toWithPriceList);
  }
  final PlanAlignmentChange alignment = getPlanChangeAlignment(from, toWithPriceList, catalog);
  return new PlanChangeResult(toPriceList, policy, alignment);
}
origin: killbill/killbill

@Override
public Plan createOrFindCurrentPlan(final PlanSpecifier spec, final PlanPhasePriceOverridesWithCallContext unused) throws CatalogApiException {
  final Plan result;
  if (spec.getPlanName() != null) {
    result = findCurrentPlan(spec.getPlanName());
  } else {
    if (spec.getProductName() == null) {
      throw new CatalogApiException(ErrorCode.CAT_NULL_PRODUCT_NAME);
    }
    if (spec.getBillingPeriod() == null) {
      throw new CatalogApiException(ErrorCode.CAT_NULL_BILLING_PERIOD);
    }
    final String inputOrDefaultPricelist = (spec.getPriceListName() == null) ? PriceListSet.DEFAULT_PRICELIST_NAME : spec.getPriceListName();
    final Product product = findCurrentProduct(spec.getProductName());
    result = priceLists.getPlanFrom(product, spec.getBillingPeriod(), inputOrDefaultPricelist);
  }
  if (result == null) {
    throw new CatalogApiException(ErrorCode.CAT_PLAN_NOT_FOUND,
                   spec.getPlanName() != null ? spec.getPlanName() : "undefined",
                   spec.getProductName() != null ? spec.getProductName() : "undefined",
                   spec.getBillingPeriod() != null ? spec.getBillingPeriod() : "undefined",
                   spec.getPriceListName() != null ? spec.getPriceListName() : "undefined");
  }
  return result;
}
origin: killbill/killbill

private DefaultPriceList findPriceList(final PlanSpecifier specifier, final StaticCatalog catalog) throws CatalogApiException {
  DefaultPriceList result = DefaultCasePriceList.getResult(priceListCase, specifier, catalog);
  if (result == null) {
    final String priceListName = specifier.getPlanName() != null ? catalog.findCurrentPlan(specifier.getPlanName()).getPriceListName() : specifier.getPriceListName();
    result = (DefaultPriceList) catalog.findCurrentPricelist(priceListName);
  }
  return result;
}
origin: killbill/killbill

public PlanRequestWrapper(final String planName) {
  this(new PlanSpecifier(planName));
}
origin: org.kill-bill.billing/killbill-api

public IllegalPlanChange(final PlanPhaseSpecifier from,
             final PlanSpecifier to) {
  super(ErrorCode.CAT_ILLEGAL_CHANGE_REQUEST, from.getProductName(), from.getBillingPeriod(), from.getPriceListName(), to.getProductName(), to.getBillingPeriod(), to.getPriceListName());
}
origin: killbill/killbill

public T getResult(final PlanPhaseSpecifier specifier, final StaticCatalog c) throws CatalogApiException {
  if ((phaseType == null || specifier.getPhaseType() == phaseType)
    && satisfiesCase(new PlanSpecifier(specifier), c)) {
    return getResult();
  }
  return null;
}
origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public IllegalPlanChange(final Throwable cause, final PlanPhaseSpecifier from,
             final PlanSpecifier to) {
  super(cause, ErrorCode.CAT_ILLEGAL_CHANGE_REQUEST, from.getProductName(), from.getBillingPeriod(), from.getPriceListName(), to.getProductName(), to.getBillingPeriod(), to.getPriceListName());
}
origin: org.kill-bill.billing/killbill-catalog

private DefaultPriceList findPriceList(final PlanSpecifier specifier, final StaticCatalog catalog) throws CatalogApiException {
  DefaultPriceList result = DefaultCasePriceList.getResult(priceListCase, specifier, catalog);
  if (result == null) {
    final String priceListName = specifier.getPlanName() != null ? catalog.findCurrentPlan(specifier.getPlanName()).getPriceListName() : specifier.getPriceListName();
    result = (DefaultPriceList) catalog.findCurrentPricelist(priceListName);
  }
  return result;
}
origin: killbill/killbill

  protected void assertion(final Result result, final DefaultCaseResult cr, final String productName, final ProductCategory productCategory, final BillingPeriod bp, final String priceListName, final StandaloneCatalog cat) throws CatalogApiException {
    Assert.assertEquals(result, cr.getResult(new PlanSpecifier(productName, bp, priceListName), cat));
  }
}
origin: org.kill-bill.billing/killbill-api

public IllegalPlanChange(final Throwable cause, final PlanPhaseSpecifier from,
             final PlanSpecifier to) {
  super(cause, ErrorCode.CAT_ILLEGAL_CHANGE_REQUEST, from.getProductName(), from.getBillingPeriod(), from.getPriceListName(), to.getProductName(), to.getBillingPeriod(), to.getPriceListName());
}
origin: killbill/killbill

spec.getPlanName() != null ? spec.getPlanName() : "undefined",
spec.getProductName() != null ? spec.getProductName() : "undefined",
spec.getBillingPeriod() != null ? spec.getBillingPeriod() : "undefined",
spec.getPriceListName() != null ? spec.getPriceListName() : "undefined");
origin: killbill/killbill

protected void assertionNull(final DefaultCaseResult cr, final String productName, final ProductCategory productCategory, final BillingPeriod bp, final String priceListName, final StandaloneCatalog cat) throws CatalogApiException {
  Assert.assertNull(cr.getResult(new PlanSpecifier(productName, bp, priceListName), cat));
}
origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public IllegalPlanChange(final PlanPhaseSpecifier from,
             final PlanSpecifier to) {
  super(ErrorCode.CAT_ILLEGAL_CHANGE_REQUEST, from.getProductName(), from.getBillingPeriod(), from.getPriceListName(), to.getProductName(), to.getBillingPeriod(), to.getPriceListName());
}
origin: killbill/killbill

protected boolean satisfiesCase(final PlanSpecifier planPhase, final StaticCatalog c) throws CatalogApiException {
  final Product product;
  final BillingPeriod billingPeriod;
  final ProductCategory productCategory;
  final PriceList priceList;
  if (planPhase.getPlanName() != null) {
    final Plan plan = c.findCurrentPlan(planPhase.getPlanName());
    product = plan.getProduct();
    billingPeriod = plan.getRecurringBillingPeriod();
    productCategory = plan.getProduct().getCategory();
    priceList = c.findCurrentPricelist(plan.getPriceListName());
  } else {
    product = c.findCurrentProduct(planPhase.getProductName());
    billingPeriod = planPhase.getBillingPeriod();
    productCategory = product.getCategory();
    priceList = getPriceList() != null ? c.findCurrentPricelist(planPhase.getPriceListName()) : null;
  }
  return (getProduct() == null || getProduct().equals(product)) &&
      (getProductCategory() == null || getProductCategory().equals(productCategory)) &&
      (getBillingPeriod() == null || getBillingPeriod().equals(billingPeriod)) &&
      (getPriceList() == null || getPriceList().equals(priceList));
}
origin: killbill/killbill

private List<TimedPhase> getTimedPhaseOnCreate(final DateTime subscriptionStartDate,
                        final DateTime bundleStartDate,
                        final Plan plan,
                        @Nullable final PhaseType initialPhase,
                        final Catalog catalog,
                        final DateTime catalogEffectiveDate,
                        final InternalTenantContext context)
    throws CatalogApiException, SubscriptionBaseApiException {
  final PlanSpecifier planSpecifier = new PlanSpecifier(plan.getName());
  final DateTime planStartDate;
  final PlanAlignmentCreate alignment = catalog.planCreateAlignment(planSpecifier, catalogEffectiveDate, subscriptionStartDate);
  switch (alignment) {
    case START_OF_SUBSCRIPTION:
      planStartDate = subscriptionStartDate;
      break;
    case START_OF_BUNDLE:
      planStartDate = bundleStartDate;
      break;
    default:
      throw new SubscriptionBaseError(String.format("Unknown PlanAlignmentCreate %s", alignment));
  }
  return getPhaseAlignments(plan, initialPhase, planStartDate);
}
origin: killbill/killbill

final ProductCategory inToProductCategory;
final PriceList inToPriceList;
if (to.getPlanName() != null) {
  final Plan plan = catalog.findCurrentPlan(to.getPlanName());
  inToProduct = plan.getProduct();
  inToBillingPeriod = plan.getRecurringBillingPeriod();
  inToPriceList = catalog.findCurrentPricelist(plan.getPriceListName());
} else {
  inToProduct = catalog.findCurrentProduct(to.getProductName());
  inToBillingPeriod = to.getBillingPeriod();
  inToProductCategory = inToProduct.getCategory();
  inToPriceList = to.getPriceListName() != null ? catalog.findCurrentPricelist(to.getPriceListName()) : null;
origin: killbill/killbill

protected void assertionNull(final DefaultCaseChangeResult cr,
               final String fromProductName, final String toProductName,
               final ProductCategory fromProductCategory, final ProductCategory toProductCategory,
               final BillingPeriod fromBp, final BillingPeriod toBp,
               final String fromPriceListName, final String toPriceListName,
               final PhaseType phaseType, final StandaloneCatalog cat) {
  try {
    Assert.assertNull(cr.getResult(new PlanPhaseSpecifier(fromProductName, fromBp, fromPriceListName, phaseType),
                    new PlanSpecifier(toProductName, toBp, toPriceListName), cat));
  } catch (CatalogApiException e) {
    Assert.fail("", e);
  }
}
origin: org.kill-bill.billing/killbill-catalog

@Override
public Plan createOrFindCurrentPlan(final PlanSpecifier spec, final PlanPhasePriceOverridesWithCallContext unused) throws CatalogApiException {
  final Plan result;
  if (spec.getPlanName() != null) {
    result = findCurrentPlan(spec.getPlanName());
  } else {
    if (spec.getProductName() == null) {
      throw new CatalogApiException(ErrorCode.CAT_NULL_PRODUCT_NAME);
    }
    if (spec.getBillingPeriod() == null) {
      throw new CatalogApiException(ErrorCode.CAT_NULL_BILLING_PERIOD);
    }
    final String inputOrDefaultPricelist = (spec.getPriceListName() == null) ? PriceListSet.DEFAULT_PRICELIST_NAME : spec.getPriceListName();
    final Product product = findCurrentProduct(spec.getProductName());
    result = priceLists.getPlanFrom(product, spec.getBillingPeriod(), inputOrDefaultPricelist);
  }
  if (result == null) {
    throw new CatalogApiException(ErrorCode.CAT_PLAN_NOT_FOUND,
                   spec.getPlanName() != null ? spec.getPlanName() : "undefined",
                   spec.getProductName() != null ? spec.getProductName() : "undefined",
                   spec.getBillingPeriod() != null ? spec.getBillingPeriod() : "undefined",
                   spec.getPriceListName() != null ? spec.getPriceListName() : "undefined");
  }
  return result;
}
origin: killbill/killbill

  protected void assertion(final Result result, final DefaultCaseChangeResult cr,
               final String fromProductName, final String toProductName,
               final BillingPeriod fromBp, final BillingPeriod toBp,
               final String fromPriceListName, final String toPriceListName,
               final PhaseType phaseType, final StandaloneCatalog cat) {
    try {
      Assert.assertEquals(result, cr.getResult(new PlanPhaseSpecifier(fromProductName, fromBp, fromPriceListName, phaseType),
                           new PlanSpecifier(toProductName, toBp, toPriceListName), cat));
    } catch (CatalogApiException e) {
      Assert.fail("", e);
    }
  }
}
origin: org.kill-bill.billing/killbill-catalog

public PlanChangeResult planChange(final PlanPhaseSpecifier from, final PlanSpecifier to, final StaticCatalog catalog) throws CatalogApiException {
  final DefaultPriceList toPriceList = to.getPriceListName() != null ?
                     (DefaultPriceList) catalog.findCurrentPricelist(to.getPriceListName()) :
                     findPriceList(from, catalog);
  // If we use old scheme {product, billingPeriod, pricelist}, ensure pricelist is correct
  // (Pricelist may be null because if it is unspecified this is the principal use-case)
  final PlanSpecifier toWithPriceList = to.getPlanName() == null ?
                     new PlanSpecifier(to.getProductName(), to.getBillingPeriod(), toPriceList.getName()) :
                     to;
  final BillingActionPolicy policy = getPlanChangePolicy(from, toWithPriceList, catalog);
  if (policy == BillingActionPolicy.ILLEGAL) {
    throw new IllegalPlanChange(from, toWithPriceList);
  }
  final PlanAlignmentChange alignment = getPlanChangeAlignment(from, toWithPriceList, catalog);
  return new PlanChangeResult(toPriceList, policy, alignment);
}
org.killbill.billing.catalog.apiPlanSpecifier

Javadoc

The class PlanSpecifier specifies the attributes of a Plan

Most used methods

  • <init>
  • getBillingPeriod
  • getPriceListName
  • getProductName
  • getPlanName

Popular in Java

  • Making http post requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • getSupportFragmentManager (FragmentActivity)
  • requestLocationUpdates (LocationManager)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now