<commit_before>/**
 * Created with IntelliJ IDEA.
 * User: vasya
 * Date: 10/26/13
 * Time: 10:04 PM
 * To change this template use File | Settings | File Templates.
 */
package org.andrey_bayev.htb_configurator.htb.leaf;

import org.andrey_bayev.htb_configurator.htb.DefaultHTBClassValues;
import org.andrey_bayev.htb_configurator.htb.SpeedInBytes;

/**
 * This class keeps sfq parameters if user set LEAF=sfq;
 */
public class SFQParams
{
    //todo: overload equals and hashcode
    private SpeedInBytes quantum;//Amount of data in bytes a stream is allowed to dequeue before next queue gets a turn.
    private int perturb;//Period of hash function perturbation.
    // why not name it hashPerturbationPeriod?

    public SFQParams()
    {
        this.quantum = new SpeedInBytes();
        this.quantum.setSpeed(DefaultHTBClassValues.DEFAULT_QUANTUM_SPEED);//default MTU packet value
        this.quantum.setUnit(DefaultHTBClassValues.DEFAULT_SPEED_UNIT);
        this.perturb = DefaultHTBClassValues.DEFAULT_PERTURB;
    }

    public SFQParams(SpeedInBytes quantum, int perturb)
    {

        if (quantum.getSpeed() < 0)
        {
            this.quantum = new SpeedInBytes();
            this.quantum.setSpeed(DefaultHTBClassValues.DEFAULT_QUANTUM_SPEED);
            this.quantum.setUnit(DefaultHTBClassValues.DEFAULT_SPEED_UNIT);
        } else this.quantum = quantum;
        if (perturb < 0) this.perturb = DefaultHTBClassValues.DEFAULT_PERTURB;
            // constants class of SpeedDefaults. There should be no 'magic numbers' in code.
        else this.perturb = perturb;
    }

    public SpeedInBytes getQuantum()
    {
        return quantum;
    }

    public void setQuantum(SpeedInBytes quantum)
    {
        if (quantum.getSpeed() < 0)
        {
            this.quantum.setSpeed(DefaultHTBClassValues.DEFAULT_QUANTUM_SPEED);
            this.quantum.setUnit(DefaultHTBClassValues.DEFAULT_SPEED_UNIT);
        } else this.quantum = quantum;
    }

    public int getPerturb()
    {
        return perturb;
    }

    public void setPerturb(int perturb)
    {
        if (perturb < 0) this.perturb = DefaultHTBClassValues.DEFAULT_PERTURB;
        else this.perturb = perturb;
    }
}
<commit_msg>Equals and hashcode methods were overrided in class SFQParams<commit_after>/**
 * Created with IntelliJ IDEA.
 * User: vasya
 * Date: 10/26/13
 * Time: 10:04 PM
 * To change this template use File | Settings | File Templates.
 */
package org.andrey_bayev.htb_configurator.htb.leaf;

import org.andrey_bayev.htb_configurator.htb.DefaultHTBClassValues;
import org.andrey_bayev.htb_configurator.htb.SpeedInBytes;

/**
 * This class keeps sfq parameters if user set LEAF=sfq;
 */
public class SFQParams
{
    private SpeedInBytes quantum;//Amount of data in bytes a stream is allowed to dequeue before next queue gets a turn.
    private int perturb;//Period of hash function perturbation.
    // why not name it hashPerturbationPeriod?

    public SFQParams()
    {
        this.quantum = new SpeedInBytes();
        this.quantum.setSpeed(DefaultHTBClassValues.DEFAULT_QUANTUM_SPEED);//default MTU packet value
        this.quantum.setUnit(DefaultHTBClassValues.DEFAULT_SPEED_UNIT);
        this.perturb = DefaultHTBClassValues.DEFAULT_PERTURB;
    }

    public SFQParams(SpeedInBytes quantum, int perturb)
    {

        if (quantum.getSpeed() < 0)
        {
            this.quantum = new SpeedInBytes();
            this.quantum.setSpeed(DefaultHTBClassValues.DEFAULT_QUANTUM_SPEED);
            this.quantum.setUnit(DefaultHTBClassValues.DEFAULT_SPEED_UNIT);
        } else this.quantum = quantum;
        if (perturb < 0) this.perturb = DefaultHTBClassValues.DEFAULT_PERTURB;
            // constants class of SpeedDefaults. There should be no 'magic numbers' in code.
        else this.perturb = perturb;
    }

    public SpeedInBytes getQuantum()
    {
        return quantum;
    }

    public void setQuantum(SpeedInBytes quantum)
    {
        if (quantum.getSpeed() < 0)
        {
            this.quantum.setSpeed(DefaultHTBClassValues.DEFAULT_QUANTUM_SPEED);
            this.quantum.setUnit(DefaultHTBClassValues.DEFAULT_SPEED_UNIT);
        } else this.quantum = quantum;
    }

    public int getPerturb()
    {
        return perturb;
    }

    public void setPerturb(int perturb)
    {
        if (perturb < 0) this.perturb = DefaultHTBClassValues.DEFAULT_PERTURB;
        else this.perturb = perturb;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SFQParams sfqParams = (SFQParams) o;

        if (perturb != sfqParams.perturb) return false;
        if (quantum != null ? !quantum.equals(sfqParams.quantum) : sfqParams.quantum != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = quantum != null ? quantum.hashCode() : 0;
        result = 31 * result + perturb;
        return result;
    }
}

{'fraction_non_alphanumeric': 0.08846383741781232, 'fraction_numerical': 0.00617652918908149, 'mean_word_length': 2.7858220211161386, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6001605', 'n_tokens_mistral': 1599, 'n_tokens_neox': 1491, 'n_words': 369}