All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.protostream.annotations.impl.ProtoEnumValueMetadata Maven / Gradle / Ivy

Go to download

Users need to implement a marshaller object that interacts with a field writer/reader in order to serialize state.

There is a newer version: 14.0.0.CR2
Show newest version
package org.infinispan.protostream.annotations.impl;

import org.infinispan.protostream.annotations.ProtoSyntax;

/**
 * @author [email protected]
 * @since 3.0
 */
public final class ProtoEnumValueMetadata implements HasProtoSchema {

   private final int number;

   private final String protoName;

   private final int javaEnumOrdinal;

   private final String javaEnumName;

   private final String documentation;

   ProtoEnumValueMetadata(int number, String protoName, int javaEnumOrdinal, String javaEnumName, String documentation) {
      this.number = number;
      this.protoName = protoName;
      this.javaEnumOrdinal = javaEnumOrdinal;
      this.javaEnumName = javaEnumName;
      this.documentation = documentation;
   }

   /**
    * Returns the Protobuf number associated to this enum value.
    */
   public int getNumber() {
      return number;
   }

   /**
    * Returns the Protobuf name of this enum value.
    */
   public String getProtoName() {
      return protoName;
   }

   /**
    * Returns the ordinal of the Java enum constant.
    */
   public int getJavaEnumOrdinal() {
      return javaEnumOrdinal;
   }

   /**
    * Returns the FQN of the Java enum constant.
    */
   public String getJavaEnumName() {
      return javaEnumName;
   }

   /**
    * Returns the documentation attached to this enum.
    */
   public String getDocumentation() {
      return documentation;
   }

   @Override
   public void generateProto(IndentWriter iw, ProtoSyntax syntax) {
      iw.append("\n");
      ProtoTypeMetadata.appendDocumentation(iw, documentation);
      iw.append(protoName).append(" = ").append(String.valueOf(number));
      if (BaseProtoSchemaGenerator.generateSchemaDebugComments) {
         iw.append(" /* ").append(javaEnumName).append(" */");
      }
      iw.append(";\n");
   }

   @Override
   public String toString() {
      return "ProtoEnumValueMetadata{" +
            "number=" + number +
            ", protoName='" + protoName + '\'' +
            ", javaEnumOrdinal=" + javaEnumOrdinal +
            ", javaEnumName='" + javaEnumName + '\'' +
            ", documentation='" + documentation + '\'' +
            '}';
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy