
cocaine.ServiceApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cocaine-core Show documentation
Show all versions of cocaine-core Show documentation
Core classes for Cocaine Application Engine.
package cocaine;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap;
/**
* @author Anton Bobukh
*/
public class ServiceApi {
private final String name;
private final ImmutableMap api;
public ServiceApi(String name, ImmutableMap api) {
this.name = name;
this.api = api;
}
public static ServiceApi of(String name, String method, int id) {
return new ServiceApi(name, ImmutableMap.of(method, id));
}
public static ServiceApi of(String name, ImmutableMap methods) {
return new ServiceApi(name, methods);
}
public int getMethod(String method) {
Integer number = api.get(method);
if (number == null) {
throw new UnknownMethodException(name, method);
}
return number;
}
@Override
public String toString() {
return "Service: " + name + "; Service API: { "
+ Joiner.on(", ").withKeyValueSeparator(": ").join(api) + " }";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy