org.odpi.openmetadata.accessservices.assetowner.metadataelements.ConnectionElement Maven / Gradle / Ivy
/* SPDX-License-Identifier: Apache 2.0 */
/* Copyright Contributors to the ODPi Egeria project. */
package org.odpi.openmetadata.accessservices.assetowner.metadataelements;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.odpi.openmetadata.accessservices.assetowner.properties.ConnectionProperties;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* ConnectionElement contains the properties and header for a connection retrieved from the metadata repository.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class ConnectionElement implements MetadataElement, Serializable
{
private static final long serialVersionUID = 1L;
private ConnectionProperties connectionProperties = null;
private ElementHeader elementHeader = null;
private ElementStub connectorType = null;
private ElementStub endpoint = null;
private List embeddedConnections = null;
/**
* Default constructor
*/
public ConnectionElement()
{
super();
}
/**
* Copy/clone constructor
*
* @param template object to copy
*/
public ConnectionElement(ConnectionElement template)
{
if (template != null)
{
elementHeader = template.getElementHeader();
connectionProperties = template.getConnectionProperties();
connectorType = template.getConnectorType();
endpoint = template.getEndpoint();
embeddedConnections = template.getEmbeddedConnections();
}
}
/**
* Return the element header associated with the properties.
*
* @return element header object
*/
@Override
public ElementHeader getElementHeader()
{
return elementHeader;
}
/**
* Set up the element header associated with the properties.
*
* @param elementHeader element header object
*/
@Override
public void setElementHeader(ElementHeader elementHeader)
{
this.elementHeader = elementHeader;
}
/**
* Return the properties for the connection.
*
* @return asset properties (using appropriate subclass)
*/
public ConnectionProperties getConnectionProperties()
{
return connectionProperties;
}
/**
* Set up the properties for the connection.
*
* @param connectionProperties asset properties
*/
public void setConnectionProperties(ConnectionProperties connectionProperties)
{
this.connectionProperties = connectionProperties;
}
/**
* Set up the connector type properties for this Connection.
*
* @param connectorType ConnectorType properties object
*/
public void setConnectorType(ElementStub connectorType)
{
this.connectorType = connectorType;
}
/**
* Returns a copy of the properties for this connection's connector type.
* A null means there is no connection type.
*
* @return connector type for the connection
*/
public ElementStub getConnectorType()
{
return connectorType;
}
/**
* Set up the endpoint properties for this Connection.
*
* @param endpoint Endpoint properties object
*/
public void setEndpoint(ElementStub endpoint)
{
this.endpoint = endpoint;
}
/**
* Returns a copy of the properties for this connection's endpoint.
* Null means no endpoint information available.
*
* @return endpoint for the connection
*/
public ElementStub getEndpoint()
{
return endpoint;
}
/**
* Return the list of embedded connections for this virtual connection.
*
* @return list of EmbeddedConnection objects
*/
public List getEmbeddedConnections()
{
if (embeddedConnections == null)
{
return null;
}
else if (embeddedConnections.isEmpty())
{
return null;
}
else
{
return new ArrayList<>(embeddedConnections);
}
}
/**
* Set up the list of embedded connections for this virtual connection.
*
* @param embeddedConnections list of EmbeddedConnection objects
*/
public void setEmbeddedConnections(List embeddedConnections)
{
this.embeddedConnections = embeddedConnections;
}
/**
* JSON-style toString
*
* @return return string containing the property names and values
*/
@Override
public String toString()
{
return "ConnectionElement{" +
"connectionProperties=" + connectionProperties +
", elementHeader=" + elementHeader +
", connectorType=" + connectorType +
", endpoint=" + endpoint +
", embeddedConnections=" + embeddedConnections +
'}';
}
/**
* Return comparison result based on the content of the properties.
*
* @param objectToCompare test object
* @return result of comparison
*/
@Override
public boolean equals(Object objectToCompare)
{
if (this == objectToCompare)
{
return true;
}
if (objectToCompare == null || getClass() != objectToCompare.getClass())
{
return false;
}
ConnectionElement that = (ConnectionElement) objectToCompare;
return Objects.equals(getConnectionProperties(), that.getConnectionProperties()) &&
Objects.equals(getElementHeader(), that.getElementHeader());
}
/**
* Return hash code for this object
*
* @return int hash code
*/
@Override
public int hashCode()
{
return Objects.hash(super.hashCode(), elementHeader, connectionProperties);
}
}