com.ibm.fhir.model.resource.CompartmentDefinition Maven / Gradle / Ivy
/*
* (C) Copyright IBM Corp. 2019, 2021
*
* SPDX-License-Identifier: Apache-2.0
*/
package com.ibm.fhir.model.resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.annotation.Generated;
import com.ibm.fhir.model.annotation.Binding;
import com.ibm.fhir.model.annotation.Constraint;
import com.ibm.fhir.model.annotation.Maturity;
import com.ibm.fhir.model.annotation.Required;
import com.ibm.fhir.model.annotation.Summary;
import com.ibm.fhir.model.type.BackboneElement;
import com.ibm.fhir.model.type.Boolean;
import com.ibm.fhir.model.type.Code;
import com.ibm.fhir.model.type.ContactDetail;
import com.ibm.fhir.model.type.DateTime;
import com.ibm.fhir.model.type.Extension;
import com.ibm.fhir.model.type.Markdown;
import com.ibm.fhir.model.type.Meta;
import com.ibm.fhir.model.type.Narrative;
import com.ibm.fhir.model.type.String;
import com.ibm.fhir.model.type.Uri;
import com.ibm.fhir.model.type.UsageContext;
import com.ibm.fhir.model.type.code.BindingStrength;
import com.ibm.fhir.model.type.code.CompartmentType;
import com.ibm.fhir.model.type.code.PublicationStatus;
import com.ibm.fhir.model.type.code.ResourceType;
import com.ibm.fhir.model.type.code.StandardsStatus;
import com.ibm.fhir.model.util.ValidationSupport;
import com.ibm.fhir.model.visitor.Visitor;
/**
* A compartment definition that defines how resources are accessed on a server.
*
* Maturity level: FMM1 (Trial Use)
*/
@Maturity(
level = 1,
status = StandardsStatus.Value.TRIAL_USE
)
@Constraint(
id = "cpd-0",
level = "Warning",
location = "(base)",
description = "Name should be usable as an identifier for the module by machine processing applications such as code generation",
expression = "name.matches('[A-Z]([A-Za-z0-9_]){0,254}')"
)
@Generated("com.ibm.fhir.tools.CodeGenerator")
public class CompartmentDefinition extends DomainResource {
@Summary
@Required
private final Uri url;
@Summary
private final String version;
@Summary
@Required
private final String name;
@Summary
@Binding(
bindingName = "PublicationStatus",
strength = BindingStrength.Value.REQUIRED,
description = "The lifecycle status of an artifact.",
valueSet = "http://hl7.org/fhir/ValueSet/publication-status|4.0.1"
)
@Required
private final PublicationStatus status;
@Summary
private final Boolean experimental;
@Summary
private final DateTime date;
@Summary
private final String publisher;
@Summary
private final List contact;
private final Markdown description;
@Summary
private final List useContext;
private final Markdown purpose;
@Summary
@Binding(
bindingName = "CompartmentType",
strength = BindingStrength.Value.REQUIRED,
description = "Which type a compartment definition describes.",
valueSet = "http://hl7.org/fhir/ValueSet/compartment-type|4.0.1"
)
@Required
private final CompartmentType code;
@Summary
@Required
private final Boolean search;
@Summary
private final List resource;
private CompartmentDefinition(Builder builder) {
super(builder);
url = builder.url;
version = builder.version;
name = builder.name;
status = builder.status;
experimental = builder.experimental;
date = builder.date;
publisher = builder.publisher;
contact = Collections.unmodifiableList(builder.contact);
description = builder.description;
useContext = Collections.unmodifiableList(builder.useContext);
purpose = builder.purpose;
code = builder.code;
search = builder.search;
resource = Collections.unmodifiableList(builder.resource);
}
/**
* An absolute URI that is used to identify this compartment definition when it is referenced in a specification, model,
* design or an instance; also called its canonical identifier. This SHOULD be globally unique and SHOULD be a literal
* address at which at which an authoritative instance of this compartment definition is (or will be) published. This URL
* can be the target of a canonical reference. It SHALL remain the same when the compartment definition is stored on
* different servers.
*
* @return
* An immutable object of type {@link Uri} that is non-null.
*/
public Uri getUrl() {
return url;
}
/**
* The identifier that is used to identify this version of the compartment definition when it is referenced in a
* specification, model, design or instance. This is an arbitrary value managed by the compartment definition author and
* is not expected to be globally unique. For example, it might be a timestamp (e.g. yyyymmdd) if a managed version is
* not available. There is also no expectation that versions can be placed in a lexicographical sequence.
*
* @return
* An immutable object of type {@link String} that may be null.
*/
public String getVersion() {
return version;
}
/**
* A natural language name identifying the compartment definition. This name should be usable as an identifier for the
* module by machine processing applications such as code generation.
*
* @return
* An immutable object of type {@link String} that is non-null.
*/
public String getName() {
return name;
}
/**
* The status of this compartment definition. Enables tracking the life-cycle of the content.
*
* @return
* An immutable object of type {@link PublicationStatus} that is non-null.
*/
public PublicationStatus getStatus() {
return status;
}
/**
* A Boolean value to indicate that this compartment definition is authored for testing purposes (or
* education/evaluation/marketing) and is not intended to be used for genuine usage.
*
* @return
* An immutable object of type {@link Boolean} that may be null.
*/
public Boolean getExperimental() {
return experimental;
}
/**
* The date (and optionally time) when the compartment definition was published. The date must change when the business
* version changes and it must change if the status code changes. In addition, it should change when the substantive
* content of the compartment definition changes.
*
* @return
* An immutable object of type {@link DateTime} that may be null.
*/
public DateTime getDate() {
return date;
}
/**
* The name of the organization or individual that published the compartment definition.
*
* @return
* An immutable object of type {@link String} that may be null.
*/
public String getPublisher() {
return publisher;
}
/**
* Contact details to assist a user in finding and communicating with the publisher.
*
* @return
* An unmodifiable list containing immutable objects of type {@link ContactDetail} that may be empty.
*/
public List getContact() {
return contact;
}
/**
* A free text natural language description of the compartment definition from a consumer's perspective.
*
* @return
* An immutable object of type {@link Markdown} that may be null.
*/
public Markdown getDescription() {
return description;
}
/**
* The content was developed with a focus and intent of supporting the contexts that are listed. These contexts may be
* general categories (gender, age, ...) or may be references to specific programs (insurance plans, studies, ...) and
* may be used to assist with indexing and searching for appropriate compartment definition instances.
*
* @return
* An unmodifiable list containing immutable objects of type {@link UsageContext} that may be empty.
*/
public List getUseContext() {
return useContext;
}
/**
* Explanation of why this compartment definition is needed and why it has been designed as it has.
*
* @return
* An immutable object of type {@link Markdown} that may be null.
*/
public Markdown getPurpose() {
return purpose;
}
/**
* Which compartment this definition describes.
*
* @return
* An immutable object of type {@link CompartmentType} that is non-null.
*/
public CompartmentType getCode() {
return code;
}
/**
* Whether the search syntax is supported,.
*
* @return
* An immutable object of type {@link Boolean} that is non-null.
*/
public Boolean getSearch() {
return search;
}
/**
* Information about how a resource is related to the compartment.
*
* @return
* An unmodifiable list containing immutable objects of type {@link Resource} that may be empty.
*/
public List getResource() {
return resource;
}
@Override
public boolean hasChildren() {
return super.hasChildren() ||
(url != null) ||
(version != null) ||
(name != null) ||
(status != null) ||
(experimental != null) ||
(date != null) ||
(publisher != null) ||
!contact.isEmpty() ||
(description != null) ||
!useContext.isEmpty() ||
(purpose != null) ||
(code != null) ||
(search != null) ||
!resource.isEmpty();
}
@Override
public void accept(java.lang.String elementName, int elementIndex, Visitor visitor) {
if (visitor.preVisit(this)) {
visitor.visitStart(elementName, elementIndex, this);
if (visitor.visit(elementName, elementIndex, this)) {
// visit children
accept(id, "id", visitor);
accept(meta, "meta", visitor);
accept(implicitRules, "implicitRules", visitor);
accept(language, "language", visitor);
accept(text, "text", visitor);
accept(contained, "contained", visitor, com.ibm.fhir.model.resource.Resource.class);
accept(extension, "extension", visitor, Extension.class);
accept(modifierExtension, "modifierExtension", visitor, Extension.class);
accept(url, "url", visitor);
accept(version, "version", visitor);
accept(name, "name", visitor);
accept(status, "status", visitor);
accept(experimental, "experimental", visitor);
accept(date, "date", visitor);
accept(publisher, "publisher", visitor);
accept(contact, "contact", visitor, ContactDetail.class);
accept(description, "description", visitor);
accept(useContext, "useContext", visitor, UsageContext.class);
accept(purpose, "purpose", visitor);
accept(code, "code", visitor);
accept(search, "search", visitor);
accept(resource, "resource", visitor, Resource.class);
}
visitor.visitEnd(elementName, elementIndex, this);
visitor.postVisit(this);
}
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
CompartmentDefinition other = (CompartmentDefinition) obj;
return Objects.equals(id, other.id) &&
Objects.equals(meta, other.meta) &&
Objects.equals(implicitRules, other.implicitRules) &&
Objects.equals(language, other.language) &&
Objects.equals(text, other.text) &&
Objects.equals(contained, other.contained) &&
Objects.equals(extension, other.extension) &&
Objects.equals(modifierExtension, other.modifierExtension) &&
Objects.equals(url, other.url) &&
Objects.equals(version, other.version) &&
Objects.equals(name, other.name) &&
Objects.equals(status, other.status) &&
Objects.equals(experimental, other.experimental) &&
Objects.equals(date, other.date) &&
Objects.equals(publisher, other.publisher) &&
Objects.equals(contact, other.contact) &&
Objects.equals(description, other.description) &&
Objects.equals(useContext, other.useContext) &&
Objects.equals(purpose, other.purpose) &&
Objects.equals(code, other.code) &&
Objects.equals(search, other.search) &&
Objects.equals(resource, other.resource);
}
@Override
public int hashCode() {
int result = hashCode;
if (result == 0) {
result = Objects.hash(id,
meta,
implicitRules,
language,
text,
contained,
extension,
modifierExtension,
url,
version,
name,
status,
experimental,
date,
publisher,
contact,
description,
useContext,
purpose,
code,
search,
resource);
hashCode = result;
}
return result;
}
@Override
public Builder toBuilder() {
return new Builder().from(this);
}
public static Builder builder() {
return new Builder();
}
public static class Builder extends DomainResource.Builder {
private Uri url;
private String version;
private String name;
private PublicationStatus status;
private Boolean experimental;
private DateTime date;
private String publisher;
private List contact = new ArrayList<>();
private Markdown description;
private List useContext = new ArrayList<>();
private Markdown purpose;
private CompartmentType code;
private Boolean search;
private List resource = new ArrayList<>();
private Builder() {
super();
}
/**
* The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
*
* @param id
* Logical id of this artifact
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder id(java.lang.String id) {
return (Builder) super.id(id);
}
/**
* The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content
* might not always be associated with version changes to the resource.
*
* @param meta
* Metadata about the resource
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder meta(Meta meta) {
return (Builder) super.meta(meta);
}
/**
* A reference to a set of rules that were followed when the resource was constructed, and which must be understood when
* processing the content. Often, this is a reference to an implementation guide that defines the special rules along
* with other profiles etc.
*
* @param implicitRules
* A set of rules under which this content was created
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder implicitRules(Uri implicitRules) {
return (Builder) super.implicitRules(implicitRules);
}
/**
* The base language in which the resource is written.
*
* @param language
* Language of the resource content
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder language(Code language) {
return (Builder) super.language(language);
}
/**
* A human-readable narrative that contains a summary of the resource and can be used to represent the content of the
* resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient
* detail to make it "clinically safe" for a human to just read the narrative. Resource definitions may define what
* content should be represented in the narrative to ensure clinical safety.
*
* @param text
* Text summary of the resource, for human interpretation
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder text(Narrative text) {
return (Builder) super.text(text);
}
/**
* These resources do not have an independent existence apart from the resource that contains them - they cannot be
* identified independently, and nor can they have their own independent transaction scope.
*
* Adds new element(s) to the existing list
*
* @param contained
* Contained, inline Resources
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder contained(com.ibm.fhir.model.resource.Resource... contained) {
return (Builder) super.contained(contained);
}
/**
* These resources do not have an independent existence apart from the resource that contains them - they cannot be
* identified independently, and nor can they have their own independent transaction scope.
*
*
Replaces the existing list with a new one containing elements from the Collection
*
* @param contained
* Contained, inline Resources
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder contained(Collection contained) {
return (Builder) super.contained(contained);
}
/**
* May be used to represent additional information that is not part of the basic definition of the resource. To make the
* use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of
* extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part
* of the definition of the extension.
*
* Adds new element(s) to the existing list
*
* @param extension
* Additional content defined by implementations
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder extension(Extension... extension) {
return (Builder) super.extension(extension);
}
/**
* May be used to represent additional information that is not part of the basic definition of the resource. To make the
* use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of
* extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part
* of the definition of the extension.
*
*
Replaces the existing list with a new one containing elements from the Collection
*
* @param extension
* Additional content defined by implementations
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder extension(Collection extension) {
return (Builder) super.extension(extension);
}
/**
* May be used to represent additional information that is not part of the basic definition of the resource and that
* modifies the understanding of the element that contains it and/or the understanding of the containing element's
* descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and
* manageable, there is a strict set of governance applied to the definition and use of extensions. Though any
* implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the
* definition of the extension. Applications processing a resource are required to check for modifier extensions.
*
* Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot
* change the meaning of modifierExtension itself).
*
*
Adds new element(s) to the existing list
*
* @param modifierExtension
* Extensions that cannot be ignored
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder modifierExtension(Extension... modifierExtension) {
return (Builder) super.modifierExtension(modifierExtension);
}
/**
* May be used to represent additional information that is not part of the basic definition of the resource and that
* modifies the understanding of the element that contains it and/or the understanding of the containing element's
* descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and
* manageable, there is a strict set of governance applied to the definition and use of extensions. Though any
* implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the
* definition of the extension. Applications processing a resource are required to check for modifier extensions.
*
*
Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot
* change the meaning of modifierExtension itself).
*
*
Replaces the existing list with a new one containing elements from the Collection
*
* @param modifierExtension
* Extensions that cannot be ignored
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder modifierExtension(Collection modifierExtension) {
return (Builder) super.modifierExtension(modifierExtension);
}
/**
* An absolute URI that is used to identify this compartment definition when it is referenced in a specification, model,
* design or an instance; also called its canonical identifier. This SHOULD be globally unique and SHOULD be a literal
* address at which at which an authoritative instance of this compartment definition is (or will be) published. This URL
* can be the target of a canonical reference. It SHALL remain the same when the compartment definition is stored on
* different servers.
*
* This element is required.
*
* @param url
* Canonical identifier for this compartment definition, represented as a URI (globally unique)
*
* @return
* A reference to this Builder instance
*/
public Builder url(Uri url) {
this.url = url;
return this;
}
/**
* The identifier that is used to identify this version of the compartment definition when it is referenced in a
* specification, model, design or instance. This is an arbitrary value managed by the compartment definition author and
* is not expected to be globally unique. For example, it might be a timestamp (e.g. yyyymmdd) if a managed version is
* not available. There is also no expectation that versions can be placed in a lexicographical sequence.
*
* @param version
* Business version of the compartment definition
*
* @return
* A reference to this Builder instance
*/
public Builder version(String version) {
this.version = version;
return this;
}
/**
* A natural language name identifying the compartment definition. This name should be usable as an identifier for the
* module by machine processing applications such as code generation.
*
*
This element is required.
*
* @param name
* Name for this compartment definition (computer friendly)
*
* @return
* A reference to this Builder instance
*/
public Builder name(String name) {
this.name = name;
return this;
}
/**
* The status of this compartment definition. Enables tracking the life-cycle of the content.
*
*
This element is required.
*
* @param status
* draft | active | retired | unknown
*
* @return
* A reference to this Builder instance
*/
public Builder status(PublicationStatus status) {
this.status = status;
return this;
}
/**
* A Boolean value to indicate that this compartment definition is authored for testing purposes (or
* education/evaluation/marketing) and is not intended to be used for genuine usage.
*
* @param experimental
* For testing purposes, not real usage
*
* @return
* A reference to this Builder instance
*/
public Builder experimental(Boolean experimental) {
this.experimental = experimental;
return this;
}
/**
* The date (and optionally time) when the compartment definition was published. The date must change when the business
* version changes and it must change if the status code changes. In addition, it should change when the substantive
* content of the compartment definition changes.
*
* @param date
* Date last changed
*
* @return
* A reference to this Builder instance
*/
public Builder date(DateTime date) {
this.date = date;
return this;
}
/**
* The name of the organization or individual that published the compartment definition.
*
* @param publisher
* Name of the publisher (organization or individual)
*
* @return
* A reference to this Builder instance
*/
public Builder publisher(String publisher) {
this.publisher = publisher;
return this;
}
/**
* Contact details to assist a user in finding and communicating with the publisher.
*
*
Adds new element(s) to the existing list
*
* @param contact
* Contact details for the publisher
*
* @return
* A reference to this Builder instance
*/
public Builder contact(ContactDetail... contact) {
for (ContactDetail value : contact) {
this.contact.add(value);
}
return this;
}
/**
* Contact details to assist a user in finding and communicating with the publisher.
*
*
Replaces the existing list with a new one containing elements from the Collection
*
* @param contact
* Contact details for the publisher
*
* @return
* A reference to this Builder instance
*/
public Builder contact(Collection contact) {
this.contact = new ArrayList<>(contact);
return this;
}
/**
* A free text natural language description of the compartment definition from a consumer's perspective.
*
* @param description
* Natural language description of the compartment definition
*
* @return
* A reference to this Builder instance
*/
public Builder description(Markdown description) {
this.description = description;
return this;
}
/**
* The content was developed with a focus and intent of supporting the contexts that are listed. These contexts may be
* general categories (gender, age, ...) or may be references to specific programs (insurance plans, studies, ...) and
* may be used to assist with indexing and searching for appropriate compartment definition instances.
*
* Adds new element(s) to the existing list
*
* @param useContext
* The context that the content is intended to support
*
* @return
* A reference to this Builder instance
*/
public Builder useContext(UsageContext... useContext) {
for (UsageContext value : useContext) {
this.useContext.add(value);
}
return this;
}
/**
* The content was developed with a focus and intent of supporting the contexts that are listed. These contexts may be
* general categories (gender, age, ...) or may be references to specific programs (insurance plans, studies, ...) and
* may be used to assist with indexing and searching for appropriate compartment definition instances.
*
*
Replaces the existing list with a new one containing elements from the Collection
*
* @param useContext
* The context that the content is intended to support
*
* @return
* A reference to this Builder instance
*/
public Builder useContext(Collection useContext) {
this.useContext = new ArrayList<>(useContext);
return this;
}
/**
* Explanation of why this compartment definition is needed and why it has been designed as it has.
*
* @param purpose
* Why this compartment definition is defined
*
* @return
* A reference to this Builder instance
*/
public Builder purpose(Markdown purpose) {
this.purpose = purpose;
return this;
}
/**
* Which compartment this definition describes.
*
* This element is required.
*
* @param code
* Patient | Encounter | RelatedPerson | Practitioner | Device
*
* @return
* A reference to this Builder instance
*/
public Builder code(CompartmentType code) {
this.code = code;
return this;
}
/**
* Whether the search syntax is supported,.
*
*
This element is required.
*
* @param search
* Whether the search syntax is supported
*
* @return
* A reference to this Builder instance
*/
public Builder search(Boolean search) {
this.search = search;
return this;
}
/**
* Information about how a resource is related to the compartment.
*
*
Adds new element(s) to the existing list
*
* @param resource
* How a resource is related to the compartment
*
* @return
* A reference to this Builder instance
*/
public Builder resource(Resource... resource) {
for (Resource value : resource) {
this.resource.add(value);
}
return this;
}
/**
* Information about how a resource is related to the compartment.
*
*
Replaces the existing list with a new one containing elements from the Collection
*
* @param resource
* How a resource is related to the compartment
*
* @return
* A reference to this Builder instance
*/
public Builder resource(Collection resource) {
this.resource = new ArrayList<>(resource);
return this;
}
/**
* Build the {@link CompartmentDefinition}
*
* Required elements:
*
* - url
* - name
* - status
* - code
* - search
*
*
* @return
* An immutable object of type {@link CompartmentDefinition}
* @throws IllegalStateException
* if the current state cannot be built into a valid CompartmentDefinition per the base specification
*/
@Override
public CompartmentDefinition build() {
CompartmentDefinition compartmentDefinition = new CompartmentDefinition(this);
if (validating) {
validate(compartmentDefinition);
}
return compartmentDefinition;
}
protected void validate(CompartmentDefinition compartmentDefinition) {
super.validate(compartmentDefinition);
ValidationSupport.requireNonNull(compartmentDefinition.url, "url");
ValidationSupport.requireNonNull(compartmentDefinition.name, "name");
ValidationSupport.requireNonNull(compartmentDefinition.status, "status");
ValidationSupport.checkList(compartmentDefinition.contact, "contact", ContactDetail.class);
ValidationSupport.checkList(compartmentDefinition.useContext, "useContext", UsageContext.class);
ValidationSupport.requireNonNull(compartmentDefinition.code, "code");
ValidationSupport.requireNonNull(compartmentDefinition.search, "search");
ValidationSupport.checkList(compartmentDefinition.resource, "resource", Resource.class);
}
protected Builder from(CompartmentDefinition compartmentDefinition) {
super.from(compartmentDefinition);
url = compartmentDefinition.url;
version = compartmentDefinition.version;
name = compartmentDefinition.name;
status = compartmentDefinition.status;
experimental = compartmentDefinition.experimental;
date = compartmentDefinition.date;
publisher = compartmentDefinition.publisher;
contact.addAll(compartmentDefinition.contact);
description = compartmentDefinition.description;
useContext.addAll(compartmentDefinition.useContext);
purpose = compartmentDefinition.purpose;
code = compartmentDefinition.code;
search = compartmentDefinition.search;
resource.addAll(compartmentDefinition.resource);
return this;
}
}
/**
* Information about how a resource is related to the compartment.
*/
public static class Resource extends BackboneElement {
@Summary
@Binding(
bindingName = "ResourceType",
strength = BindingStrength.Value.REQUIRED,
description = "One of the resource types defined as part of this version of FHIR.",
valueSet = "http://hl7.org/fhir/ValueSet/resource-types|4.0.1"
)
@Required
private final ResourceType code;
@Summary
private final List param;
private final String documentation;
private Resource(Builder builder) {
super(builder);
code = builder.code;
param = Collections.unmodifiableList(builder.param);
documentation = builder.documentation;
}
/**
* The name of a resource supported by the server.
*
* @return
* An immutable object of type {@link ResourceType} that is non-null.
*/
public ResourceType getCode() {
return code;
}
/**
* The name of a search parameter that represents the link to the compartment. More than one may be listed because a
* resource may be linked to a compartment in more than one way,.
*
* @return
* An unmodifiable list containing immutable objects of type {@link String} that may be empty.
*/
public List getParam() {
return param;
}
/**
* Additional documentation about the resource and compartment.
*
* @return
* An immutable object of type {@link String} that may be null.
*/
public String getDocumentation() {
return documentation;
}
@Override
public boolean hasChildren() {
return super.hasChildren() ||
(code != null) ||
!param.isEmpty() ||
(documentation != null);
}
@Override
public void accept(java.lang.String elementName, int elementIndex, Visitor visitor) {
if (visitor.preVisit(this)) {
visitor.visitStart(elementName, elementIndex, this);
if (visitor.visit(elementName, elementIndex, this)) {
// visit children
accept(id, "id", visitor);
accept(extension, "extension", visitor, Extension.class);
accept(modifierExtension, "modifierExtension", visitor, Extension.class);
accept(code, "code", visitor);
accept(param, "param", visitor, String.class);
accept(documentation, "documentation", visitor);
}
visitor.visitEnd(elementName, elementIndex, this);
visitor.postVisit(this);
}
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Resource other = (Resource) obj;
return Objects.equals(id, other.id) &&
Objects.equals(extension, other.extension) &&
Objects.equals(modifierExtension, other.modifierExtension) &&
Objects.equals(code, other.code) &&
Objects.equals(param, other.param) &&
Objects.equals(documentation, other.documentation);
}
@Override
public int hashCode() {
int result = hashCode;
if (result == 0) {
result = Objects.hash(id,
extension,
modifierExtension,
code,
param,
documentation);
hashCode = result;
}
return result;
}
@Override
public Builder toBuilder() {
return new Builder().from(this);
}
public static Builder builder() {
return new Builder();
}
public static class Builder extends BackboneElement.Builder {
private ResourceType code;
private List param = new ArrayList<>();
private String documentation;
private Builder() {
super();
}
/**
* Unique id for the element within a resource (for internal references). This may be any string value that does not
* contain spaces.
*
* @param id
* Unique id for inter-element referencing
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder id(java.lang.String id) {
return (Builder) super.id(id);
}
/**
* May be used to represent additional information that is not part of the basic definition of the element. To make the
* use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of
* extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part
* of the definition of the extension.
*
* Adds new element(s) to the existing list
*
* @param extension
* Additional content defined by implementations
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder extension(Extension... extension) {
return (Builder) super.extension(extension);
}
/**
* May be used to represent additional information that is not part of the basic definition of the element. To make the
* use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of
* extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part
* of the definition of the extension.
*
*
Replaces the existing list with a new one containing elements from the Collection
*
* @param extension
* Additional content defined by implementations
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder extension(Collection extension) {
return (Builder) super.extension(extension);
}
/**
* May be used to represent additional information that is not part of the basic definition of the element and that
* modifies the understanding of the element in which it is contained and/or the understanding of the containing
* element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe
* and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any
* implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the
* extension. Applications processing a resource are required to check for modifier extensions.
*
* Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot
* change the meaning of modifierExtension itself).
*
*
Adds new element(s) to the existing list
*
* @param modifierExtension
* Extensions that cannot be ignored even if unrecognized
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder modifierExtension(Extension... modifierExtension) {
return (Builder) super.modifierExtension(modifierExtension);
}
/**
* May be used to represent additional information that is not part of the basic definition of the element and that
* modifies the understanding of the element in which it is contained and/or the understanding of the containing
* element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe
* and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any
* implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the
* extension. Applications processing a resource are required to check for modifier extensions.
*
*
Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot
* change the meaning of modifierExtension itself).
*
*
Replaces the existing list with a new one containing elements from the Collection
*
* @param modifierExtension
* Extensions that cannot be ignored even if unrecognized
*
* @return
* A reference to this Builder instance
*/
@Override
public Builder modifierExtension(Collection modifierExtension) {
return (Builder) super.modifierExtension(modifierExtension);
}
/**
* The name of a resource supported by the server.
*
* This element is required.
*
* @param code
* Name of resource type
*
* @return
* A reference to this Builder instance
*/
public Builder code(ResourceType code) {
this.code = code;
return this;
}
/**
* The name of a search parameter that represents the link to the compartment. More than one may be listed because a
* resource may be linked to a compartment in more than one way,.
*
*
Adds new element(s) to the existing list
*
* @param param
* Search Parameter Name, or chained parameters
*
* @return
* A reference to this Builder instance
*/
public Builder param(String... param) {
for (String value : param) {
this.param.add(value);
}
return this;
}
/**
* The name of a search parameter that represents the link to the compartment. More than one may be listed because a
* resource may be linked to a compartment in more than one way,.
*
*
Replaces the existing list with a new one containing elements from the Collection
*
* @param param
* Search Parameter Name, or chained parameters
*
* @return
* A reference to this Builder instance
*/
public Builder param(Collection param) {
this.param = new ArrayList<>(param);
return this;
}
/**
* Additional documentation about the resource and compartment.
*
* @param documentation
* Additional documentation about the resource and compartment
*
* @return
* A reference to this Builder instance
*/
public Builder documentation(String documentation) {
this.documentation = documentation;
return this;
}
/**
* Build the {@link Resource}
*
* Required elements:
*
* - code
*
*
* @return
* An immutable object of type {@link Resource}
* @throws IllegalStateException
* if the current state cannot be built into a valid Resource per the base specification
*/
@Override
public Resource build() {
Resource resource = new Resource(this);
if (validating) {
validate(resource);
}
return resource;
}
protected void validate(Resource resource) {
super.validate(resource);
ValidationSupport.requireNonNull(resource.code, "code");
ValidationSupport.checkList(resource.param, "param", String.class);
ValidationSupport.requireValueOrChildren(resource);
}
protected Builder from(Resource resource) {
super.from(resource);
code = resource.code;
param.addAll(resource.param);
documentation = resource.documentation;
return this;
}
}
}
}