Skip to content

Commit

Permalink
changes in AuthorizationValue class
Browse files Browse the repository at this point in the history
  • Loading branch information
gracekarina committed Aug 5, 2021
1 parent d157b5f commit 83592ed
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
8 changes: 8 additions & 0 deletions modules/swagger-models/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package io.swagger.models.auth;

import java.net.URL;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;

public class AuthorizationValue {
private String value, type, keyName;
private List<URL> urls;
private Predicate<URL> urlMatcher;

public AuthorizationValue() {
}

public AuthorizationValue(String keyName, String value, String type, List<URL> urls) {
public AuthorizationValue(String keyName, String value, String type, Predicate<URL> urlMatcher) {
this.setKeyName(keyName);
this.setValue(value);
this.setType(type);
this.setUrls(urls);
this.setUrlMatcher(urlMatcher);
}

public AuthorizationValue(String keyName, String value, String type) {
this(keyName, value, type, null);
this(keyName, value, type, url -> true);
}

public AuthorizationValue value(String value) {
Expand All @@ -36,8 +37,8 @@ public AuthorizationValue keyName(String keyName) {
return this;
}

public AuthorizationValue urls(List<URL> urls) {
this.urls = urls;
public AuthorizationValue urlMatcher(Predicate<URL> urlMatcher) {
setUrlMatcher(urlMatcher);
return this;
}

Expand Down Expand Up @@ -65,11 +66,11 @@ public void setKeyName(String keyName) {
this.keyName = keyName;
}

public List<URL> getUrls() {
return urls;
public Predicate<URL> getUrlMatcher() {
return urlMatcher;
}
public void setUrls(List<URL> urls) {
this.urls = urls;
public void setUrlMatcher(Predicate<URL> urlMatcher) {
this.urlMatcher = Objects.requireNonNull(urlMatcher);
}

@Override
Expand All @@ -79,7 +80,7 @@ public int hashCode() {
result = prime * result + ((keyName == null) ? 0 : keyName.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
result = prime * result + ((urls == null) ? 0 : urls.hashCode());
result = prime * result + ((urlMatcher == null) ? 0 : urlMatcher.hashCode());
return result;
}

Expand Down Expand Up @@ -116,12 +117,14 @@ public boolean equals(Object obj) {
} else if (!value.equals(other.value)) {
return false;
}
if (urls == null) {
if (other.urls != null) {
if (urlMatcher == null) {
if (other.urlMatcher != null) {
return false;
}
} else if (!urlMatcher.equals(other.urlMatcher)) {
if (!urlMatcher.equals(other.urlMatcher)) {
return false;
}
} else if (!urls.equals(other.urls)) {
return false;
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<version>2.7</version>
<configuration>
<aggregate>true</aggregate>
<source>1.7</source>
<source>1.8</source>
<encoding>UTF-8</encoding>
<maxmemory>1g</maxmemory>
<links>
Expand Down

0 comments on commit 83592ed

Please sign in to comment.