All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yiwowang.intellij.finding.base.bean.Component Maven / Gradle / Ivy

The newest version!
package com.yiwowang.intellij.finding.base.bean;

import com.google.gson.annotations.SerializedName;
import org.apache.commons.lang3.StringUtils;

import java.util.Collection;

/**
 * 依赖信息
 */
public class Component {
    public Component() {

    }

    public Component(String name, String filePath) {
        this.name = name;
        this.filePath = filePath;
    }

    public boolean fromSystem;
    // TODO name不带版本
    @SerializedName("name")
    public String name;
    @SerializedName("version")
    private String version;
    @SerializedName("file_path")
    public String filePath;
    // TODO 兼容project jar
    @SerializedName("dep_ref")
    public Collection depRef;
    /**
     * full dep
     */
    public Collection depRefFull;
    /**
     * include self
     */
    public Collection codeRef;
    private String fullName;

    @Override
    public int hashCode() {
        if (name != null) {
            return name.hashCode();
        } else {
            return super.hashCode();
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Component) {
            return StringUtils.equals(((Component) obj).name, name);
        }
        return super.equals(obj);
    }

    @Override
    public String toString() {
        return "name:" + name + ",filePath:" + filePath;
    }

    public String getFullName() {
        if (!StringUtils.isEmpty(fullName)) {
            return fullName;
        }
        if (!StringUtils.isEmpty(name)) {
            if (!StringUtils.isEmpty(version)) {
                fullName = name + ":" + version;
            } else {
                fullName = name;
            }
        }

        return fullName;
    }

    public static String getNameByFull(String fullName) {
        String[] arr = fullName.split(":");
        if (arr.length >= 3) {
            return arr[0] + ":" + arr[1];
        } else {
            return fullName;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy