1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.volley; 17 18 import android.text.TextUtils; 19 20 /** An HTTP header. */ 21 public final class Header { 22 private final String mName; 23 private final String mValue; 24 Header(String name, String value)25 public Header(String name, String value) { 26 mName = name; 27 mValue = value; 28 } 29 getName()30 public final String getName() { 31 return mName; 32 } 33 getValue()34 public final String getValue() { 35 return mValue; 36 } 37 38 @Override equals(Object o)39 public boolean equals(Object o) { 40 if (this == o) return true; 41 if (o == null || getClass() != o.getClass()) return false; 42 43 Header header = (Header) o; 44 45 return TextUtils.equals(mName, header.mName) && TextUtils.equals(mValue, header.mValue); 46 } 47 48 @Override hashCode()49 public int hashCode() { 50 int result = mName.hashCode(); 51 result = 31 * result + mValue.hashCode(); 52 return result; 53 } 54 55 @Override toString()56 public String toString() { 57 return "Header[name=" + mName + ",value=" + mValue + "]"; 58 } 59 } 60