/*
 * Unique Schlüssel für JPA Entität
 */
package de.ivu.elect.business.dokumente.entity;
import java.util.function.Function;
import java.util.ArrayList;
import java.util.stream.Collectors;

@javax.enterprise.inject.Vetoed
public class DokumentVorlageUK
implements de.ivu.elect.jee.entity.tk.EntityUK, java.io.Serializable
  {

  private static final long serialVersionUID = 1L;

    protected final java.lang.String name;

    public java.lang.String getName(){
      return name;
    }

  protected final de.ivu.elect.business.wahl.entity.WahlterminUK wahlterminUK;

    public de.ivu.elect.business.wahl.entity.WahlterminUK getWahlterminUK(){
      return wahlterminUK;
    }

  public DokumentVorlageUK(
java.lang.String name
,   de.ivu.elect.business.wahl.entity.WahlterminUK wahlterminUK
  ) {
    super();


      this.name = name;
        this.wahlterminUK = wahlterminUK;
    }

  @Override
  public int hashCode() {
        int result = 1;
    
    
                    result = result + ((name == null) ? 0 : name.hashCode());
        
                    result = result + ((wahlterminUK == null) ? 0 : wahlterminUK.hashCode());
            
    return result;
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }

    if (obj == null) {
      return false;
    }

    
    if (getClass() != obj.getClass()) {
      return false;
    }

            DokumentVorlageUK other = (DokumentVorlageUK) obj;

                if (name == null) {
          if (other.name != null) {
            return false;
          }
        } else if (!name.equals(other.name)) {
          return false;
        }
        
                if (wahlterminUK == null) {
          if (other.wahlterminUK != null) {
            return false;
          }
        } else if (!wahlterminUK.equals(other.wahlterminUK)) {
          return false;
        }
            
    return true;
  }

  @Override
  public String getEntityMessageKey() {
    return DokumentVorlageConstants.MESSAGE_KEY_ENTITY_EINZAHL;
  }

  @Override
  public java.util.List<de.ivu.elect.jee.entity.tk.EntityFieldValue> getAllEntityFieldValues() {
    java.util.List<de.ivu.elect.jee.entity.tk.EntityFieldValue> result = new java.util.ArrayList<>();

    result.addAll(getEntityFieldValuesForEntity());
    result.addAll(wahlterminUK.getAllEntityFieldValues());
    return result;
  }

  @Override
  public java.util.List<de.ivu.elect.jee.entity.tk.EntityFieldValue> getEntityFieldValuesForEntity() {
            java.util.List<de.ivu.elect.jee.entity.tk.EntityFieldValue> result = new java.util.ArrayList<>();

                    result.add(new de.ivu.elect.jee.entity.tk.EntityFieldValue(DokumentVorlageConstants.MESSAGE_KEY_ENTITY_EINZAHL, DokumentVorlageConstants.MESSAGE_KEY_NAME_EINZAHL, name));
        
        return result;
      }
  
    @Override
  public String toString() {
    return "DokumentVorlageUK[" + toStringParameter() + "]";
  }

            protected String toStringParameter() {
              String result = ""

                                                        +"name="+name
                                        +", "                +"wahlterminUK="+wahlterminUK
                        ;
                          return result;
            
            }




          public String allUKFields() {
    return String.join(", ", getAllUKFieldValues().stream()
         .map(object -> (object != null ? object.toString() : null))
         .collect(Collectors.toList()));
    }

   protected ArrayList<Object> getAllUKFieldValues() {
              ArrayList<Object> list = new ArrayList<>();
              list.add(name);
     return list;
   }

            public static <E extends DokumentVorlage> java.util.Map<DokumentVorlageUK, E> mappeDokumentVorlageNachUK(java.util.Collection<E> entities) {

                return entities.stream().collect(java.util.stream.Collectors.toMap(DokumentVorlage::getDokumentVorlageUK, Function.<E>identity(), (u,v)->v));
             }


                public static Function<DokumentVorlage, DokumentVorlageUK> getDokumentVorlageToUKFunction() {
                return DokumentVorlage::getDokumentVorlageUK;
                }

}
