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

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

  private static final long serialVersionUID = 1L;

    protected final String schluessel;

    public String getSchluessel(){
      return schluessel;
    }

  protected final de.ivu.elect.business.mandant.entity.MandantUK mandantUK;

    public de.ivu.elect.business.mandant.entity.MandantUK getMandantUK(){
      return mandantUK;
    }

  public KonfigurationUK(
String schluessel
,   de.ivu.elect.business.mandant.entity.MandantUK mandantUK
  ) {
    super();


      this.schluessel = schluessel;
        this.mandantUK = mandantUK;
    }

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

            KonfigurationUK other = (KonfigurationUK) obj;

                if (schluessel == null) {
          if (other.schluessel != null) {
            return false;
          }
        } else if (!schluessel.equals(other.schluessel)) {
          return false;
        }
        
                if (mandantUK == null) {
          if (other.mandantUK != null) {
            return false;
          }
        } else if (!mandantUK.equals(other.mandantUK)) {
          return false;
        }
            
    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());
    result.addAll(mandantUK.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(KonfigurationConstants.MESSAGE_KEY_ENTITY_EINZAHL, KonfigurationConstants.MESSAGE_KEY_SCHLUESSEL_EINZAHL, schluessel));
        
        return result;
      }
  
    @Override
  public String toString() {
    return "KonfigurationUK[" + toStringParameter() + "]";
  }

            protected String toStringParameter() {
              String result = ""

                                                        +"schluessel="+schluessel
                                        +", "                +"mandantUK="+mandantUK
                        ;
                          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 Konfiguration> java.util.Map<KonfigurationUK, E> mappeKonfigurationNachUK(java.util.Collection<E> entities) {

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


                public static Function<Konfiguration, KonfigurationUK> getKonfigurationToUKFunction() {
                return Konfiguration::getKonfigurationUK;
                }

}
