Class ResultFlavor
- java.lang.Object
-
- com.inet.taskplanner.server.api.result.ResultFlavor
-
@JsonData public final class ResultFlavor extends java.lang.Object
AResultFlavor
is an enum-like class representing the 'type' of data aResult
contains.With
resultflavors
differentresults
can be matched to multipleResultActions
. AResultAction
defines which Flavors it supports.New types of Flavors can be added with
create(String)
.You can use '==' to check for equality because there cannot be more than one Flavor object with the same key.
- Since:
- taskplanner 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ResultFlavor.FlavorLabel
Functional Interface for the internationalization of the ResultFlavor.
-
Field Summary
Fields Modifier and Type Field Description static ResultFlavor
FILE
This flavor is used for any binary data with a known size.static ResultFlavor
NONE
This flavor can be used to trigger aResultAction
without passing any content data.static ResultFlavor
PRINT
This flavor is used for printable results.static ResultFlavor
TEXT
This flavor is used for textual data that is usually human readable.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ResultFlavor
create(java.lang.String key)
Creates, registers and returns a newResultFlavor
type.static ResultFlavor
create(java.lang.String key, ResultFlavor.FlavorLabel labelFunction)
Creates, registers and returns a newResultFlavor
type.java.lang.String
getKey()
Returns the key of this ResultFlavorjava.lang.String
getLabel()
Returns the localized label of this flavorjava.lang.String
toString()
static ResultFlavor
valueOf(java.lang.String key)
Get the Flavor for the given key name.static java.util.Collection<ResultFlavor>
values()
Get all registered ResultFlavors.
-
-
-
Field Detail
-
NONE
public static final ResultFlavor NONE
This flavor can be used to trigger aResultAction
without passing any content data. It's for instance accepted by the e-mail action to send an e-mail even in case the job produced no result content to attach to the e-mail. Or in other words, if aResultAction
supports this flavor then it is executed even if noresults
at all or no matching results are available.There are no constraints to a
Result
supporting this flavor, but this makes no sense.
-
FILE
public static final ResultFlavor FILE
This flavor is used for any binary data with a known size. In case a result supports this flavor it MUST implementFileResult
. Results of this type can for instance be stored to disk or attached to an e-mail
-
TEXT
public static final ResultFlavor TEXT
This flavor is used for textual data that is usually human readable. In case a result supports this flavor it MUST implementTextResult
. Results of this type can be presented to a reader e.g. in the content of an e-mail.
-
PRINT
public static final ResultFlavor PRINT
This flavor is used for printable results. In case a result supports this flavor it MUST implementPrintResult
.
-
-
Method Detail
-
create
public static ResultFlavor create(@Nonnull java.lang.String key, ResultFlavor.FlavorLabel labelFunction)
Creates, registers and returns a newResultFlavor
type.Typically used as a constant:
public static final ResultFlavor TABLE = create( "TABLE" ); //table data flavor
Note that you can use "==" for equality checks because there cannot be more than one Flavor object with the same key.
- Parameters:
key
- the key of this type, must be uniquelabelFunction
- optional function to provide a internationalized label for the flavor.- Returns:
- the new created flavor
- Throws:
java.lang.IllegalArgumentException
- if the given key is null or a Flavor with this key exists already- Since:
- taskplanner 3.0
-
create
public static ResultFlavor create(@Nonnull java.lang.String key)
Creates, registers and returns a newResultFlavor
type.Typically used as a constant:
public static final ResultFlavor TABLE = create( "TABLE" ); //table data flavor
Note that you can use "==" for equality checks because there cannot be more than one Flavor object with the same key.
- Parameters:
key
- the key of this type, must be unique- Returns:
- the new created flavor
- Throws:
java.lang.IllegalArgumentException
- if the given key is null or a Flavor with this key exists already- Since:
- taskplanner 3.0
-
getKey
@Nonnull public java.lang.String getKey()
Returns the key of this ResultFlavor- Returns:
- the key of this flavor
-
valueOf
public static ResultFlavor valueOf(java.lang.String key)
Get the Flavor for the given key name. This is equivalent to an enum's valueOf() method.- Parameters:
key
- the key of the desired Flavor- Returns:
- the
ResultFlavor
- Throws:
java.lang.IllegalArgumentException
- if there is no flavor for the given key- Since:
- taskplanner 3.0
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getLabel
public java.lang.String getLabel()
Returns the localized label of this flavor- Returns:
- the label of this flavor for the current language
- Since:
- taskplanner 3.0
-
values
public static java.util.Collection<ResultFlavor> values()
Get all registered ResultFlavors. This is equivalent to an enum's values() method but with collection because array is ugly.- Returns:
- List with currently registered
ResultFlavor
s. Later registered Flavors are not reflected in the returned list. - Since:
- taskplanner 3.0
-
-