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

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

  private static final long serialVersionUID = 1L;

    protected final java.lang.String schluessel;

    public java.lang.String getSchluessel(){
      return schluessel;
    }

  protected final de.ivu.elect.business.wahl.entity.WahlUK wahlUK;

    public de.ivu.elect.business.wahl.entity.WahlUK getWahlUK(){
      return wahlUK;
    }

  public GruppeUK(
java.lang.String schluessel
,   de.ivu.elect.business.wahl.entity.WahlUK wahlUK
  ) {
    super();


      this.schluessel = schluessel;
        this.wahlUK = wahlUK;
    }

  @Override
  public int hashCode() {
        int result = 1;
    
    
                    result = result + ((schluessel == null) ? 0 : schluessel.hashCode());
        
                    result = result + ((wahlUK == null) ? 0 : wahlUK.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;
    }

            GruppeUK other = (GruppeUK) obj;

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

  @Override
  public String getEntityMessageKey() {
    return GruppeConstants.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(wahlUK.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(GruppeConstants.MESSAGE_KEY_ENTITY_EINZAHL, GruppeConstants.MESSAGE_KEY_SCHLUESSEL_EINZAHL, schluessel));
        
        return result;
      }
  
    @Override
  public String toString() {
    return "GruppeUK[" + toStringParameter() + "]";
  }

            protected String toStringParameter() {
              String result = ""

                                                        +"schluessel="+schluessel
                                        +", "                +"wahlUK="+wahlUK
                        ;
                          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(schluessel);
     return list;
   }

            public static <E extends Gruppe> java.util.Map<GruppeUK, E> mappeGruppeNachUK(java.util.Collection<E> entities) {

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


                public static Function<Gruppe, GruppeUK> getGruppeToUKFunction() {
                return Gruppe::getGruppeUK;
                }

}
