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

@javax.enterprise.inject.Vetoed
public class ReferendumOptionUK
extends de.ivu.elect.business.wahlvorschlag.entity.WahlvorschlagUK
  {

  private static final long serialVersionUID = 1L;

    protected final java.lang.Long position;

    public java.lang.Long getPosition(){
      return position;
    }


  public ReferendumOptionUK(
java.lang.String discriminator
,   de.ivu.elect.business.gruppeimgebiet.entity.GruppeImGebietUK gruppeImGebietUK
, java.lang.Long position
  ) {
super(
discriminator
,   gruppeImGebietUK
);


      this.position = position;
      }

  @Override
  public int hashCode() {
        int result = super.hashCode();
    
    
                    result = result + ((position == null) ? 0 : position.hashCode());
        
            
    return result;
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }

    if (obj == null) {
      return false;
    }

        if (!super.equals(obj)) {
      return false;
    }
    
    if (getClass() != obj.getClass()) {
      return false;
    }

            ReferendumOptionUK other = (ReferendumOptionUK) obj;

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

  @Override
  public String getEntityMessageKey() {
    return ReferendumOptionConstants.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(super.getAllEntityFieldValues());
    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(ReferendumOptionConstants.MESSAGE_KEY_ENTITY_EINZAHL, ReferendumOptionConstants.MESSAGE_KEY_POSITION_EINZAHL, position));
        
        return result;
      }
  
    @Override
  public String toString() {
    return "ReferendumOptionUK[" + toStringParameter() + "]";
  }

            protected String toStringParameter() {
              String result = ""

                                                        +"position="+position
                                    ;
                            String resultParent = super.toStringParameter();
                if (resultParent.isEmpty()) {
                  return result;
                }
                if (result.isEmpty()) {
                  return resultParent;
                }
                return resultParent +", " + result;
            
            }




        
   @Override
   protected ArrayList<Object> getAllUKFieldValues() {
              ArrayList<Object> list = super.getAllUKFieldValues();
              list.add(position);
     return list;
   }

            public static <E extends ReferendumOption> java.util.Map<ReferendumOptionUK, E> mappeReferendumOptionNachUK(java.util.Collection<E> entities) {

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


                public static Function<ReferendumOption, ReferendumOptionUK> getReferendumOptionToUKFunction() {
                return ReferendumOption::getReferendumOptionUK;
                }

}
