org.zodiac.netty.http.headers.UriHeader Maven / Gradle / Ivy
package org.zodiac.netty.http.headers;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final class UriHeader extends AbstractHeader {
private Logger log = LoggerFactory.getLogger(getClass());
UriHeader(CharSequence name) {
super(URI.class, name);
}
@Override
public String toString(URI value) {
return Objects.requireNonNull(value,"value").toString();
}
@Override
public URI toValue(CharSequence value) {
try {
return new URI(Objects.requireNonNull(value,"value").toString());
} catch (URISyntaxException ex) {
log.warn(String.format("Bad URI in %s - %s", name(), value), ex);
return null;
}
}
}