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;
    }
}

@@ -2741,35 +2741,49 @@
 g) obj;%0A        
-if 
+%0A        return !
 (!Objects.equals
@@ -2813,19 +2813,16 @@
 repend_)
-) %7B
 %0A       
@@ -2830,44 +2830,15 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 !Obj
@@ -2885,19 +2885,16 @@
 refix())
-) %7B
 %0A       
@@ -2902,44 +2902,15 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 !Obj
@@ -2965,19 +2965,16 @@
 ength())
-) %7B
 %0A       
@@ -2982,44 +2982,15 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 !Obj
@@ -3039,19 +3039,16 @@
 arMap())
-) %7B
 %0A       
@@ -3056,44 +3056,15 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 !Obj
@@ -3117,19 +3117,16 @@
 nType())
-) %7B
 %0A       
@@ -3134,44 +3134,15 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 !Obj
@@ -3195,19 +3195,16 @@
 owels())
-) %7B
 %0A       
@@ -3212,44 +3212,15 @@
     
-return false;%0A        %7D%0A        if (
+    && 
 this
@@ -3240,19 +3240,16 @@
 er.auto_
-) %7B
 %0A       
@@ -3257,132 +3257,45 @@
     
-return false;%0A        %7D%0A        if (this.random_ != other.random_) %7B%0A            return false;%0A        %7D%0A        return true
+    && this.random_ != other.random_)
 ;%0A  

Simplify logic in DefaultSetting.equals()