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

org.infinispan.protostream.sampledomain.marshallers.GenderMarshaller Maven / Gradle / Ivy

package org.infinispan.protostream.sampledomain.marshallers;

import org.infinispan.protostream.EnumMarshaller;
import org.infinispan.protostream.sampledomain.User;

/**
 * @author [email protected]
 * @deprecated This marshalling mechanism will be removed in 5. Please switch to annotation based marshalling.
 */
@Deprecated
public class GenderMarshaller implements EnumMarshaller {

   @Override
   public Class getJavaClass() {
      return User.Gender.class;
   }

   @Override
   public String getTypeName() {
      return "sample_bank_account.User.Gender";
   }

   @Override
   public User.Gender decode(int enumValue) {
      switch (enumValue) {
         case 0:
            return User.Gender.MALE;
         case 1:
            return User.Gender.FEMALE;
      }
      return null;  // unknown value
   }

   @Override
   public int encode(User.Gender gender) {
      switch (gender) {
         case MALE:
            return 0;
         case FEMALE:
            return 1;
         default:
            throw new IllegalArgumentException("Unexpected User.Gender value : " + gender);
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy