/* (non-Javadoc)
@see net.finmath.marketdata.model.curves.ForwardCurveInterface#getPaymentOffset(double)
511572
@Override
	public double getPaymentOffset(double fixingTime) {
		if(paymentOffsetCode == null) {
			return paymentOffset;
		}

		if(paymentOffsets.containsKey(fixingTime)) {
			return paymentOffsets.get(fixingTime);
		}
		else {
			/**
			 *  @TODO In case paymentDate is relevant for the index modeling, it should be checked
			 *  if the following derivation of paymentDate is accurate (e.g. wo we have a fixingOffset).
			 *  In such a case, this method may be overridden.
			 */
			LocalDate referenceDate = getReferenceDate();
			LocalDate fixingDate = FloatingpointDate.getDateFromFloatingPointDate(referenceDate, fixingTime);
			LocalDate paymentDate = paymentBusinessdayCalendar.getAdjustedDate(fixingDate, paymentOffsetCode, paymentDateRollConvention);
			double paymentTime = FloatingpointDate.getFloatingPointDateFromDate(referenceDate, paymentDate);
			paymentOffsets.put(fixingTime, paymentTime-fixingTime);
			return paymentTime-fixingTime;
		}
	}
1170543
public final void makePrepaymentMatchingReversed(
    final Map<String, Object> pReqVars, final String pPrepayId,
      final BankStatementLine pBsl, final DateFormat pDateFormat,
        final String pLangDef) throws Exception {
    EBankEntryResultType resultRecordType = null;
    EBankEntryResultAction resultAction = null;
    String resultDescription = null;
    Long resultRecordId = null;
    if (pBsl.getItsAmount().compareTo(BigDecimal.ZERO) > 0) {
      PrepaymentFrom prep = getSrvOrm().retrieveEntityById(pReqVars,
        PrepaymentFrom.class, Long.parseLong(pPrepayId));
      if (!prep.getHasMadeAccEntries() || pBsl.getItsAmount().abs()
        .compareTo(prep.getItsTotal().abs()) != 0
          || prep.getSubaccCashType() != 2002 || !pBsl.getItsOwner()
            .getBankAccount().getItsId().equals(prep.getSubaccCashId())) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "record_is_not_matching");
      }
      resultRecordType = EBankEntryResultType.PREPAYMENTFROM;
      if (EBankEntryStatus.VOIDED.equals(pBsl.getItsStatus())
        && prep.getReversedId() == null) {
        resultAction = EBankEntryResultAction.CREATE;
        PrepaymentFrom reversed = prep;
        prep = new PrepaymentFrom();
        prep.setAccCash(reversed.getAccCash());
        prep.setSubaccCash(reversed.getSubaccCash());
        prep.setSubaccCashId(reversed.getSubaccCashId());
        prep.setSubaccCashType(2002);
        prep.setCustomer(reversed.getCustomer());
        prep.setForeignTotal(reversed.getForeignTotal().negate());
        prep.setDescription(makeDescrForCreated(pBsl, pDateFormat, pLangDef)
          + " " + getSrvI18n().getMsg("reversed_n", pLangDef) + reversed
            .getIdDatabaseBirth() + "-" + reversed.getItsId());
        makeDocReversed(pReqVars, prep, reversed, pLangDef);
      } else {
        resultAction = EBankEntryResultAction.MATCH;
      }
      resultRecordId = prep.getItsId();
      resultDescription = makeBslResDescr(resultAction, pDateFormat, prep,
        prep.getItsDate(), pLangDef);
    } else {
      PrepaymentTo prep = getSrvOrm().retrieveEntityById(pReqVars,
        PrepaymentTo.class, Long.parseLong(pPrepayId));
      if (!prep.getHasMadeAccEntries() || pBsl.getItsAmount().abs()
        .compareTo(prep.getItsTotal().abs()) != 0
          || prep.getSubaccCashType() != 2002 || !pBsl.getItsOwner()
            .getBankAccount().getItsId().equals(prep.getSubaccCashId())) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "record_is_not_matching");
      }
      resultRecordType = EBankEntryResultType.PREPAYMENTTO;
      if (EBankEntryStatus.VOIDED.equals(pBsl.getItsStatus())
        && prep.getReversedId() == null) {
        resultAction = EBankEntryResultAction.CREATE;
        PrepaymentTo reversed = prep;
        prep = new PrepaymentTo();
        prep.setAccCash(reversed.getAccCash());
        prep.setSubaccCash(reversed.getSubaccCash());
        prep.setSubaccCashId(reversed.getSubaccCashId());
        prep.setSubaccCashType(2002);
        prep.setVendor(reversed.getVendor());
        prep.setForeignTotal(reversed.getForeignTotal().negate());
        prep.setDescription(makeDescrForCreated(pBsl, pDateFormat, pLangDef)
          + " " + getSrvI18n().getMsg("reversed_n", pLangDef) + reversed
            .getIdDatabaseBirth() + "-" + reversed.getItsId());
        makeDocReversed(pReqVars, prep, reversed, pLangDef);
      } else {
        resultAction = EBankEntryResultAction.MATCH;
      }
      resultRecordId = prep.getItsId();
      resultDescription = makeBslResDescr(resultAction, pDateFormat, prep,
        prep.getItsDate(), pLangDef);
    }
    pBsl.setResultAction(resultAction);
    pBsl.setResultRecordType(resultRecordType);
    pBsl.setResultRecordId(resultRecordId);
    pBsl.setResultDescription(resultDescription);
    getSrvOrm().updateEntity(pReqVars, pBsl);
  }
693678
@Override
    public double getValueAt(final int at) {
        if (userPrecAtCutoff.containsKey(at)) {
            int n = 0;
            double prec = 0.0;
            for (U u : userPrecAtCutoff.get(at).keySet()) {
                double uprec = getValueAt(u, at);
                if (!Double.isNaN(uprec)) {
                    prec += uprec;
                    n++;
                }
            }
            if (n == 0) {
                prec = 0.0;
            } else {
                prec = prec / n;
            }
            return prec;
        }
        return Double.NaN;
    }
105953
@Override
    public int getTransactionTimeout() {
        for (TransactionSettingsProvider s : _serverWideConfigProvider.getTransactionSettingsProviders().services()) {
            if (s.isActive()) {

                final GlobalTransactionSettings gts = s.getGlobalTransactionSettings();

                if (gts != null) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        Tr.debug(tc, "Found a GlobalTransactionSettings");
                    return gts.getTransactionTimeout();
                } else {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        Tr.debug(tc, "No GlobalTransactionSettings on this thread");
                }
            } else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(tc, "Found the TransactionSettingsProvider but it was inactive");
            }
        }

        return -1;
    }
1366070
public static function get(
        int $switchServicePaymentId,
        int $noteTextBankSwitchServiceNetherlandsIncomingPaymentId,
        int $monetaryAccountId = null,
        array $customHeaders = []
    ): BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPayment {
        $apiClient = new ApiClient(static::getApiContext());
        $responseRaw = $apiClient->get(
            vsprintf(
                self::ENDPOINT_URL_READ,
                [
                    static::determineUserId(),
                    static::determineMonetaryAccountId($monetaryAccountId),
                    $switchServicePaymentId,
                    $noteTextBankSwitchServiceNetherlandsIncomingPaymentId,
                ]
            ),
            [],
            $customHeaders
        );

        return BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPayment::castFromBunqResponse(
            static::fromJson($responseRaw, self::OBJECT_TYPE_GET)
        );
    }
17154
@Override
  public final void makeFirstPrepareForSave(final Map<String, Object> pReqVars,
    final PurchaseInvoice pEntity,
      final IRequestData pRequestData) throws Exception {
    if (pEntity.getPrepaymentTo() != null) {
      pEntity.setPrepaymentTo(getSrvOrm()
        .retrieveEntity(pReqVars, pEntity.getPrepaymentTo()));
      if (pEntity.getReversedId() == null && pEntity.getPrepaymentTo()
        .getPurchaseInvoiceId() != null && !pEntity.getHasMadeAccEntries()) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "prepayment_already_in_use");
      }
      if (pEntity.getReversedId() == null && !pEntity.getPrepaymentTo()
        .getVendor().getItsId().equals(pEntity.getVendor().getItsId())) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "prepayment_for_different_vendor");
      }
    }
    if (pEntity.getReversedId() != null && pEntity.getPrepaymentTo() != null
      && pEntity.getPaymentTotal().compareTo(pEntity.getPrepaymentTo()
        .getItsTotal()) != 0) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "reverse_payments_first");
    }
    if (pEntity.getReversedId() != null && pEntity.getPrepaymentTo() == null
      && pEntity.getPaymentTotal().compareTo(BigDecimal.ZERO) != 0) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "reverse_payments_first");
    }
    if (pEntity.getReversedId() == null) {
      calculateTotalPayment(pReqVars, pEntity);
    }
    if (!pEntity.getIsNew()) {
      pReqVars.put("DebtorCreditortaxDestinationdeepLevel", 2);
      Set<String> ndFlDc = new HashSet<String>();
      ndFlDc.add("itsId");
      ndFlDc.add("isForeigner");
      ndFlDc.add("taxDestination");
      pReqVars.put("DebtorCreditorneededFields", ndFlDc);
    }
  }
649428
@Override
    public synchronized Coin getFeePaid() {
        stateMachine.checkState(State.CLOSED, State.CLOSING);
        return feePaidForPayment;
    }
59366
public Wallet getWallet() {

    if (wallets.size() != 1) {
      throw new UnsupportedOperationException(wallets.size() + " wallets in account");
    }

    return getWallet(wallets.keySet().iterator().next());
  }
698423
public com.liferay.commerce.tax.engine.fixed.service.CommerceTaxFixedRateService getCommerceTaxFixedRateService() {
		return commerceTaxFixedRateService;
	}
262879
@Override
	public RandomVariable getDiscountFactor(AnalyticModel model, double maturity) {
		ForwardCurveInterface	forwardCurve;
		if(this.forwardCurve != null) {
			forwardCurve = this.forwardCurve;
		} else {
			forwardCurve = model.getForwardCurve(forwardCurveName);
		}

		if(forwardCurve == null) {
			throw new IllegalArgumentException("No forward curve given and no forward curve found in the model under the name " + forwardCurveName + ".");
		}
		RandomVariable discountFactor = new RandomVariableFromDoubleArray(1.0);
		double	time			= 0;
		double paymentOffset = 0;
		while(time < maturity) {
			paymentOffset	= forwardCurve.getPaymentOffset(time);
			if(paymentOffset <= 0) {
				throw new RuntimeException("Trying to calculate a discount curve from a forward curve with non-positive payment offset.");
			}
			discountFactor = forwardCurve.getForward(model, time).mult(Math.min(paymentOffset, maturity-time) * timeScaling).add(1.0).pow(-1.0).mult(discountFactor);
			time += paymentOffset;
		}

		return discountFactor;
	}
173580
private int getServiceNameOffset(final int servAreaOffset) {
        // if there are other services which have been written
        if (prevServiceOffset != 0) {
            return prevServiceOffset + prevServiceName.length() + BitUtil.SIZE_OF_INT + BitUtil.SIZE_OF_INT;
        }
        // else
        return servAreaOffset;
    }
394798
public boolean getForwardScanning()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.entry(tc, "getForwardScanning");
            SibTr.exit(tc, "getForwardScanning", Boolean.valueOf(_forwardScanning));
        }

        return _forwardScanning;
    }
718474
public ApiSuccessResponse forward(ForwardData forwardData) throws ApiException {
        ApiResponse<ApiSuccessResponse> resp = forwardWithHttpInfo(forwardData);
        return resp.getData();
    }
564857
public com.google.api.ads.adwords.axis.v201809.cm.AppPaymentModelAppPaymentModelType getAppPaymentModelType() {
        return appPaymentModelType;
    }
1194277
protected int getDigestOffset2(byte[] handshake, int bufferOffset) {
        bufferOffset += 772;
        int offset = handshake[bufferOffset] & 0xff; // & 0x0ff;
        bufferOffset++;
        offset += handshake[bufferOffset] & 0xff;
        bufferOffset++;
        offset += handshake[bufferOffset] & 0xff;
        bufferOffset++;
        offset += handshake[bufferOffset] & 0xff;
        int res = Math.abs((offset % 728) + 776);
        if (res + DIGEST_LENGTH > 1535) {
            log.error("Invalid digest offset calc: {}", res);
        }
        return res;
    }
1262474
@Override
    int guessPayloadLength() {
        int length = 0;
        byte[] payload = getDataFromPayload();
        if (payload != null) {
            length = payload.length + 24;
        }
        return length;
    }
54944
@Override
    public double getValueAt(final U user, final int at) {
        if (userRecallAtCutoff.containsKey(at) && userRecallAtCutoff.get(at).containsKey(user)) {
            return userRecallAtCutoff.get(at).get(user) / userTotalRecall.get(user);
        }
        return Double.NaN;
    }