lundi 2 septembre 2019

How do I use interfaces with "fallback" parameters in the methods?

I am writing some code in java, and am struggling with deciding if this is Ok code since I've never had any real education. I want to force use save(ConfigurationSection) in my classes, but if not available allow for using save(String). I realize I could just do this conversion before I'd call this method. Is that what I am supposed to be doing?

public interface Serializable {

    default void save(String path){
        save(Claims.getDataManager().getData().createSection(path));
    }
    void save(ConfigurationSection section);

}

I'd like to know if I am allowed to do this. Also any good resources that are relatively comprehendable for someone without any real knowledge of jargon.

Aucun commentaire:

Enregistrer un commentaire