/*
 * Fachlicher Schlüssel für JPA Entität
 */
package de.ivu.elect.business.wahlvorschlag.entity;

import de.ivu.elect.jee.faces.Messages;
import java.util.function.Function;

@javax.enterprise.inject.Vetoed
public class ListeTK
extends de.ivu.elect.business.wahlvorschlag.entity.WahlvorschlagTK
  {

  private static final long serialVersionUID = 1L;

  private final int hashCode;


  public ListeTK(
java.lang.String discriminator
,   de.ivu.elect.business.gruppeimgebiet.entity.GruppeImGebietTK gruppeImGebietTK
  ) {
super(

discriminator

,   gruppeImGebietTK
);


    
hashCode = calculateHashCode();
  }

  @Override
  public int hashCode(){
    return hashCode;
  }


  protected int calculateHashCode() {
        int result = super.calculateHashCode();
    
    
    return result;
  }

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

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

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


                    if (super.equals(obj)) {
          return true;
        }
            // Keine Attribute definiert => nicht gleich
    return false;
    
  }

  protected boolean hatAttribute() {
              return super.hatAttribute();
            }

  @Override
  public String getEntityMessageKey() {
    return ListeConstants.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(super.getAllEntityFieldValues());
    result.addAll(getEntityFieldValuesForEntity());
    return result;
  }

  @Override
  public java.util.List<de.ivu.elect.jee.entity.tk.EntityFieldValue> getEntityFieldValuesForEntity() {
            return java.util.Collections.emptyList();
      }


            @Override
            public String toString() {
            return "ListeTK[" + toStringParameter() + "]";
            }



            protected String toStringParameter() {
            String result = ""

                                    
            ;
                            String resultParent = super.toStringParameter();
                if (resultParent.isEmpty()) {
                return result;
                }
                if (result.isEmpty()) {
                return resultParent;
                }
                return resultParent +", " + result;
            
            }


      @Override       protected String toStringLokalisiertFields(Messages messages) {
        return ""
                                                              + super.toStringLokalisiertFields(messages)
                     ;
      }


            private String toStringLokalisiert(de.ivu.elect.jee.entity.tk.EntityTK entityTK, Messages messages) {
                if (entityTK != null) {
                    return entityTK.toStringLokalisiert(messages);
                }
                return null;
            }

            public static <E extends Liste> java.util.Map<ListeTK, E> mappeListeNachTK(java.util.Collection<E> entities) {
                return entities.stream().collect(java.util.stream.Collectors.toMap(Liste::getListeTK, Function.<E>identity(), (u,v)-> v));
                }


                public static Function<Liste, ListeTK> getListeToTKFunction() {
                return Liste::getListeTK;
                }

}
