<commit_before>package org.ovirt.engine.core.common.businessentities;

import org.ovirt.engine.core.compat.*;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import java.io.Serializable;

@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "VdsVersion")
public class VdsVersion implements Serializable {
    private static final long serialVersionUID = -3138828435468456070L;
    private String softwareVersion;
    private String softwareRevision;
    private String buildName;
    private String versionName;
    private Version mFullVersion;

    @XmlElement(name = "SoftwareVersion")
    public String getSoftwareVersion() {
        return softwareVersion;
    }

    public void setSoftwareVersion(String value) {
        softwareVersion = value;
    }

    @XmlElement(name = "SoftwareRevision")
    public String getSoftwareRevision() {
        return softwareRevision;
    }

    public void setSoftwareRevision(String value) {
        softwareRevision = value;
    }

    @XmlElement(name = "BuildName")
    public String getBuildName() {
        return buildName;
    }

    public void setBuildName(String value) {
        buildName = value;
    }

    @XmlElement(name = "VersionName")
    public String getVersionName() {
        return versionName;
    }

    public void setVersionName(String value) {
        versionName = value;
    }

    /**
     * Version in .Net style: a.b.c.d when a: major version, b: minor version , c: major revision, d: minor revision
     * assumption: Vds version in format: x.y where x = major version, y= minor version. there is no major revision
     * recieved from vds - always 0
     */
    public Version getFullVersion() {
        if (mFullVersion == null) {
            // defencive code for prevent incorrect versioning
            try {
                if (getSoftwareVersion() != null && getSoftwareRevision() != null) {
                    String stringVersion;
                    String[] revision = getSoftwareRevision().split("[.]", -1);

                    if (revision.length > 1) {
                        stringVersion = StringFormat.format("%s.%s", getSoftwareVersion(), getSoftwareRevision());
                    } else {
                        stringVersion = StringFormat.format("%s.0.%s", getSoftwareVersion(), getSoftwareRevision());
                    }

                    mFullVersion = new Version(stringVersion);
                }
            } catch (java.lang.Exception e) {
                log.warnFormat("Couldn't parse vds version: {0} , {1}", getSoftwareVersion(), getSoftwareRevision());
            }
        }

        return mFullVersion;
    }

    public Version getPartialVersion() {
        return getSoftwareVersion() == null ? null : new Version(getSoftwareVersion());
    }

    @Override
    public boolean equals(Object obj) {
        if (super.equals(obj)) {
            return true;
        }

        VdsVersion other = (VdsVersion) ((obj instanceof VdsVersion) ? obj : null);
        if (other == null) {
            return false;
        }
        return (getFullVersion() == null && other.getFullVersion() == null)
                || (getFullVersion() != null && getFullVersion().equals(other.getFullVersion()));
    }

    @Override
    public int hashCode() {
        return getFullVersion() != null ? getFullVersion().hashCode() : -1;
    }

    private static LogCompat log = LogFactoryCompat.getLog(VdsVersion.class);

    public VdsVersion() {
    }
}<commit_msg>core: Code cleanup for VdsVersion<commit_after>package org.ovirt.engine.core.common.businessentities;

import java.io.Serializable;

import org.ovirt.engine.core.compat.LogCompat;
import org.ovirt.engine.core.compat.LogFactoryCompat;
import org.ovirt.engine.core.compat.StringFormat;
import org.ovirt.engine.core.compat.Version;

public class VdsVersion implements Serializable {
    private static final long serialVersionUID = -3138828435468456070L;
    private static final LogCompat log = LogFactoryCompat.getLog(VdsVersion.class);
    private String softwareVersion;
    private String softwareRevision;
    private String buildName;
    private String versionName;
    private Version mFullVersion;

    public VdsVersion() {
    }

    public String getSoftwareVersion() {
        return softwareVersion;
    }

    public void setSoftwareVersion(String value) {
        softwareVersion = value;
    }

    public String getSoftwareRevision() {
        return softwareRevision;
    }

    public void setSoftwareRevision(String value) {
        softwareRevision = value;
    }

    public String getBuildName() {
        return buildName;
    }

    public void setBuildName(String value) {
        buildName = value;
    }

    public String getVersionName() {
        return versionName;
    }

    public void setVersionName(String value) {
        versionName = value;
    }

    /**
     * Version in .Net style a.b.c.d when:
     * <ul>
     * <li>a: major version</li>
     * <li>b: minor version</li>
     * <li>c: major revision</li>
     * <li>d: minor revision</li>
     * <ul>
     * <p>
     * Assumption: VDS version in format: x.y where x = major version, y= minor version. There is no major revision
     * received from VDS - always 0
     */
    public Version getFullVersion() {
        if (mFullVersion == null) {
            // defensive code for prevent incorrect versioning
            try {
                if (getSoftwareVersion() != null && getSoftwareRevision() != null) {
                    String stringVersion;
                    String[] revision = getSoftwareRevision().split("[.]", -1);

                    if (revision.length > 1) {
                        stringVersion = StringFormat.format("%s.%s", getSoftwareVersion(), getSoftwareRevision());
                    } else {
                        stringVersion = StringFormat.format("%s.0.%s", getSoftwareVersion(), getSoftwareRevision());
                    }

                    mFullVersion = new Version(stringVersion);
                }
            } catch (Exception e) {
                log.info(StringFormat.format("Couldn't parse vds version: %s , %s",
                        getSoftwareVersion(),
                        getSoftwareRevision()));
            }
        }

        return mFullVersion;
    }

    public Version getPartialVersion() {
        return getSoftwareVersion() == null ? null : new Version(getSoftwareVersion());
    }

    @Override
    public boolean equals(Object obj) {
        if (super.equals(obj)) {
            return true;
        }

        VdsVersion other = (VdsVersion) ((obj instanceof VdsVersion) ? obj : null);
        if (other == null) {
            return false;
        }
        return (getFullVersion() == null && other.getFullVersion() == null)
                || (getFullVersion() != null && getFullVersion().equals(other.getFullVersion()));
    }

    @Override
    public int hashCode() {
        return getFullVersion() != null ? getFullVersion().hashCode() : -1;
    }

}
{'fraction_non_alphanumeric': 0.10422495803021824, 'fraction_numerical': 0.006994963626189144, 'mean_word_length': 2.3020785219399538, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '3115892', 'n_tokens_mistral': 1981, 'n_tokens_neox': 1835, 'n_words': 481}