package org.jibeframework.core.app.bootstrap;
import org.jibeframework.core.Context;
import org.jibeframework.core.annotation.ConditionFunction;
import org.jibeframework.core.service.CoreServices;
import org.jibeframework.core.service.MethodService;
/**
* Data object holding all data and behaviour about application which is
* bootstraped to application selector
*
* @author dhalupa
*
*/
public class BootstrapedApplication implements Comparable<BootstrapedApplication> {
private String key, definition;
private int order = 0;
public void setOrder(int order) {
this.order = order;
}
public void setKey(String key) {
this.key = key;
}
public void setDefinition(String definition) {
this.definition = definition;
}
/**
* Get the key which uniquely identifies application
*
* @return
*/
public final String getKey() {
return key;
}
/**
* Returns id of application viewport definition
*
* @return
*/
public final String getDefinition() {
return this.definition;
}
public String getName() {
return CoreServices.getMessage(String.format("jibe.app.%1$s", key));
}
/**
* Return wheather this application should be shown
*
* @return
*/
public final boolean applies() {
MethodService methodService = CoreServices.getMethodService();
if (methodService.annotatedMethodExists(ConditionFunction.class, this.key)) {
return (Boolean) methodService.invoke(ConditionFunction.class, this.key, null, Context
.getCurrentContext());
}
return true;
}
/*
* (non-Javadoc)
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public int compareTo(BootstrapedApplication o) {
return this.order - o.order;
}
}