CLValueU128.java

  1. package com.syntifi.casper.sdk.model.clvalue;

  2. import com.fasterxml.jackson.annotation.JsonGetter;
  3. import com.fasterxml.jackson.annotation.JsonSetter;
  4. import com.syntifi.casper.sdk.annotation.ExcludeFromJacocoGeneratedReport;
  5. import com.syntifi.casper.sdk.exception.CLValueDecodeException;
  6. import com.syntifi.casper.sdk.exception.CLValueEncodeException;
  7. import com.syntifi.casper.sdk.exception.NoSuchTypeException;
  8. import com.syntifi.casper.sdk.model.clvalue.cltype.CLTypeU128;
  9. import com.syntifi.casper.sdk.model.clvalue.encdec.CLValueDecoder;
  10. import com.syntifi.casper.sdk.model.clvalue.encdec.CLValueEncoder;
  11. import lombok.EqualsAndHashCode;
  12. import lombok.Getter;
  13. import lombok.NoArgsConstructor;
  14. import lombok.Setter;

  15. import java.io.IOException;
  16. import java.math.BigInteger;

  17. /**
  18.  * Casper U128 CLValue implementation
  19.  *
  20.  * @author Alexandre Carvalho
  21.  * @author Andre Bertolace
  22.  * @see AbstractCLValue
  23.  * @since 0.0.1
  24.  */
  25. @Getter
  26. @Setter
  27. @EqualsAndHashCode(callSuper = true)
  28. @NoArgsConstructor
  29. public class CLValueU128 extends AbstractCLValue<BigInteger, CLTypeU128> {
  30.     private CLTypeU128 clType = new CLTypeU128();

  31.     @JsonSetter("cl_type")
  32.     @ExcludeFromJacocoGeneratedReport
  33.     protected void setJsonClType(CLTypeU128 clType) {
  34.         this.clType = clType;
  35.     }

  36.     @JsonGetter("cl_type")
  37.     @ExcludeFromJacocoGeneratedReport
  38.     protected String getJsonClType() {
  39.         return this.getClType().getTypeName();
  40.     }

  41.     public CLValueU128(BigInteger value) {
  42.         this.setValue(value);
  43.     }

  44.     @Override
  45.     public void encode(CLValueEncoder clve, boolean encodeType) throws IOException, CLValueEncodeException, NoSuchTypeException {
  46.         clve.writeU128(this);
  47.         if (encodeType) {
  48.             this.encodeType(clve);
  49.         }
  50.     }

  51.     @Override
  52.     public void decode(CLValueDecoder clvd) throws IOException, CLValueDecodeException {
  53.         clvd.readU128(this);
  54.     }
  55. }