title: Call certain method based of condition
body: <p>I recently wrote this piece of code:</p>
  
  <pre><code>  public Object getProperty(String key) {
      if (this.plugin.getConfig().isBoolean(key)) {
        return this.plugin.getConfig().getBoolean(key);
      } else if (this.plugin.getConfig().isColor(key)) {
        return this.plugin.getConfig().getColor(key);
      } else if (this.plugin.getConfig().isConfigurationSection(key)) {
        return this.plugin.getConfig().getConfigurationSection(key);
      } else if (this.plugin.getConfig().isDouble(key)) {
        return this.plugin.getConfig().getDouble(key);
      } else if (this.plugin.getConfig().isInt(key)) {
        return this.plugin.getConfig().getInt(key);
      } else if (this.plugin.getConfig().isItemStack(key)) {
        return this.plugin.getConfig().getItemStack(key);
      } else if (this.plugin.getConfig().isList(key)) {
        return this.plugin.getConfig().getList(key);
      } else if (this.plugin.getConfig().isLong(key)) {
        return this.plugin.getConfig().getLong(key);
      } else if (this.plugin.getConfig().isOfflinePlayer(key)) {
        return this.plugin.getConfig().getOfflinePlayer(key);
      } else if (this.plugin.getConfig().isPrimitiveWrapper(key)) {
        return this.plugin.getConfig().getPrimitiveWrapper(key);
      } else if (this.plugin.getConfig().isSet(key)) {
        return this.plugin.getConfig().getSet(key);
      } else if (this.plugin.getConfig().isString(key)) {
        return this.plugin.getConfig().getString(key);
      } else if (this.plugin.getConfig().isVector(key)) {
        return this.plugin.getConfig().getVector(key);
      }
    }
  </code></pre>
  
  <p>As you can see, it is super repetitive and very ugly.</p>
  
  <p>Is there a better way it can be written?</p>
  
  <hr>
  
  <p><code>plugin.getConfig()</code> returns <a href="https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/file/FileConfiguration.html" rel="nofollow noreferrer">one of these</a>. I want to make a method that, when given a path (<code>key</code>) which points at some value in a YAML file, I can return that value no matter what its type is.</p>