class ComponentIdentity {

    public enum ObjectType {
        COMPONENT,
        SERVICE
    }

    private ObjectType objectType;
    private PackageURL purl;
    private PackageURL purlCoordinates;
    private String cpe;
    private String swidTagId;
    private String group;
    private String name;
    private String version;
    private UUID uuid;

    public ComponentIdentity(final PackageURL purl, final String cpe, final String swidTagId,
                             final String group, final String name, final String version) {
        this.purl = purl;
        this.purlCoordinates = PurlUtil.silentPurlCoordinatesOnly(purl);
        this.cpe = cpe;
        this.swidTagId = swidTagId;
        this.group = group;
        this.name = name;
        this.version = version;
        this.objectType = ObjectType.COMPONENT;
    }

    public ComponentIdentity(final Component component) {
        this.purl = component.getPurl();
        this.purlCoordinates = PurlUtil.silentPurlCoordinatesOnly(purl);
        this.cpe = component.getCpe();
        this.swidTagId = component.getSwidTagId();
        this.group = component.getGroup();
        this.name = component.getName();
        this.version = component.getVersion();
        this.uuid = component.getUuid();
        this.objectType = ObjectType.COMPONENT;
    }

    public ComponentIdentity(final org.cyclonedx.model.Component component) {
        try {
            this.purl = new PackageURL(component.getPurl());
            this.purlCoordinates = PurlUtil.purlCoordinatesOnly(purl);
        } catch (MalformedPackageURLException e) {
            // throw it away
        }
        this.cpe = component.getCpe();
        this.swidTagId = (component.getSwid() != null) ? component.getSwid().getTagId() : null;
        this.group = component.getGroup();
        this.name = component.getName();
        this.version = component.getVersion();
        this.objectType = ObjectType.COMPONENT;
    }

    public ComponentIdentity(final ServiceComponent service) {
        this.group = service.getGroup();
        this.name = service.getName();
        this.version = service.getVersion();
        this.uuid = service.getUuid();
        this.objectType = ObjectType.SERVICE;
    }

    public ComponentIdentity(final org.cyclonedx.model.Service service) {
        this.group = service.getGroup();
        this.name = service.getName();
        this.version = service.getVersion();
        this.objectType = ObjectType.SERVICE;
    }

    public ObjectType getObjectType() {
        return objectType;
    }

    public PackageURL getPurl() {
        return purl;
    }

    public PackageURL getPurlCoordinates() {
        return purlCoordinates;
    }

    public String getCpe() {
        return cpe;
    }

    public String getSwidTagId() {
        return swidTagId;
    }

    public String getGroup() {
        return group;
    }

    public String getName() {
        return name;
    }

    public String getVersion() {
        return version;
    }

    public UUID getUuid() {
        return uuid;
    }

    @Override
    public boolean equals(final Object o) {<FILL_FUNCTION_BODY>}

    @Override
    public int hashCode() {
        return Objects.hash(objectType, purl, purlCoordinates, cpe, swidTagId, group, name, version, uuid);
    }

    public JSONObject toJSON() {
        final JSONObject jsonObject = new JSONObject();
        jsonObject.put("uuid", this.getUuid());
        jsonObject.put("group", this.getGroup());
        jsonObject.put("name", this.getName());
        jsonObject.put("version", this.getVersion());
        jsonObject.put("purl", this.getPurl());
        jsonObject.put("purlCoordinates", this.getPurlCoordinates());
        jsonObject.put("cpe", this.getCpe());
        jsonObject.put("swidTagId", this.getSwidTagId());
        jsonObject.put("objectType", this.getObjectType());
        return jsonObject;
    }
}

        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        final ComponentIdentity that = (ComponentIdentity) o;
        return objectType == that.objectType
                && Objects.equals(purl, that.purl)
                && Objects.equals(purlCoordinates, that.purlCoordinates)
                && Objects.equals(cpe, that.cpe)
                && Objects.equals(swidTagId, that.swidTagId)
                && Objects.equals(group, that.group)
                && Objects.equals(name, that.name)
                && Objects.equals(version, that.version)
                && Objects.equals(uuid, that.uuid);
    
<no_super_class>