org.openapi4j.parser.model.v3.SecurityRequirement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openapi-parser Show documentation
Show all versions of openapi-parser Show documentation
openapi4j schema parser & validator
package org.openapi4j.parser.model.v3;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import org.openapi4j.parser.model.AbsOpenApiSchema;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@SuppressWarnings("unused")
public class SecurityRequirement extends AbsOpenApiSchema {
private Map> requirements;
// Requirement
@JsonAnyGetter
public Map> getRequirements() {
return requirements;
}
public SecurityRequirement setRequirements(Map> requirements) {
this.requirements = requirements;
return this;
}
public boolean hasRequirement(String name) {
return mapHas(requirements, name);
}
public boolean hasRequirementScopes(String name) {
List scopes = mapGet(requirements, name);
return scopes != null && !scopes.isEmpty();
}
public List getRequirement(String name) {
return mapGet(requirements, name);
}
@JsonAnySetter
public SecurityRequirement setRequirement(String name, List scopes) {
if (requirements == null) {
requirements = new HashMap<>();
}
requirements.put(name, scopes);
return this;
}
public SecurityRequirement removeRequirement(String name) {
mapRemove(requirements, name);
return this;
}
@Override
public SecurityRequirement copy() {
SecurityRequirement copy = new SecurityRequirement();
copy.setRequirements(copySimpleMap(getRequirements()));
return copy;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SecurityRequirement that = (SecurityRequirement) o;
return Objects.equals(requirements, that.requirements);
}
@Override
public int hashCode() {
return requirements != null ? requirements.hashCode() : 0;
}
}