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

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

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

  private static final long serialVersionUID = 1L;

  private final int hashCode;

    protected final String schluessel;
    public String getSchluessel(){
      return schluessel;
    }

  public KonfigurationTK(
String schluessel
  ) {
    super();


      this.schluessel = schluessel;
    
hashCode = calculateHashCode();
  }

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


  protected int calculateHashCode() {
        int result = 1;
    
    
                    result = result + ((schluessel == null) ? 0 : schluessel.hashCode());
        
            
    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 (getClass() != obj.getClass()) {
      if (!(obj instanceof KonfigurationTK)) {
        return false;
      }

      if (!obj.getClass().isInstance(this)) {
        return obj.equals(this); // equals-Methode aus speziellerer Klasse verwenden
      }

    }

        KonfigurationTK other = (KonfigurationTK) obj;

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

  protected boolean hatAttribute() {
        return true;
      }

  @Override
  public String getEntityMessageKey() {
    return KonfigurationConstants.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());
    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(KonfigurationConstants.MESSAGE_KEY_ENTITY_EINZAHL, KonfigurationConstants.MESSAGE_KEY_SCHLUESSEL_EINZAHL, schluessel));
        
        return result;
      }


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



            protected String toStringParameter() {
            String result = ""

                                        +"schluessel="+schluessel
                        
            ;
                            return result;
            
            }

  @Override
  public String toStringLokalisiert(IMessages messages) {
    return messages.getMessageForMessageKey(getEntityMessageKey()) + " ["
            + toStringLokalisiertFields(messages)
            + "]"
            ;
   }

            protected String toStringLokalisiertFields(IMessages messages) {
        return ""
                                      + messages.getMessageForMessageKey(KonfigurationConstants.MESSAGE_KEY_SCHLUESSEL_EINZAHL) + "=" +

                                    schluessel
                
                                             ;
      }


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

            public static <E extends Konfiguration> java.util.Map<KonfigurationTK, E> mappeKonfigurationNachTK(java.util.Collection<E> entities) {
                return entities.stream().collect(java.util.stream.Collectors.toMap(Konfiguration::getKonfigurationTK, Function.<E>identity(), (u,v)-> v));
                }


                public static Function<Konfiguration, KonfigurationTK> getKonfigurationToTKFunction() {
                return Konfiguration::getKonfigurationTK;
                }

}
