1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.hc.client5.testing.auth;
29
30 import java.util.Arrays;
31 import java.util.Collections;
32 import java.util.List;
33
34 import org.apache.hc.core5.http.NameValuePair;
35 import org.apache.hc.core5.util.LangUtils;
36
37 public final class AuthResult {
38
39 private final boolean success;
40 private final List<NameValuePair> params;
41
42 public AuthResult(final boolean success, final List<NameValuePair> params) {
43 this.success = success;
44 this.params = params != null ? Collections.unmodifiableList(params) : Collections.emptyList();
45 }
46
47 public AuthResult(final boolean success, final NameValuePair... params) {
48 this(success, Arrays.asList(params));
49 }
50
51 public boolean isSuccess() {
52 return success;
53 }
54
55 public boolean hasParams() {
56 return !params.isEmpty();
57 }
58
59 public List<NameValuePair> getParams() {
60 return params;
61 }
62
63 @Override
64 public int hashCode() {
65 int hash = LangUtils.HASH_SEED;
66 hash = LangUtils.hashCode(hash, this.success);
67 return hash;
68 }
69
70 @Override
71 public boolean equals(final Object o) {
72 if (this == o) {
73 return true;
74 }
75 if (o instanceof AuthResult) {
76 final AuthResult that = (AuthResult) o;
77 return this.success == that.success;
78 }
79 return false;
80 }
81
82 @Override
83 public String toString() {
84 final StringBuilder buf = new StringBuilder();
85 buf.append(success);
86 if (!params.isEmpty()) {
87 buf.append(" ").append(params);
88 }
89 return buf.toString();
90 }
91
92 }