com.jayway.restassured.response.Header Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-assured Show documentation
Show all versions of rest-assured Show documentation
Java DSL for easy testing of REST services
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jayway.restassured.response;
import com.jayway.restassured.internal.NameAndValue;
import com.jayway.restassured.internal.assertion.AssertParameter;
/**
* Represents a HTTP header
*/
public class Header implements NameAndValue {
private final String name;
private final String value;
/**
* Create a new header with the given name and value.
*
* @param name The header name, cannot be null.
* @param value The value (can be null)
*/
public Header(String name, String value) {
AssertParameter.notNull(name, "Header name");
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public String getValue() {
return value;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Header header = (Header) o;
if (name != null ? !name.equals(header.name) : header.name != null) return false;
if (value != null ? !value.equals(header.value) : header.value != null) return false;
return true;
}
@Override
public int hashCode() {
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (value != null ? value.hashCode() : 0);
return result;
}
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append(name);
if(value != null) {
builder.append("=").append(value);
}
return builder.toString();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy