Class MoneyBuilder

java.lang.Object
com.commercetools.history.models.common.MoneyBuilder
All Implemented Interfaces:
Builder<Money>

public class MoneyBuilder extends Object implements Builder<Money>
MoneyBuilder
Example to create an instance using the builder pattern

     Money money = Money.builder()
             .currencyCode("{currencyCode}")
             .centAmount(1)
             .fractionDigits(1)
             .type(MoneyType.CENT_PRECISION)
             .build()
 
  • Constructor Details

    • MoneyBuilder

      public MoneyBuilder()
  • Method Details

    • currencyCode

      public MoneyBuilder currencyCode(String currencyCode)

      Currency code compliant to ISO 4217.

      Parameters:
      currencyCode - value to be set
      Returns:
      Builder
    • centAmount

      public MoneyBuilder centAmount(Integer centAmount)
      set the value to the centAmount
      Parameters:
      centAmount - value to be set
      Returns:
      Builder
    • fractionDigits

      public MoneyBuilder fractionDigits(Integer fractionDigits)
      set the value to the fractionDigits
      Parameters:
      fractionDigits - value to be set
      Returns:
      Builder
    • type

      public MoneyBuilder type(MoneyType type)
      set the value to the type
      Parameters:
      type - value to be set
      Returns:
      Builder
    • getCurrencyCode

      public String getCurrencyCode()

      Currency code compliant to ISO 4217.

      Returns:
      currencyCode
    • getCentAmount

      public Integer getCentAmount()
      value of centAmount}
      Returns:
      centAmount
    • getFractionDigits

      public Integer getFractionDigits()
      value of fractionDigits}
      Returns:
      fractionDigits
    • getType

      public MoneyType getType()
      value of type}
      Returns:
      type
    • build

      public Money build()
      builds Money with checking for non-null required values
      Specified by:
      build in interface Builder<Money>
      Returns:
      Money
    • buildUnchecked

      public Money buildUnchecked()
      builds Money without checking for non-null required values
      Returns:
      Money
    • of

      public static MoneyBuilder of()
      factory method for an instance of MoneyBuilder
      Returns:
      builder
    • of

      public static MoneyBuilder of(Money template)
      create builder for Money instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder