2016-09-22 11:31:05 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package org.gcube.vremanagement.executor.pluginmanager;
|
|
|
|
|
|
|
|
import org.gcube.vremanagement.executor.exception.InvalidPluginStateEvolutionException;
|
|
|
|
import org.gcube.vremanagement.executor.plugin.PercentageSetter;
|
|
|
|
import org.gcube.vremanagement.executor.plugin.Plugin;
|
|
|
|
|
|
|
|
/**
|
2017-02-01 17:01:15 +01:00
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
2016-09-22 11:31:05 +02:00
|
|
|
*
|
|
|
|
*/
|
2020-09-30 11:19:49 +02:00
|
|
|
public class PercentageSetterImpl<T extends Plugin> implements PercentageSetter {
|
2016-09-22 11:31:05 +02:00
|
|
|
|
|
|
|
private final RunnablePlugin<T> runnablePlugin;
|
|
|
|
|
|
|
|
public PercentageSetterImpl(RunnablePlugin<T> runnablePlugin){
|
|
|
|
this.runnablePlugin = runnablePlugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPercentageEvolution(Integer percentage){
|
|
|
|
try {
|
|
|
|
if(percentage<0 || percentage>100){
|
|
|
|
throw new InvalidPluginStateEvolutionException("Percentage must be beetween 0 and 100");
|
|
|
|
}
|
|
|
|
this.runnablePlugin.setPercentage(percentage);
|
|
|
|
} catch(Exception e){
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|