class LineItemBuilder {

    public LineItem build() {
        LineItem.Builder androidPayBuilder = LineItem.newBuilder();
        androidPayBuilder.setCurrencyCode(mCurrency.getCurrencyCode()).setRole(mRole);

        if (mTotalPrice != null) {
            androidPayBuilder.setTotalPrice(PaymentUtils.getPriceString(mTotalPrice, mCurrency));
        }

        if (mUnitPrice != null) {
            androidPayBuilder.setUnitPrice(PaymentUtils.getPriceString(mUnitPrice, mCurrency));
        }

        if (mQuantity != null) {
            if (isWholeNumber(mQuantity)) {
                androidPayBuilder.setQuantity(mQuantity.toBigInteger().toString());
            } else {
                androidPayBuilder.setQuantity(mQuantity.toString());
            }
        }

        if (mTotalPrice == null && mQuantity != null && mUnitPrice != null) {
            mTotalPrice = mQuantity.multiply(
                    BigDecimal.valueOf(mUnitPrice),
                    MathContext.DECIMAL64).longValue();
            androidPayBuilder.setTotalPrice(PaymentUtils.getPriceString(mTotalPrice, mCurrency));
        } else {
            if (!isPriceBreakdownConsistent(mUnitPrice, mQuantity, mTotalPrice)) {
                Log.w(TAG, String.format(Locale.ENGLISH,
                        "Price breakdown of %d * %.1f = %d is off by more than 1 percent",
                        mUnitPrice, mQuantity.floatValue(), mTotalPrice));
            }
        }

        if (mRole != LineItem.Role.REGULAR) {
            androidPayBuilder.setRole(mRole);
        }

        if (!TextUtils.isEmpty(mDescription)) {
            androidPayBuilder.setDescription(mDescription);
        }

        return androidPayBuilder.build();
    }

      LineItemBuilder();
      LineItemBuilder(String currencyCode);

}