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

@javax.enterprise.inject.Vetoed
public class WertelistenUK
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.wertelisten.entity.WertelistenArt wertelistenArt;

    public de.ivu.elect.business.wertelisten.entity.WertelistenArt getWertelistenArt(){
      return wertelistenArt;
    }

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

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

  public WertelistenUK(
java.lang.String name
, de.ivu.elect.business.wertelisten.entity.WertelistenArt wertelistenArt
,   de.ivu.elect.business.wahl.entity.WahlUK wahlUK
  ) {
    super();


      this.name = name;
      this.wertelistenArt = wertelistenArt;
        this.wahlUK = wahlUK;
    }

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

            WertelistenUK other = (WertelistenUK) obj;

                if (name == null) {
          if (other.name != null) {
            return false;
          }
        } else if (!name.equals(other.name)) {
          return false;
        }
                if (wertelistenArt == null) {
          if (other.wertelistenArt != null) {
            return false;
          }
        } else if (!wertelistenArt.equals(other.wertelistenArt)) {
          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 WertelistenConstants.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(WertelistenConstants.MESSAGE_KEY_ENTITY_EINZAHL, WertelistenConstants.MESSAGE_KEY_NAME_EINZAHL, name));
                    result.add(new de.ivu.elect.jee.entity.tk.EntityFieldValue(WertelistenConstants.MESSAGE_KEY_ENTITY_EINZAHL, WertelistenConstants.MESSAGE_KEY_WERTELISTEN_ART_EINZAHL, wertelistenArt));
        
        return result;
      }
  
    @Override
  public String toString() {
    return "WertelistenUK[" + toStringParameter() + "]";
  }

            protected String toStringParameter() {
              String result = ""

                                                        +"name="+name
                            +", "                +"wertelistenArt="+wertelistenArt
                                        +", "                +"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(name);
         list.add(wertelistenArt);
     return list;
   }

            public static <E extends Wertelisten> java.util.Map<WertelistenUK, E> mappeWertelistenNachUK(java.util.Collection<E> entities) {

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


                public static Function<Wertelisten, WertelistenUK> getWertelistenToUKFunction() {
                return Wertelisten::getWertelistenUK;
                }

}
