package io.vertx.ext.web.impl;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import io.vertx.ext.web.ParsedHeaderValue;
public class implements ParsedHeaderValue {
private final String ;
protected String ;
private float ;
private Map<String, String> ;
private int ;
public (String headerContent) {
Objects.requireNonNull(headerContent, "headerContent must not be null");
this.headerContent = headerContent;
value = null;
weight = -1;
parameter = Collections.emptyMap();
}
@Override
public String () {
return headerContent;
}
@Override
public String () {
ensureHeaderProcessed();
return value;
}
@Override
public float () {
ensureHeaderProcessed();
return weight;
}
@Override
public boolean () {
ensureHeaderProcessed();
return weight < 0.001;
}
public String (String key) {
ensureHeaderProcessed();
return parameter.get(key);
}
public Map<String, String> () {
ensureHeaderProcessed();
return Collections.unmodifiableMap(parameter);
}
public final boolean (ParsedHeaderValue matchTry){
ParsableHeaderValue impl = (ParsableHeaderValue) matchTry;
return this.headerContent.equals(impl.headerContent) || isMatchedBy2(impl);
}
protected boolean (ParsableHeaderValue matchTry){
ensureHeaderProcessed();
if (matchTry.parameter.isEmpty()) {
return true;
}
if (parameter.isEmpty()) {
return false;
}
for (Entry<String, String> requiredParameter : matchTry.parameter.entrySet()) {
String parameterValueToTest = parameter.get(requiredParameter.getKey());
String requiredParamVal = requiredParameter.getValue();
if (parameterValueToTest == null || (
!requiredParamVal.isEmpty() && !requiredParamVal.equalsIgnoreCase(parameterValueToTest))
){
return false;
}
}
return true;
}
@Override
public <T extends ParsedHeaderValue> T (Collection<T> matchTries) {
for (T matchTry : matchTries) {
if(isMatchedBy(matchTry)){
return matchTry;
}
}
return null;
}
private void () {
if(parameter.isEmpty()){
parameter = new HashMap<>();
}
}
protected void () {
if(weight < 0){
weight = DEFAULT_WEIGHT;
HeaderParser.parseHeaderValue(
headerContent,
this::setValue,
this::setWeight,
this::addParameter
);
paramsWeight = parameter.isEmpty() ? 0 : 1;
}
}
public ParsableHeaderValue (){
ensureHeaderProcessed();
return this;
}
private void (String value) {
this.value = value;
}
private void (String key, String value) {
ensureParameterIsHashMap();
if(value == null){
value = "";
paramsWeight = Math.max(1, paramsWeight);
} else {
paramsWeight = Math.max(2, paramsWeight);
}
parameter.put(key, value);
}
private void (float weight) {
this.weight = ((int)((Math.max(0, Math.min(1, weight)) * 100)) / 100.0f);
}
public final int (){
ensureHeaderProcessed();
return (int)(weight() * 1000) + (weightedOrderPart2() * 10) + paramsWeight;
}
protected int (){
return 0;
}
@Override
public int () {
return Objects.hash(headerContent);
}
@Override
public boolean (Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ParsableHeaderValue)) {
return false;
}
ParsableHeaderValue other = (ParsableHeaderValue) obj;
if (headerContent == null) {
return other.headerContent == null;
} else {
return headerContent.equals(other.headerContent);
}
}
}