package com.jambotronGroup.jambotron.model;

import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import lombok.ToString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



@Entity
public class Bean {


    private String name;
    @Id
    private String shortName;
    private String type;
    private String typeShortName;
    private String scope;

    public Bean(String name, String type, String scope) {
        this.name = name;
        this.type = type;
        this.scope = scope;

        this.shortName = getAfterLastDot(name);
        this.typeShortName = getAfterLastDot(type);

    }

    @Override
    public String toString() {

        return String.format("name = %s  type= %s", this.shortName, this.typeShortName);
    }

    public String getAfterLastDot(String input) {
        if (input == null || !input.contains(".")) {
            return input; // Return the input if it's null or doesn't contain a dot
        }
        return input.substring(input.lastIndexOf('.') + 1);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }



    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }

    public String getTypeShortName() {
        return typeShortName;
    }

    public void setTypeShortName(String typeShortName) {
        this.typeShortName = typeShortName;
    }
}
