Commit 513df158 authored by Marco Descher's avatar Marco Descher

[9918] IContext/Service clearly document setType(null) vs removeTyped

parent 62418ac9
Pipeline #12388 passed with stages
in 4 minutes and 51 seconds
......@@ -72,6 +72,8 @@ public class Context implements IContext {
}
}
updateElexisEventDispatcher(object);
} else {
throw new IllegalArgumentException("object must not be null, use #removeTyped");
}
}
......
......@@ -29,7 +29,7 @@ public interface IContext {
/**
* Set an {@link Object} identified by its type in the context.
*
* @param object
* @param object must not be <code>null</code>
*/
public void setTyped(Object object);
......
......@@ -30,10 +30,15 @@ public interface IContextService {
/**
* Set the active {@link IUser} of the root context.
*
* @return
*/
default public void setActiveUser(IUser object){
getRootContext().setTyped(object);
* @param user
* or <code>null</code> to unset
*/
default public void setActiveUser(IUser user){
if (user != null) {
getRootContext().setTyped(user);
} else {
getRootContext().removeTyped(IUser.class);
}
}
/**
......@@ -58,10 +63,15 @@ public interface IContextService {
/**
* Set the active {@link IPatient} of the root context.
*
* @return
* @param patient
* or <code>null</code> to unset
*/
default public void setActivePatient(IPatient object){
getRootContext().setTyped(object);
default public void setActivePatient(IPatient patient){
if (patient != null) {
getRootContext().setTyped(patient);
} else {
getRootContext().removeTyped(IPatient.class);
}
}
/**
......@@ -76,10 +86,15 @@ public interface IContextService {
/**
* Set the active {@link IMandator} of the root context.
*
* @return
* @param mandator
* or <code>null</code> to unset
*/
default public void setActiveMandator(IMandator object){
getRootContext().setTyped(object);
default public void setActiveMandator(IMandator mandator){
if (mandator != null) {
getRootContext().setTyped(mandator);
} else {
getRootContext().removeTyped(IMandator.class);
}
}
/**
......@@ -94,18 +109,24 @@ public interface IContextService {
/**
* Set the active {@link ICoverage} of the root context.
*
* @return
* @param coverage
* or <code>null</code> to unset
*/
default public void setActiveCoverage(ICoverage object){
getRootContext().setTyped(object);
default public void setActiveCoverage(ICoverage coverage){
if (coverage != null) {
getRootContext().setTyped(coverage);
} else {
getRootContext().removeTyped(ICoverage.class);
}
}
/**
* Get the station identifier.
* Get the station identifier.
*
* @return
* @see IContext#getStationIdentifier()
*/
default public String getStationIdentifier() {
default public String getStationIdentifier(){
return getRootContext().getStationIdentifier();
}
......@@ -115,7 +136,7 @@ public interface IContextService {
* @param clazz
* @return
*/
default public <T> Optional<T> getTyped(Class<T> clazz) {
default public <T> Optional<T> getTyped(Class<T> clazz){
return getRootContext().getTyped(clazz);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment