package com.hida.model;

import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * A type of Setting that references the default values that could be used to
 * create a set of Pids. These default values can be overridden and only one
 * DefaultSetting object is persisted in the database at any given time.
 *
 * @author lruffin
 */
@Entity
@Table(name = "DEFAULT_SETTING")
public class DefaultSetting extends Setting {

    @Column(name = "PREPEND", nullable = false)
    private String Prepend;

    @Column(name = "ISAUTO")
    private boolean Auto;

    @Column(name = "ISRANDOM")
    private boolean Random;
    
    @Column(name = "CACHESIZE")
    private long CacheSize;

    /**
     * Constructor used to create a DefaultSetting entity
     *
     * @param Prepend Primarily used to turn a Pid into a PURL
     * @param Prefix A sequence of characters that appear in the beginning of
     * PIDs
     * @param CacheSize The size of the cache that'll be generated whenever the
     * context is refreshed
     * @param TokenType An enum used to configure PIDS
     * @param CharMap A sequence of characters used to configure PIDs
     * @param RootLength Designates the length of the id's root
     * @param SansVowels Dictates whether or not vowels are allowed
     * @param Auto Determines which generator, either Auto or Custom, will be
     * used
     * @param Random Determines if the PIDs are created randomly or sequentially
     */
    public DefaultSetting(String Prepend, String Prefix, long CacheSize, Token TokenType, 
            String CharMap, int RootLength, boolean SansVowels, boolean Auto, boolean Random) {
        super(Prefix, TokenType, CharMap, RootLength, SansVowels);
        this.Prepend = Prepend;
        this.CacheSize = CacheSize;
        this.Auto = Auto;
        this.Random = Random;

    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 43 * hash + Objects.hashCode(this.Prepend);
        hash = 43 * hash + Objects.hashCode(this.getCharMap());
        hash = 43 * hash + Objects.hashCode(this.getPrefix());
        hash = 43 * hash + Objects.hashCode(this.getTokenType());
        hash = 43 * hash + Objects.hashCode(this.getRootLength());
        hash = 43 * hash + Objects.hashCode(this.isSansVowels());
        hash = 43 * hash + (this.Auto ? 1 : 0);
        hash = 43 * hash + (this.Random ? 1 : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final DefaultSetting other = (DefaultSetting) obj;
        if (!Objects.equals(this.Prepend, other.Prepend)) {
            return false;
        }
        if (!Objects.equals(this.getPrefix(), other.getPrefix())) {
            return false;
        }
        if (!Objects.equals(this.getRootLength(), other.getRootLength())) {
            return false;
        }
        if (!Objects.equals(this.getCharMap(), other.getCharMap())) {
            return false;
        }
        if (!Objects.equals(this.getTokenType(), other.getTokenType())) {
            return false;
        }
        if (!Objects.equals(this.isSansVowels(), other.isSansVowels())) {
            return false;
        }
        if (this.Auto != other.Auto) {
            return false;
        }
        if (this.Random != other.Random) {
            return false;
        }
        return true;
    }

    /**
     * No-arg constructor used by Hibernate
     */
    public DefaultSetting() {

    }

    public String getPrepend() {
        return this.Prepend;
    }

    public void setPrepend(String prepend) {
        this.Prepend = prepend;
    }

    public boolean isAuto() {
        return Auto;
    }

    public void setAuto(boolean Auto) {
        this.Auto = Auto;
    }

    public boolean isRandom() {
        return Random;
    }

    public void setRandom(boolean Random) {
        this.Random = Random;
    }

    public long getCacheSize() {
        return CacheSize;
    }

    public void setCacheSize(long CacheSize) {
        this.CacheSize = CacheSize;
    }        
}

@@ -2734,35 +2734,49 @@
 g) obj;%0A        
-if 
+%0A        return !
 (!Objects.equals
@@ -2785,23 +2785,28 @@
 his.
+get
 Prepend
+()
 , other.
 Prep
@@ -2805,19 +2805,21 @@
 her.
+get
 Prepend
+(
 ))
- %7B
 %0A   
@@ -2831,44 +2831,15 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 !Obj
@@ -2886,19 +2886,16 @@
 refix())
-) %7B
 %0A       
@@ -2903,44 +2903,15 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 !Obj
@@ -2966,19 +2966,16 @@
 ength())
-) %7B
 %0A       
@@ -2983,44 +2983,15 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 !Obj
@@ -3040,19 +3040,16 @@
 arMap())
-) %7B
 %0A       
@@ -3057,44 +3057,15 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 !Obj
@@ -3118,19 +3118,16 @@
 nType())
-) %7B
 %0A       
@@ -3135,44 +3135,15 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 !Obj
@@ -3196,19 +3196,16 @@
 owels())
-) %7B
 %0A       
@@ -3213,53 +3213,28 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 this.
+is
 Auto
+()
  != 
@@ -3239,23 +3239,24 @@
 = other.
+is
 Auto
+(
 )
- %7B
 %0A       
@@ -3264,55 +3264,30 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 this.
+is
 Random
+()
  != 
@@ -3296,73 +3296,19 @@
 her.
+is
 Random
-) %7B%0A            return false;%0A        %7D%0A        return true
+())
 ;%0A  

Simplify logic in DefaultSetting.equals()