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

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

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

  private static final long serialVersionUID = 1L;

  private final int hashCode;

    protected final java.lang.String plz;
    public java.lang.String getPlz(){
      return plz;
    }

  public GeodataPlzTK(
java.lang.String plz
  ) {
    super();


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

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


  protected int calculateHashCode() {
        int result = 1;
    
    
                    result = result + ((plz == null) ? 0 : plz.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 GeodataPlzTK)) {
        return false;
      }

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

    }

        GeodataPlzTK other = (GeodataPlzTK) obj;

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

  protected boolean hatAttribute() {
        return true;
      }

  @Override
  public String getEntityMessageKey() {
    return GeodataPlzConstants.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(GeodataPlzConstants.MESSAGE_KEY_ENTITY_EINZAHL, GeodataPlzConstants.MESSAGE_KEY_PLZ_EINZAHL, plz));
        
        return result;
      }


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



            protected String toStringParameter() {
            String result = ""

                                        +"plz="+plz
                        
            ;
                            return result;
            
            }
  
  @Override
  public String toStringLokalisiert(Messages messages) {
    return messages.getMessageForMessageKey(getEntityMessageKey()) + " ["
    + messages.getMessageForMessageKey(GeodataPlzConstants.MESSAGE_KEY_PLZ_EINZAHL) + "=" + plz
                + "]"

            ;
  }

            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 GeodataPlz> java.util.Map<GeodataPlzTK, E> mappeGeodataPlzNachTK(java.util.Collection<E> entities) {
                return entities.stream().collect(java.util.stream.Collectors.toMap(GeodataPlz::getGeodataPlzTK, Function.<E>identity(), (u,v)-> v));
                }


                public static Function<GeodataPlz, GeodataPlzTK> getGeodataPlzToTKFunction() {
                return GeodataPlz::getGeodataPlzTK;
                }

}
