org.yangcentral.yangkit.model.impl.codec.StringStringValueCodecImpl Maven / Gradle / Ivy
package org.yangcentral.yangkit.model.impl.codec;
import org.yangcentral.yangkit.base.ErrorCode;
import org.yangcentral.yangkit.model.api.codec.StringStringValueCodec;
import org.yangcentral.yangkit.model.api.codec.YangCodecException;
import org.yangcentral.yangkit.model.api.restriction.Restriction;
public class StringStringValueCodecImpl extends StringValueCodecImpl implements StringStringValueCodec {
public String deserialize(Restriction restriction, String input) throws YangCodecException {
if (!restriction.evaluated(input)) {
throw new YangCodecException(ErrorCode.INVALID_VALUE.getFieldName());
} else {
return input;
}
}
public String serialize(Restriction restriction, String output) throws YangCodecException {
if (!restriction.evaluated(output)) {
throw new YangCodecException(ErrorCode.INVALID_VALUE.getFieldName());
} else {
return output;
}
}
}