rippled
Loading...
Searching...
No Matches
Loan.h
1// This file is auto-generated. Do not edit.
2#pragma once
3
4#include <xrpl/protocol/STLedgerEntry.h>
5#include <xrpl/protocol/STParsedJSON.h>
6#include <xrpl/protocol/jss.h>
7#include <xrpl/protocol_autogen/LedgerEntryBase.h>
8#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
9#include <xrpl/json/json_value.h>
10
11#include <stdexcept>
12#include <optional>
13
14namespace xrpl::ledger_entries {
15
16class LoanBuilder;
17
27class Loan : public LedgerEntryBase
28{
29public:
30 static constexpr LedgerEntryType entryType = ltLOAN;
31
37 : LedgerEntryBase(std::move(sle))
38 {
39 // Verify ledger entry type
40 if (sle_->getType() != entryType)
41 {
42 throw std::runtime_error("Invalid ledger entry type for Loan");
43 }
44 }
45
46 // Ledger entry-specific field getters
47
52 [[nodiscard]]
53 SF_UINT256::type::value_type
55 {
56 return this->sle_->at(sfPreviousTxnID);
57 }
58
63 [[nodiscard]]
64 SF_UINT32::type::value_type
66 {
67 return this->sle_->at(sfPreviousTxnLgrSeq);
68 }
69
74 [[nodiscard]]
75 SF_UINT64::type::value_type
77 {
78 return this->sle_->at(sfOwnerNode);
79 }
80
85 [[nodiscard]]
86 SF_UINT64::type::value_type
88 {
89 return this->sle_->at(sfLoanBrokerNode);
90 }
91
96 [[nodiscard]]
97 SF_UINT256::type::value_type
99 {
100 return this->sle_->at(sfLoanBrokerID);
101 }
102
107 [[nodiscard]]
108 SF_UINT32::type::value_type
110 {
111 return this->sle_->at(sfLoanSequence);
112 }
113
118 [[nodiscard]]
119 SF_ACCOUNT::type::value_type
121 {
122 return this->sle_->at(sfBorrower);
123 }
124
129 [[nodiscard]]
132 {
134 return this->sle_->at(sfLoanOriginationFee);
135 return std::nullopt;
136 }
137
142 [[nodiscard]]
143 bool
145 {
146 return this->sle_->isFieldPresent(sfLoanOriginationFee);
147 }
148
153 [[nodiscard]]
156 {
157 if (hasLoanServiceFee())
158 return this->sle_->at(sfLoanServiceFee);
159 return std::nullopt;
160 }
161
166 [[nodiscard]]
167 bool
169 {
170 return this->sle_->isFieldPresent(sfLoanServiceFee);
171 }
172
177 [[nodiscard]]
180 {
181 if (hasLatePaymentFee())
182 return this->sle_->at(sfLatePaymentFee);
183 return std::nullopt;
184 }
185
190 [[nodiscard]]
191 bool
193 {
194 return this->sle_->isFieldPresent(sfLatePaymentFee);
195 }
196
201 [[nodiscard]]
204 {
205 if (hasClosePaymentFee())
206 return this->sle_->at(sfClosePaymentFee);
207 return std::nullopt;
208 }
209
214 [[nodiscard]]
215 bool
217 {
218 return this->sle_->isFieldPresent(sfClosePaymentFee);
219 }
220
225 [[nodiscard]]
228 {
229 if (hasOverpaymentFee())
230 return this->sle_->at(sfOverpaymentFee);
231 return std::nullopt;
232 }
233
238 [[nodiscard]]
239 bool
241 {
242 return this->sle_->isFieldPresent(sfOverpaymentFee);
243 }
244
249 [[nodiscard]]
252 {
253 if (hasInterestRate())
254 return this->sle_->at(sfInterestRate);
255 return std::nullopt;
256 }
257
262 [[nodiscard]]
263 bool
265 {
266 return this->sle_->isFieldPresent(sfInterestRate);
267 }
268
273 [[nodiscard]]
276 {
278 return this->sle_->at(sfLateInterestRate);
279 return std::nullopt;
280 }
281
286 [[nodiscard]]
287 bool
289 {
290 return this->sle_->isFieldPresent(sfLateInterestRate);
291 }
292
297 [[nodiscard]]
300 {
302 return this->sle_->at(sfCloseInterestRate);
303 return std::nullopt;
304 }
305
310 [[nodiscard]]
311 bool
313 {
314 return this->sle_->isFieldPresent(sfCloseInterestRate);
315 }
316
321 [[nodiscard]]
324 {
326 return this->sle_->at(sfOverpaymentInterestRate);
327 return std::nullopt;
328 }
329
334 [[nodiscard]]
335 bool
337 {
338 return this->sle_->isFieldPresent(sfOverpaymentInterestRate);
339 }
340
345 [[nodiscard]]
346 SF_UINT32::type::value_type
348 {
349 return this->sle_->at(sfStartDate);
350 }
351
356 [[nodiscard]]
357 SF_UINT32::type::value_type
359 {
360 return this->sle_->at(sfPaymentInterval);
361 }
362
367 [[nodiscard]]
370 {
371 if (hasGracePeriod())
372 return this->sle_->at(sfGracePeriod);
373 return std::nullopt;
374 }
375
380 [[nodiscard]]
381 bool
383 {
384 return this->sle_->isFieldPresent(sfGracePeriod);
385 }
386
391 [[nodiscard]]
394 {
396 return this->sle_->at(sfPreviousPaymentDueDate);
397 return std::nullopt;
398 }
399
404 [[nodiscard]]
405 bool
407 {
408 return this->sle_->isFieldPresent(sfPreviousPaymentDueDate);
409 }
410
415 [[nodiscard]]
418 {
420 return this->sle_->at(sfNextPaymentDueDate);
421 return std::nullopt;
422 }
423
428 [[nodiscard]]
429 bool
431 {
432 return this->sle_->isFieldPresent(sfNextPaymentDueDate);
433 }
434
439 [[nodiscard]]
442 {
444 return this->sle_->at(sfPaymentRemaining);
445 return std::nullopt;
446 }
447
452 [[nodiscard]]
453 bool
455 {
456 return this->sle_->isFieldPresent(sfPaymentRemaining);
457 }
458
463 [[nodiscard]]
464 SF_NUMBER::type::value_type
466 {
467 return this->sle_->at(sfPeriodicPayment);
468 }
469
474 [[nodiscard]]
477 {
479 return this->sle_->at(sfPrincipalOutstanding);
480 return std::nullopt;
481 }
482
487 [[nodiscard]]
488 bool
490 {
491 return this->sle_->isFieldPresent(sfPrincipalOutstanding);
492 }
493
498 [[nodiscard]]
501 {
503 return this->sle_->at(sfTotalValueOutstanding);
504 return std::nullopt;
505 }
506
511 [[nodiscard]]
512 bool
514 {
515 return this->sle_->isFieldPresent(sfTotalValueOutstanding);
516 }
517
522 [[nodiscard]]
525 {
527 return this->sle_->at(sfManagementFeeOutstanding);
528 return std::nullopt;
529 }
530
535 [[nodiscard]]
536 bool
538 {
539 return this->sle_->isFieldPresent(sfManagementFeeOutstanding);
540 }
541
546 [[nodiscard]]
549 {
550 if (hasLoanScale())
551 return this->sle_->at(sfLoanScale);
552 return std::nullopt;
553 }
554
559 [[nodiscard]]
560 bool
562 {
563 return this->sle_->isFieldPresent(sfLoanScale);
564 }
565};
566
574class LoanBuilder : public LedgerEntryBuilderBase<LoanBuilder>
575{
576public:
604
611 {
612 if (sle->at(sfLedgerEntryType) != ltLOAN)
613 {
614 throw std::runtime_error("Invalid ledger entry type for Loan");
615 }
616 object_ = *sle;
617 }
618
627 {
628 object_[sfPreviousTxnID] = value;
629 return *this;
630 }
631
638 {
639 object_[sfPreviousTxnLgrSeq] = value;
640 return *this;
641 }
642
649 {
650 object_[sfOwnerNode] = value;
651 return *this;
652 }
653
660 {
661 object_[sfLoanBrokerNode] = value;
662 return *this;
663 }
664
671 {
672 object_[sfLoanBrokerID] = value;
673 return *this;
674 }
675
682 {
683 object_[sfLoanSequence] = value;
684 return *this;
685 }
686
693 {
694 object_[sfBorrower] = value;
695 return *this;
696 }
697
704 {
705 object_[sfLoanOriginationFee] = value;
706 return *this;
707 }
708
715 {
716 object_[sfLoanServiceFee] = value;
717 return *this;
718 }
719
726 {
727 object_[sfLatePaymentFee] = value;
728 return *this;
729 }
730
737 {
738 object_[sfClosePaymentFee] = value;
739 return *this;
740 }
741
748 {
749 object_[sfOverpaymentFee] = value;
750 return *this;
751 }
752
759 {
760 object_[sfInterestRate] = value;
761 return *this;
762 }
763
770 {
771 object_[sfLateInterestRate] = value;
772 return *this;
773 }
774
781 {
782 object_[sfCloseInterestRate] = value;
783 return *this;
784 }
785
792 {
793 object_[sfOverpaymentInterestRate] = value;
794 return *this;
795 }
796
803 {
804 object_[sfStartDate] = value;
805 return *this;
806 }
807
814 {
815 object_[sfPaymentInterval] = value;
816 return *this;
817 }
818
825 {
826 object_[sfGracePeriod] = value;
827 return *this;
828 }
829
836 {
837 object_[sfPreviousPaymentDueDate] = value;
838 return *this;
839 }
840
847 {
848 object_[sfNextPaymentDueDate] = value;
849 return *this;
850 }
851
858 {
859 object_[sfPaymentRemaining] = value;
860 return *this;
861 }
862
869 {
870 object_[sfPeriodicPayment] = value;
871 return *this;
872 }
873
880 {
881 object_[sfPrincipalOutstanding] = value;
882 return *this;
883 }
884
891 {
892 object_[sfTotalValueOutstanding] = value;
893 return *this;
894 }
895
902 {
903 object_[sfManagementFeeOutstanding] = value;
904 return *this;
905 }
906
913 {
914 object_[sfLoanScale] = value;
915 return *this;
916 }
917
923 Loan
924 build(uint256 const& index)
925 {
926 return Loan{std::make_shared<SLE>(std::move(object_), index)};
927 }
928};
929
930} // namespace xrpl::ledger_entries
Base class for type-safe ledger entry wrappers.
std::shared_ptr< SLE const > sle_
The underlying serialized ledger entry being wrapped.
Base class for all ledger entry builders.
Builder for Loan ledger entries.
Definition Loan.h:575
LoanBuilder & setCloseInterestRate(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfCloseInterestRate (soeDEFAULT)
Definition Loan.h:780
LoanBuilder & setGracePeriod(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfGracePeriod (soeDEFAULT)
Definition Loan.h:824
LoanBuilder & setLoanServiceFee(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfLoanServiceFee (soeDEFAULT)
Definition Loan.h:714
LoanBuilder & setOwnerNode(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfOwnerNode (soeREQUIRED)
Definition Loan.h:648
LoanBuilder & setLoanBrokerNode(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfLoanBrokerNode (soeREQUIRED)
Definition Loan.h:659
Loan build(uint256 const &index)
Build and return the completed Loan wrapper.
Definition Loan.h:924
LoanBuilder & setBorrower(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfBorrower (soeREQUIRED)
Definition Loan.h:692
LoanBuilder & setClosePaymentFee(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfClosePaymentFee (soeDEFAULT)
Definition Loan.h:736
LoanBuilder & setLoanOriginationFee(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfLoanOriginationFee (soeDEFAULT)
Definition Loan.h:703
LoanBuilder & setLoanScale(std::decay_t< typename SF_INT32::type::value_type > const &value)
Set sfLoanScale (soeDEFAULT)
Definition Loan.h:912
LoanBuilder & setOverpaymentInterestRate(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfOverpaymentInterestRate (soeDEFAULT)
Definition Loan.h:791
LoanBuilder & setInterestRate(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfInterestRate (soeDEFAULT)
Definition Loan.h:758
LoanBuilder & setPreviousTxnLgrSeq(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfPreviousTxnLgrSeq (soeREQUIRED)
Definition Loan.h:637
LoanBuilder & setOverpaymentFee(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfOverpaymentFee (soeDEFAULT)
Definition Loan.h:747
LoanBuilder & setPaymentInterval(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfPaymentInterval (soeREQUIRED)
Definition Loan.h:813
LoanBuilder & setLoanSequence(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfLoanSequence (soeREQUIRED)
Definition Loan.h:681
LoanBuilder & setStartDate(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfStartDate (soeREQUIRED)
Definition Loan.h:802
LoanBuilder & setPrincipalOutstanding(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfPrincipalOutstanding (soeDEFAULT)
Definition Loan.h:879
LoanBuilder & setTotalValueOutstanding(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfTotalValueOutstanding (soeDEFAULT)
Definition Loan.h:890
LoanBuilder & setLoanBrokerID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Set sfLoanBrokerID (soeREQUIRED)
Definition Loan.h:670
LoanBuilder & setLatePaymentFee(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfLatePaymentFee (soeDEFAULT)
Definition Loan.h:725
LoanBuilder & setPreviousPaymentDueDate(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfPreviousPaymentDueDate (soeDEFAULT)
Definition Loan.h:835
LoanBuilder & setManagementFeeOutstanding(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfManagementFeeOutstanding (soeDEFAULT)
Definition Loan.h:901
LoanBuilder(std::shared_ptr< SLE const > sle)
Construct a LoanBuilder from an existing SLE object.
Definition Loan.h:610
LoanBuilder & setPreviousTxnID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Ledger entry-specific field setters.
Definition Loan.h:626
LoanBuilder & setNextPaymentDueDate(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfNextPaymentDueDate (soeDEFAULT)
Definition Loan.h:846
LoanBuilder & setPaymentRemaining(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfPaymentRemaining (soeDEFAULT)
Definition Loan.h:857
LoanBuilder & setPeriodicPayment(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfPeriodicPayment (soeREQUIRED)
Definition Loan.h:868
LoanBuilder(std::decay_t< typename SF_UINT256::type::value_type > const &previousTxnID, std::decay_t< typename SF_UINT32::type::value_type > const &previousTxnLgrSeq, std::decay_t< typename SF_UINT64::type::value_type > const &ownerNode, std::decay_t< typename SF_UINT64::type::value_type > const &loanBrokerNode, std::decay_t< typename SF_UINT256::type::value_type > const &loanBrokerID, std::decay_t< typename SF_UINT32::type::value_type > const &loanSequence, std::decay_t< typename SF_ACCOUNT::type::value_type > const &borrower, std::decay_t< typename SF_UINT32::type::value_type > const &startDate, std::decay_t< typename SF_UINT32::type::value_type > const &paymentInterval, std::decay_t< typename SF_NUMBER::type::value_type > const &periodicPayment)
Construct a new LoanBuilder with required fields.
Definition Loan.h:590
LoanBuilder & setLateInterestRate(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfLateInterestRate (soeDEFAULT)
Definition Loan.h:769
Ledger Entry: Loan.
Definition Loan.h:28
protocol_autogen::Optional< SF_UINT32::type::value_type > getLateInterestRate() const
Get sfLateInterestRate (soeDEFAULT)
Definition Loan.h:275
bool hasLoanScale() const
Check if sfLoanScale is present.
Definition Loan.h:561
protocol_autogen::Optional< SF_UINT32::type::value_type > getPaymentRemaining() const
Get sfPaymentRemaining (soeDEFAULT)
Definition Loan.h:441
bool hasLoanOriginationFee() const
Check if sfLoanOriginationFee is present.
Definition Loan.h:144
protocol_autogen::Optional< SF_UINT32::type::value_type > getCloseInterestRate() const
Get sfCloseInterestRate (soeDEFAULT)
Definition Loan.h:299
Loan(std::shared_ptr< SLE const > sle)
Construct a Loan ledger entry wrapper from an existing SLE object.
Definition Loan.h:36
bool hasNextPaymentDueDate() const
Check if sfNextPaymentDueDate is present.
Definition Loan.h:430
SF_UINT64::type::value_type getOwnerNode() const
Get sfOwnerNode (soeREQUIRED)
Definition Loan.h:76
bool hasPrincipalOutstanding() const
Check if sfPrincipalOutstanding is present.
Definition Loan.h:489
protocol_autogen::Optional< SF_NUMBER::type::value_type > getLatePaymentFee() const
Get sfLatePaymentFee (soeDEFAULT)
Definition Loan.h:179
protocol_autogen::Optional< SF_UINT32::type::value_type > getNextPaymentDueDate() const
Get sfNextPaymentDueDate (soeDEFAULT)
Definition Loan.h:417
SF_UINT32::type::value_type getPaymentInterval() const
Get sfPaymentInterval (soeREQUIRED)
Definition Loan.h:358
protocol_autogen::Optional< SF_NUMBER::type::value_type > getClosePaymentFee() const
Get sfClosePaymentFee (soeDEFAULT)
Definition Loan.h:203
protocol_autogen::Optional< SF_INT32::type::value_type > getLoanScale() const
Get sfLoanScale (soeDEFAULT)
Definition Loan.h:548
protocol_autogen::Optional< SF_UINT32::type::value_type > getGracePeriod() const
Get sfGracePeriod (soeDEFAULT)
Definition Loan.h:369
SF_UINT256::type::value_type getPreviousTxnID() const
Get sfPreviousTxnID (soeREQUIRED)
Definition Loan.h:54
protocol_autogen::Optional< SF_NUMBER::type::value_type > getPrincipalOutstanding() const
Get sfPrincipalOutstanding (soeDEFAULT)
Definition Loan.h:476
protocol_autogen::Optional< SF_UINT32::type::value_type > getOverpaymentFee() const
Get sfOverpaymentFee (soeDEFAULT)
Definition Loan.h:227
static constexpr LedgerEntryType entryType
Definition Loan.h:30
SF_UINT256::type::value_type getLoanBrokerID() const
Get sfLoanBrokerID (soeREQUIRED)
Definition Loan.h:98
bool hasOverpaymentFee() const
Check if sfOverpaymentFee is present.
Definition Loan.h:240
protocol_autogen::Optional< SF_NUMBER::type::value_type > getManagementFeeOutstanding() const
Get sfManagementFeeOutstanding (soeDEFAULT)
Definition Loan.h:524
bool hasManagementFeeOutstanding() const
Check if sfManagementFeeOutstanding is present.
Definition Loan.h:537
protocol_autogen::Optional< SF_UINT32::type::value_type > getOverpaymentInterestRate() const
Get sfOverpaymentInterestRate (soeDEFAULT)
Definition Loan.h:323
SF_ACCOUNT::type::value_type getBorrower() const
Get sfBorrower (soeREQUIRED)
Definition Loan.h:120
bool hasTotalValueOutstanding() const
Check if sfTotalValueOutstanding is present.
Definition Loan.h:513
protocol_autogen::Optional< SF_NUMBER::type::value_type > getLoanServiceFee() const
Get sfLoanServiceFee (soeDEFAULT)
Definition Loan.h:155
protocol_autogen::Optional< SF_NUMBER::type::value_type > getLoanOriginationFee() const
Get sfLoanOriginationFee (soeDEFAULT)
Definition Loan.h:131
bool hasLoanServiceFee() const
Check if sfLoanServiceFee is present.
Definition Loan.h:168
bool hasLateInterestRate() const
Check if sfLateInterestRate is present.
Definition Loan.h:288
bool hasClosePaymentFee() const
Check if sfClosePaymentFee is present.
Definition Loan.h:216
SF_UINT32::type::value_type getStartDate() const
Get sfStartDate (soeREQUIRED)
Definition Loan.h:347
bool hasPreviousPaymentDueDate() const
Check if sfPreviousPaymentDueDate is present.
Definition Loan.h:406
bool hasInterestRate() const
Check if sfInterestRate is present.
Definition Loan.h:264
protocol_autogen::Optional< SF_NUMBER::type::value_type > getTotalValueOutstanding() const
Get sfTotalValueOutstanding (soeDEFAULT)
Definition Loan.h:500
protocol_autogen::Optional< SF_UINT32::type::value_type > getInterestRate() const
Get sfInterestRate (soeDEFAULT)
Definition Loan.h:251
SF_UINT32::type::value_type getPreviousTxnLgrSeq() const
Get sfPreviousTxnLgrSeq (soeREQUIRED)
Definition Loan.h:65
SF_UINT32::type::value_type getLoanSequence() const
Get sfLoanSequence (soeREQUIRED)
Definition Loan.h:109
bool hasGracePeriod() const
Check if sfGracePeriod is present.
Definition Loan.h:382
SF_NUMBER::type::value_type getPeriodicPayment() const
Get sfPeriodicPayment (soeREQUIRED)
Definition Loan.h:465
bool hasLatePaymentFee() const
Check if sfLatePaymentFee is present.
Definition Loan.h:192
bool hasPaymentRemaining() const
Check if sfPaymentRemaining is present.
Definition Loan.h:454
SF_UINT64::type::value_type getLoanBrokerNode() const
Get sfLoanBrokerNode (soeREQUIRED)
Definition Loan.h:87
protocol_autogen::Optional< SF_UINT32::type::value_type > getPreviousPaymentDueDate() const
Get sfPreviousPaymentDueDate (soeDEFAULT)
Definition Loan.h:393
bool hasCloseInterestRate() const
Check if sfCloseInterestRate is present.
Definition Loan.h:312
bool hasOverpaymentInterestRate() const
Check if sfOverpaymentInterestRate is present.
Definition Loan.h:336
T is_same_v
STL namespace.
LedgerEntryType
Identifiers for on-ledger objects.