com.github.davidmoten.oas3.internal.model.Class Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openapi-to-plantuml Show documentation
Show all versions of openapi-to-plantuml Show documentation
Generates PlantUML file from an OpenAPI 3.0 Definition
package com.github.davidmoten.oas3.internal.model;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import com.google.common.base.Preconditions;
public final class Class {
private final String name;
private final ClassType type;
private final List fields;
private final boolean isEnum;
private final Optional description;
public Class(String name, ClassType type, List fields, boolean isEnum, Optional description) {
this.isEnum = isEnum;
Preconditions.checkNotNull(name);
Preconditions.checkNotNull(type);
Preconditions.checkNotNull(fields);
this.name = name;
this.type = type;
this.fields = fields;
this.description = description;
}
public Class(String name, ClassType type) {
this(name, type, Collections.emptyList(), false, Optional.empty());
}
public String name() {
return name;
}
public ClassType type() {
return type;
}
public List fields() {
return fields;
}
public boolean isEnum() {
return isEnum;
}
public Optional description() {
return description;
}
@Override
public int hashCode() {
return Objects.hash(fields, isEnum, name, type);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Class other = (Class) obj;
return Objects.equals(fields, other.fields) && isEnum == other.isEnum && Objects.equals(name, other.name)
&& type == other.type;
}
@Override
public String toString() {
StringBuilder b = new StringBuilder();
b.append("Class [name=");
b.append(name);
b.append(", type=");
b.append(type);
b.append(", fields=");
b.append(fields);
b.append("]");
return b.toString();
}
}