org.schmant.task.stub
Class AbstractGeneratorTask<T extends GeneratorTaskSpec<T>>

java.lang.Object
  extended by org.schmant.support.AbstractArgumentChecker
      extended by org.schmant.task.stub.AbstractTask<T>
          extended by org.schmant.task.stub.AbstractGeneratorTask<T>
All Implemented Interfaces:
TaskDependency, LoggingConfigurable<T>, OverwriteConfigurable<T>, TargetConfigurable<T>, TargetConfigured, GeneratorTaskConfigurable<T>, GeneratorTaskSpec<T>, Task, TaskRunnable, TaskSpecification<T>

public abstract class AbstractGeneratorTask<T extends GeneratorTaskSpec<T>>
extends AbstractTask<T>
implements GeneratorTaskSpec<T>

This class may be used as a starting point for generator task implementations.

Since:
0.5
Author:
Karl Gustafsson

Field Summary
 
Fields inherited from interface org.schmant.task.confable.OverwriteConfigurable
DEFAULT_OVERWRITE_STRATEGY
 
Constructor Summary
AbstractGeneratorTask()
           
 
Method Summary
 void copyProperties(T spec)
          Override the method inherited from AbstractTask to copy the target and overwrite strategy properties.
protected  OverwriteStrategy getOverwriteStrategy()
           
 Object getTarget()
          Get the target.
protected  boolean isTargetMandatory()
          Is a target mandatory? This method always returns true.
 T setOverwrite(boolean b)
          Should things be overwritten? If this is set to true, it is equivalent to setting the overwrite strategy to DoOverwriteAndLogWarning.
 T setOverwriteStrategy(OverwriteStrategy strat)
          Set a strategy for how to react to existing entities in locations where the task wants to write.
 T setTarget(Object o)
          Set the target.
protected  Collection<String> validate(Report r)
          Override the method inherited from AbstractTask to give a validation error if the target property is not set (and isTargetMandatory() returns true).
 
Methods inherited from class org.schmant.task.stub.AbstractTask
cancel, createTask, getDefaultLogFooter, getDefaultLogHeader, getDependencyForTasksScheduledByThisTask, getDependencyObservable, getFailureCause, getLogFooter, getLogHeader, getSatisfiedStateLock, getThis, isCancelled, isDone, isInterrupted, isRunning, isSatisfied, isSuccessful, run, runInternal, setLogFooter, setLogHeader, setReportLevel, setTraceLogging, toString
 
Methods inherited from class org.schmant.support.AbstractArgumentChecker
check, check, check, check
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.schmant.task.TaskSpecification
createTask
 
Methods inherited from interface org.schmant.task.confable.LoggingConfigurable
setLogFooter, setLogHeader, setReportLevel, setTraceLogging
 

Constructor Detail

AbstractGeneratorTask

public AbstractGeneratorTask()
Method Detail

setTarget

public final T setTarget(Object o)
Description copied from interface: TargetConfigurable
Set the target.

Specified by:
setTarget in interface TargetConfigurable<T extends GeneratorTaskSpec<T>>
Parameters:
o - The target.
Returns:
this

getTarget

public final Object getTarget()
Description copied from interface: TargetConfigured
Get the target.

Specified by:
getTarget in interface TargetConfigured
Returns:
The target or null if it is not set.

setOverwrite

public final T setOverwrite(boolean b)
Description copied from interface: OverwriteConfigurable
Should things be overwritten? If this is set to true, it is equivalent to setting the overwrite strategy to DoOverwriteAndLogWarning. If this is set to false, it is equivalent to setting the overwrite strategy to DontOverwriteAndLogWarning.

Specified by:
setOverwrite in interface OverwriteConfigurable<T extends GeneratorTaskSpec<T>>
Parameters:
b - Should things be overwritten?
Returns:
this

setOverwriteStrategy

public final T setOverwriteStrategy(OverwriteStrategy strat)
Description copied from interface: OverwriteConfigurable
Set a strategy for how to react to existing entities in locations where the task wants to write.

Specified by:
setOverwriteStrategy in interface OverwriteConfigurable<T extends GeneratorTaskSpec<T>>
Parameters:
strat - The overwrite strategy.
Returns:
this

getOverwriteStrategy

protected final OverwriteStrategy getOverwriteStrategy()

isTargetMandatory

protected boolean isTargetMandatory()
Is a target mandatory? This method always returns true. Subclasses may override this to return false if a target is not mandatory for them.

Returns:
true, always

validate

protected Collection<String> validate(Report r)
Override the method inherited from AbstractTask to give a validation error if the target property is not set (and isTargetMandatory() returns true).

Subclasses may override this to add their own validation.

Overrides:
validate in class AbstractTask<T extends GeneratorTaskSpec<T>>
Parameters:
r - A report to log warning and debug messages to. Validation errors should not be logged, though. They are logged later.
Returns:
A collection of error messages.

copyProperties

public void copyProperties(T spec)
Override the method inherited from AbstractTask to copy the target and overwrite strategy properties.

Subclasses must override this to copy their own properties.

Specified by:
copyProperties in interface TaskSpecification<T extends GeneratorTaskSpec<T>>
Overrides:
copyProperties in class AbstractTask<T extends GeneratorTaskSpec<T>>
Parameters:
spec - The specification to copy properties to.