de.SweetCode.SteamAPI.interfaces.SteamInterface Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SteamAPI Show documentation
Show all versions of SteamAPI Show documentation
SteamAPI is a wrapper of the Steam Web API.
package de.SweetCode.SteamAPI.interfaces;
import de.SweetCode.SteamAPI.SteamAPI;
import de.SweetCode.SteamAPI.method.SteamMethod;
import java.util.HashMap;
import java.util.Map;
/**
*
* The steam API is divided into interfaces, methods and versions. - This class represents the
* abstract idea of the Steam Interface.
*
*/
public abstract class SteamInterface {
private final SteamAPI steam;
private final String name;
private final Map, SteamMethod> steamMethods = new HashMap<>();
/**
*
* A constructor to create a SteamInterface.
*
*
* @param steam The instance of the Steam API the interface belongs to.
* @param name The name of the interface which can be directly used in URLs to access the API.
*/
public SteamInterface(SteamAPI steam, String name) {
//@TODO Verify input
assert !(steam == null);
assert !(name == null);
this.steam = steam;
this.name = name;
}
/**
*
* Gives the name of the interface which can be directly used in URLs to access the API.
*
*
* @return Always string, never null.
*/
public String getName() {
return this.name;
}
/**
*
* Gives the Steam API instance this interface belongs to.
*
*
* @return The Steam API instance, never null.
*/
public SteamAPI getSteam() {
return this.steam;
}
/**
*
* Gives a list of all related {@link SteamMethod methods.}
*
*
* @return A list of all supported methods. Is never null. Can be empty.
*/
public Map, SteamMethod> getMethods() {
return this.steamMethods;
}
/**
*
* Gives a method according to the provided class IF the method belongs to this interface.
*
*
* @param method The method to search for.
* @param the Steam Method type
*
* @return The SteamMethod instance.
*/
public T get(Class method) {
//TODO Verify input
assert !(method == null);
assert this.steamMethods.containsKey(method);
return (T) this.steamMethods.get(method);
}
/**
*
* Adds a method to the interface.
*
*
* @param method The method to add.
*/
public void add(SteamMethod method) {
//@TODO Verify input
assert !(method == null);
assert !(this.steamMethods.containsKey(method.getClass()));
this.steamMethods.put(method.getClass(), method);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy