Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: talk/app/webrtc/java/src/org/webrtc/MediaConstraints.java

Issue 1193883006: Adding an equals method for KeyValuePair for easier testing. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: adding hashCode Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 return key; 49 return key;
50 } 50 }
51 51
52 public String getValue() { 52 public String getValue() {
53 return value; 53 return value;
54 } 54 }
55 55
56 public String toString() { 56 public String toString() {
57 return key + ": " + value; 57 return key + ": " + value;
58 } 58 }
59
60 @Override
61 public boolean equals(Object other) {
62 if (this == other) {
63 return true;
64 }
65 if (other == null || getClass() != other.getClass()) {
66 return false;
67 }
68 KeyValuePair that = (KeyValuePair)other;
69 return key.equals(that.key) && value.equals(that.value);
70 }
71
72 @Override
73 public int hashCode() {
74 return key.hashCode() + value.hashCode();
75 }
59 } 76 }
60 77
61
62 public final List<KeyValuePair> mandatory; 78 public final List<KeyValuePair> mandatory;
63 public final List<KeyValuePair> optional; 79 public final List<KeyValuePair> optional;
64 80
65 public MediaConstraints() { 81 public MediaConstraints() {
66 mandatory = new LinkedList<KeyValuePair>(); 82 mandatory = new LinkedList<KeyValuePair>();
67 optional = new LinkedList<KeyValuePair>(); 83 optional = new LinkedList<KeyValuePair>();
68 } 84 }
69 85
70 private static String stringifyKeyValuePairList(List<KeyValuePair> list) { 86 private static String stringifyKeyValuePairList(List<KeyValuePair> list) {
71 StringBuilder builder = new StringBuilder("["); 87 StringBuilder builder = new StringBuilder("[");
72 for (KeyValuePair pair : list) { 88 for (KeyValuePair pair : list) {
73 if (builder.length() > 1) { 89 if (builder.length() > 1) {
74 builder.append(", "); 90 builder.append(", ");
75 } 91 }
76 builder.append(pair.toString()); 92 builder.append(pair.toString());
77 } 93 }
78 return builder.append("]").toString(); 94 return builder.append("]").toString();
79 } 95 }
80 96
81 public String toString() { 97 public String toString() {
82 return "mandatory: " + stringifyKeyValuePairList(mandatory) + 98 return "mandatory: " + stringifyKeyValuePairList(mandatory) +
83 ", optional: " + stringifyKeyValuePairList(optional); 99 ", optional: " + stringifyKeyValuePairList(optional);
84 } 100 }
85 } 101 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698