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 25 public Header(String name, String value) { 26 mName = name; 27 mValue = value; 28 } 29 30 public final String getName() { 31 return mName; 32 } 33 34 public final String getValue() { 35 return mValue; 36 } 37 38 @Override 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) 46 && TextUtils.equals(mValue, header.mValue); 47 } 48 49 @Override 50 public int hashCode() { 51 int result = mName.hashCode(); 52 result = 31 * result + mValue.hashCode(); 53 return result; 54 } 55 56 @Override 57 public String toString() { 58 return "Header[name=" + mName + ",value=" + mValue + "]"; 59 } 60 } 61