ContractFunction.java

  1. /*
  2.  * @copyright defined in LICENSE.txt
  3.  */

  4. package hera.api.model;

  5. import static hera.util.ValidationUtils.assertNotNull;
  6. import static java.util.Collections.unmodifiableList;

  7. import hera.annotation.ApiAudience;
  8. import hera.annotation.ApiStability;
  9. import java.util.Collections;
  10. import java.util.List;
  11. import lombok.EqualsAndHashCode;
  12. import lombok.Getter;
  13. import lombok.ToString;

  14. @ApiAudience.Public
  15. @ApiStability.Unstable
  16. @ToString
  17. @EqualsAndHashCode
  18. public class ContractFunction {

  19.   @Getter
  20.   protected final String name;

  21.   @Getter
  22.   protected final List<String> argumentNames;

  23.   @Getter
  24.   protected final boolean payable;

  25.   @Getter
  26.   protected final boolean view;

  27.   @Getter
  28.   protected final boolean feeDelegation;

  29.   /**
  30.    * ContractFunction constructor.
  31.    *
  32.    * @param name a function name
  33.    */
  34.   @ApiAudience.Private
  35.   public ContractFunction(final String name) {
  36.     this(name, Collections.<String>emptyList());
  37.   }

  38.   /**
  39.    * ContractFunction constructor.
  40.    *
  41.    * @param name a function name
  42.    * @param argumentNames an argument names
  43.    */
  44.   @ApiAudience.Private
  45.   public ContractFunction(final String name, final List<String> argumentNames) {
  46.     this(name, argumentNames, false, false, false);
  47.   }

  48.   /**
  49.    * ContractFunction constructor.
  50.    *
  51.    * @param name a function name
  52.    * @param payable whether a function is payable or not
  53.    * @param view whether a function is view or not
  54.    * @param feeDelegation whether a function can delegate fee or not
  55.    */
  56.   @ApiAudience.Private
  57.   public ContractFunction(final String name, final boolean payable, final boolean view,
  58.       final boolean feeDelegation) {
  59.     this(name, Collections.<String>emptyList(), payable, view, feeDelegation);
  60.   }

  61.   /**
  62.    * ContractFunction constructor.
  63.    *
  64.    * @param name a function name
  65.    * @param argumentNames an argument names
  66.    * @param payable whether a function is payable or not
  67.    * @param view whether a function is view or not
  68.    * @param feeDelegation whether a function can delegate fee or not
  69.    */
  70.   @ApiAudience.Private
  71.   public ContractFunction(final String name, final List<String> argumentNames,
  72.       final boolean payable, final boolean view, final boolean feeDelegation) {
  73.     assertNotNull(name, "Function name must not null");
  74.     assertNotNull(argumentNames, "Argument names must not null");
  75.     this.name = name;
  76.     this.argumentNames = unmodifiableList(argumentNames);
  77.     this.payable = payable;
  78.     this.view = view;
  79.     this.feeDelegation = feeDelegation;
  80.   }


  81. }