org.yangcentral.yangkit.model.impl.codec.EmptyStringValueCodecImpl Maven / Gradle / Ivy
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 "";
}
}