com.sap.cloud.security.ams.dcl.client.dcn.Schema Maven / Gradle / Ivy
The newest version!
/************************************************************************
* © 2019-2024 SAP SE or an SAP affiliate company. All rights reserved. *
************************************************************************/
package com.sap.cloud.security.ams.dcl.client.dcn;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import com.sap.cloud.security.ams.dcl.client.annotation.Beta;
import com.sap.cloud.security.ams.dcl.client.el.QualifiedName;
@Beta
public class Schema implements Annotated {
private QualifiedName qualifiedName;
private String tenant;
private SchemaAttribute definition;
private Map annotations;
private transient Object userData; // NOSONAR
public QualifiedName qualifiedName() {
return qualifiedName;
}
public Schema qualifiedName(QualifiedName qualifiedName) {
if (qualifiedName != null && (qualifiedName.isEmpty()
|| !DcnSchemaBuilderImpl.DCN_SCHEMA_NAME.equals(qualifiedName.getLastSegment()))) {
throw new IllegalArgumentException("The qualified name must end with schema.");
}
this.qualifiedName = qualifiedName;
return this;
}
public String tenant() {
return tenant;
}
public Schema tenant(String tenant) {
this.tenant = tenant;
return this;
}
public SchemaAttribute definition() {
return definition;
}
public Schema definition(SchemaAttribute definition) {
this.definition = definition;
return this;
}
@Override
public Map annotations() {
return annotations; // NOSONAR
}
@Override
public Schema annotations(Map annotations) {
this.annotations = annotations; // NOSONAR
return this;
}
/**
* Gets the custom user data. This data is not stored or loaded (i.e transient). The value is not take into account for hashCode() or
* equals(Object other).
*
* @return user data
*/
public Object userData() {
return userData;
}
/**
* Sets the user data. This data is not stored or loaded (i.e transient). The value is not take into account for hashCode() or equals(Object
* other).
*
* @param userData
* custom user data
* @return this
*/
public Schema userData(Object userData) {
this.userData = userData;
return this;
}
public Schema apply(Consumer consumer) {
consumer.accept(this);
return this;
}
//
@Override
public String toString() {
return "Schema [qualifiedName=" + qualifiedName
+ ", tenant=" + tenant
+ ", definition=" + definition
+ ", annotations=" + annotations
+ "]";
}
@Override
public int hashCode() {
return Objects.hash(qualifiedName, tenant, definition, annotations);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Schema other = (Schema) obj;
return Objects.equals(qualifiedName, other.qualifiedName)
&& Objects.equals(tenant, other.tenant)
&& Objects.equals(definition, other.definition)
&& Objects.equals(annotations, other.annotations);
}
}