<commit_before>/**
 * Copyright 2015 Maven Source Dependencies
 * Plugin contributors as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.l2x6.maven.srcdeps;

public class ScmVersion {

    public enum WellKnownType { branch, tag, revision };

    public static ScmVersion fromSrcdepsVersionString(String version) {
        int pos = version.indexOf(SrcdepsConstants.SRC_VERSION_INFIX);
        if (pos >= 0) {
            int versionTypeStart = pos + SrcdepsConstants.SRC_VERSION_INFIX.length();
            int versionTypeEnd = version.indexOf(SrcdepsConstants.SRC_VERSION_DELIMITER, versionTypeStart);
            if (versionTypeEnd >= 0) {
                String versionType = version.substring(versionTypeStart, versionTypeEnd);
                return new ScmVersion(versionType, version.substring(versionTypeEnd + 1));
            } else {
                throw new RuntimeException(
                        "Version string '" + version + "' contains '" + SrcdepsConstants.SRC_VERSION_INFIX
                                + " that is not followed by a version type such as 'tag', 'branch', or 'revision'.");
            }
        } else {
            return null;
        }
    }

    /**
     * See https://maven.apache.org/scm/maven-scm-plugin/checkout-mojo.html#
     * scmVersion
     */
    private final String version;

    /**
     * See https://maven.apache.org/scm/maven-scm-plugin/checkout-mojo.html#
     * scmVersionType
     */
    private final String versionType;

    public ScmVersion(String versionType, String version) {
        super();
        this.versionType = versionType;
        this.version = version;
    }

    /**
     * @return version see {@link #versionType}
     */
    public String getVersion() {
        return version;
    }

    /**
     * @return versionType see {@link #version}
     */
    public String getVersionType() {
        return versionType;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((version == null) ? 0 : version.hashCode());
        result = prime * result + ((versionType == null) ? 0 : versionType.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "ScmVersionElement [version=" + version + ", versionType=" + versionType + "]";
    }

    public WellKnownType getWellKnownType() {
        return WellKnownType.valueOf(versionType);
    }

}
<commit_msg>Re-add missing ScmVersion.equals(Object)<commit_after>/**
 * Copyright 2015 Maven Source Dependencies
 * Plugin contributors as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.l2x6.maven.srcdeps;

public class ScmVersion {

    public enum WellKnownType { branch, revision, tag };

    public static ScmVersion fromSrcdepsVersionString(String version) {
        int pos = version.indexOf(SrcdepsConstants.SRC_VERSION_INFIX);
        if (pos >= 0) {
            int versionTypeStart = pos + SrcdepsConstants.SRC_VERSION_INFIX.length();
            int versionTypeEnd = version.indexOf(SrcdepsConstants.SRC_VERSION_DELIMITER, versionTypeStart);
            if (versionTypeEnd >= 0) {
                String versionType = version.substring(versionTypeStart, versionTypeEnd);
                return new ScmVersion(versionType, version.substring(versionTypeEnd + 1));
            } else {
                throw new RuntimeException(
                        "Version string '" + version + "' contains '" + SrcdepsConstants.SRC_VERSION_INFIX
                                + " that is not followed by a version type such as 'tag', 'branch', or 'revision'.");
            }
        } else {
            return null;
        }
    }

    /**
     * See https://maven.apache.org/scm/maven-scm-plugin/checkout-mojo.html#
     * scmVersion
     */
    private final String version;

    /**
     * See https://maven.apache.org/scm/maven-scm-plugin/checkout-mojo.html#
     * scmVersionType
     */
    private final String versionType;

    public ScmVersion(String versionType, String version) {
        super();
        this.versionType = versionType;
        this.version = version;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        ScmVersion other = (ScmVersion) obj;
        if (version == null) {
            if (other.version != null)
                return false;
        } else if (!version.equals(other.version))
            return false;
        if (versionType == null) {
            if (other.versionType != null)
                return false;
        } else if (!versionType.equals(other.versionType))
            return false;
        return true;
    }

    /**
     * @return version see {@link #versionType}
     */
    public String getVersion() {
        return version;
    }

    /**
     * @return versionType see {@link #version}
     */
    public String getVersionType() {
        return versionType;
    }

    public WellKnownType getWellKnownType() {
        return WellKnownType.valueOf(versionType);
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((version == null) ? 0 : version.hashCode());
        result = prime * result + ((versionType == null) ? 0 : versionType.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "ScmVersionElement [version=" + version + ", versionType=" + versionType + "]";
    }

}

{'fraction_non_alphanumeric': 0.0991833704528582, 'fraction_numerical': 0.005345211581291759, 'mean_word_length': 2.313330054107231, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1696330', 'n_tokens_mistral': 1849, 'n_tokens_neox': 1766, 'n_words': 546}