com.sap.cloud.security.ams.dcl.client.dcn.SchemaAttribute 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.AttributeName;
@Beta
public class SchemaAttribute implements Annotated {
private AttributeName attributeName;
private DataType type;
private Map nested;
private Map annotations;
private transient Object userData; // NOSONAR
public SchemaAttribute() {
super();
}
public String getName() {
return attributeName.isEmpty() ? "" : attributeName.getLastSegment();
}
public AttributeName attributeName() {
return attributeName;
}
public SchemaAttribute attributeName(AttributeName attributeName) {
this.attributeName = attributeName;
return this;
}
//
public DataType type() {
return type;
}
public SchemaAttribute type(DataType type) {
this.type = type;
return this;
}
public Map nested() {
return nested; // NOSONAR
}
public SchemaAttribute nested(Map nested) {
this.nested = nested; // NOSONAR
return this;
}
@Override
public Map annotations() {
return annotations; // NOSONAR
}
@Override
public SchemaAttribute 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 SchemaAttribute userData(Object userData) {
this.userData = userData;
return this;
}
public SchemaAttribute apply(Consumer consumer) {
consumer.accept(this);
return this;
}
//
@Override
public String toString() {
return "SchemaAttribute [attributeName=" + attributeName
+ ", type=" + type
+ ", nested=" + nested
+ ", annotations=" + annotations
+ "]";
}
@Override
public int hashCode() {
return Objects.hash(attributeName, type, nested, annotations);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SchemaAttribute other = (SchemaAttribute) obj;
return Objects.equals(attributeName, other.attributeName)
&& type == other.type
&& Objects.equals(nested, other.nested)
&& Objects.equals(annotations, other.annotations);
}
//
}