Skip to content

Commit 43a5581

Browse files
gracekarinafrantuma
authored andcommitted
add url matcher to authorizationValue
1 parent 655a454 commit 43a5581

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

modules/swagger-models/src/main/java/io/swagger/models/auth/AuthorizationValue.java

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
package io.swagger.models.auth;
22

3+
import java.net.URL;
4+
import java.util.Objects;
5+
36
public class AuthorizationValue {
47
private String value, type, keyName;
8+
private UrlMatcher urlMatcher;
59

610
public AuthorizationValue() {
711
}
812

9-
public AuthorizationValue(String keyName, String value, String type) {
13+
public AuthorizationValue(String keyName, String value, String type, UrlMatcher urlMatcher) {
1014
this.setKeyName(keyName);
1115
this.setValue(value);
1216
this.setType(type);
17+
this.setUrlMatcher(urlMatcher);
18+
}
19+
20+
public AuthorizationValue(String keyName, String value, String type) {
21+
this(keyName, value, type, new UrlMatcher() {
22+
@Override
23+
public boolean test(URL url) {
24+
return true;
25+
}
26+
});
1327
}
1428

1529
public AuthorizationValue value(String value) {
@@ -27,6 +41,11 @@ public AuthorizationValue keyName(String keyName) {
2741
return this;
2842
}
2943

44+
public AuthorizationValue urlMatcher(UrlMatcher urlMatcher) {
45+
setUrlMatcher(urlMatcher);
46+
return this;
47+
}
48+
3049
public String getValue() {
3150
return value;
3251
}
@@ -51,13 +70,21 @@ public void setKeyName(String keyName) {
5170
this.keyName = keyName;
5271
}
5372

73+
public UrlMatcher getUrlMatcher() {
74+
return urlMatcher;
75+
}
76+
public void setUrlMatcher(UrlMatcher urlMatcher) {
77+
this.urlMatcher = Objects.requireNonNull(urlMatcher);
78+
}
79+
5480
@Override
5581
public int hashCode() {
5682
final int prime = 31;
5783
int result = 1;
5884
result = prime * result + ((keyName == null) ? 0 : keyName.hashCode());
5985
result = prime * result + ((type == null) ? 0 : type.hashCode());
6086
result = prime * result + ((value == null) ? 0 : value.hashCode());
87+
result = prime * result + ((urlMatcher == null) ? 0 : urlMatcher.hashCode());
6188
return result;
6289
}
6390

@@ -94,6 +121,15 @@ public boolean equals(Object obj) {
94121
} else if (!value.equals(other.value)) {
95122
return false;
96123
}
124+
if (urlMatcher == null) {
125+
if (other.urlMatcher != null) {
126+
return false;
127+
}
128+
} else if (!urlMatcher.equals(other.urlMatcher)) {
129+
if (!urlMatcher.equals(other.urlMatcher)) {
130+
return false;
131+
}
132+
}
97133
return true;
98134
}
99-
}
135+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.swagger.models.auth;
2+
3+
import java.net.URL;
4+
5+
public interface UrlMatcher {
6+
boolean test(URL url);
7+
}

0 commit comments

Comments
 (0)