/* SPDX-License-Identifier: Apache-2.0 */

// This is a generated file - do not edit - changes should be made to the templates amd/or generator to generate this file with changes.

package org.odpi.openmetadata.accessservices.subjectarea.generated.<$$package$$>;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship;

import org.odpi.openmetadata.accessservices.subjectarea.ffdc.exceptions.InvalidParameterException;
import org.odpi.openmetadata.accessservices.subjectarea.properties.objects.line.Line;
<$$$
import org.odpi.openmetadata.accessservices.subjectarea.generated.<$$referencePackage$$>.<$$uPropertyName$$>Reference;
import org.odpi.openmetadata.accessservices.subjectarea.generated.relationships.<$$uRelationshipName$$>.<$$uRelationshipName$$>;
import org.odpi.openmetadata.accessservices.subjectarea.generated.relationships.<$$uRelationshipName$$>.<$$uRelationshipName$$>Mapper;
$$$>

import java.io.Serializable;
import java.util.*;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;

/**
 *
 */
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class <$$uname$$>References implements Serializable {
    private static final Logger log = LoggerFactory.getLogger(<$$uname$$>References.class);
    private static final String className = <$$uname$$>References.class.getName();

    public static final String[] REFERENCE_NAMES_SET_VALUES = new String[] {
             <$$$
             "<$$PropertyName$$>",
             $$$>
             // Terminate the list
             null
    };

     public static final String[] RELATIONSHIP_NAMES_SET_VALUES = new String[] {
              <$$$
             "<$$uRelationshipName$$>",
              $$$>
              // Terminate the list
              null
     };
     /**
       * We are passed a set of omrs relationships that are associated with a entity <$$uname$$>
       * Each of these relationships should map to a reference (a uniquely named attribute in <$$uname$$>).
       *
       * Relationships have cardinality. There are 2 sorts of cardinality relevant here, whether the relationship can be related to one or many
       * entities.
       *
       * @param lines
       * @param entityGuid
       * @throws InvalidParameterException
       */
     public <$$uname$$>References(String entityGuid, Set<Line> lines) throws InvalidParameterException {

        if (lines !=null) {
         for (Line relationship: lines) {
            for (int i=0;i< RELATIONSHIP_NAMES_SET_VALUES.length; i++) {
               if (relationship.getName().equals(RELATIONSHIP_NAMES_SET_VALUES[i])) {
                    String referenceName = REFERENCE_NAMES_SET_VALUES[i];

                   <$SetAttr$$
                    if ("<$$setReferenceName$$>".equals(referenceName)) {
                         <$$uRelationshipName$$> <$$RelationshipName$$>_relationship = (<$$uRelationshipName$$>)relationship;
                         <$$uSetReferenceName$$>Reference <$$setReferenceName$$>Reference = new <$$uSetReferenceName$$>Reference(entityGuid,<$$RelationshipName$$>_relationship);
                         if ( <$$setReferenceName$$>== null ) {
                              <$$setReferenceName$$> = new HashSet();
                         }
                          <$$setReferenceName$$>.add(<$$setReferenceName$$>Reference);
                    }
                    $SetAttr$$>

                    <$SingleAttr$$
                    if ("<$$singleReferenceName$$>".equals(referenceName)) {
                         <$$uRelationshipName$$> <$$RelationshipName$$>_relationship = (<$$uRelationshipName$$>)relationship;
                         <$$singleReferenceName$$> = new <$$uSingleReferenceName$$>Reference(entityGuid, <$$RelationshipName$$>_relationship);
                    }
                    $SingleAttr$$>
                 }
             }
         }
        }
     }

    public static final Set<String> REFERENCE_NAMES_SET = new HashSet(new HashSet<>(Arrays.asList(REFERENCE_NAMES_SET_VALUES)));
    // there may be duplicate strings in RELATIONSHIP_NAMES_SET_VALUES, the following line deduplicates the Strings into a Set.
    public static final Set<String> RELATIONSHIP_NAMES_SET = new HashSet(new HashSet<>(Arrays.asList(RELATIONSHIP_NAMES_SET_VALUES)));
// Singular properties
<$SingleAttr$$
    private <$$uSingleReferenceName$$>Reference <$$singleReferenceName$$>;
$SingleAttr$$>
// Set properties

<$SetAttr$$
    private Set<<$$uSetReferenceName$$>Reference> <$$setReferenceName$$>;
$SetAttr$$>

// List properties
<$ListAttr$$
    private List<<$$uListReferenceName$$>Reference> <$$listReferenceName$$>;
$ListAttr$$>

    // setters and setters
<$SingleAttr$$
    public <$$uSingleReferenceName$$>Reference get<$$uSingleReferenceName$$>Reference() {
        return <$$singleReferenceName$$>;   }

    public void set<$$uSingleReferenceName$$>Reference(<$$uSingleReferenceName$$>Reference <$$singleReferenceName$$>) {
        this.<$$singleReferenceName$$> = <$$singleReferenceName$$>; }
$SingleAttr$$>

// Sets
<$SetAttr$$
    public Set<<$$uSetReferenceName$$>Reference> get<$$uSetReferenceName$$>References() {
        return <$$setReferenceName$$>;
    }

    public void set<$$uSetReferenceName$$>References(Set<<$$uSetReferenceName$$>Reference> <$$setReferenceName$$>) {
        this.<$$setReferenceName$$> =<$$setReferenceName$$>;
    }
$SetAttr$$>

// Lists
<$ListAttr$$
    public List<<$$uListReferenceName$$>Reference> get<$$uListReferenceName$$>References() {
        return <$$listReferenceName$$>;
    }

    public void set<$$uListReferenceName$$>References(Set<<$$uListReferenceName$$>Reference> <$$listReferenceName$$>) {
        this.<$$listReferenceName$$> =<$$listReferenceName$$>;
    }
$ListAttr$$>

 public StringBuilder toString(StringBuilder sb) {
        if (sb == null) {
            sb = new StringBuilder();
        }

        sb.append("<$$uname$$>References{");
        <$ListAttr$$
        sb.append("<$$listReferenceName$$>Reference='").append(<$$listReferenceName$$>.toString());
        $ListAttr$$>
        <$SetAttr$$
        sb.append("<$$setReferenceName$$>Reference='").append(<$$setReferenceName$$>.toString());
        $SetAttr$$>
        <$SingleAttr$$
        sb.append("<$$singleReferenceName$$>Reference='").append(<$$singleReferenceName$$>.toString());
        $SingleAttr$$>

        sb.append('}');

        return sb;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) { return true; }
        if (o == null || getClass() != o.getClass()) { return false; }
        if (!super.equals(o)) { return false; }
         <$$uname$$>References typedThat = (<$$uname$$>References) o;
      // compare single cardinality attributes
  <$$$
         if (this.<$$PropertyName$$> != null && !Objects.equals(this.<$$PropertyName$$>,typedThat.<$$PropertyName$$>)) {
                            return false;
                 }
  $$$>
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode()
    <$$$
    ,this.<$$PropertyName$$>
    $$$>
       );
    }

    @Override
    public String toString() {
        return toString(new StringBuilder()).toString();
    }
}
