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

org.yangcentral.yangkit.model.impl.codec.EmptyStringValueCodecImpl Maven / Gradle / Ivy

There is a newer version: 1.4.5
Show newest version
package org.yangcentral.yangkit.model.impl.codec;

import org.yangcentral.yangkit.base.ErrorCode;
import org.yangcentral.yangkit.model.api.codec.EmptyStringValueCodec;
import org.yangcentral.yangkit.model.api.codec.YangCodecException;
import org.yangcentral.yangkit.model.api.restriction.Restriction;
import org.apache.commons.lang3.ObjectUtils;

public class EmptyStringValueCodecImpl extends StringValueCodecImpl implements EmptyStringValueCodec {
   public ObjectUtils.Null deserialize(Restriction restriction, String input) throws YangCodecException {
      if (input != null && input.length() == 0) {
         return ObjectUtils.NULL;
      } else {
         throw new YangCodecException(ErrorCode.INVALID_VALUE.getFieldName());
      }
   }

   public String serialize(Restriction restriction, ObjectUtils.Null output) throws YangCodecException {
      return "";
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy