Package uk.ac.starlink.ttools.plot2
Class ReportKey<T>
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.ReportKey<T>
-
public abstract class ReportKey<T> extends java.lang.Object
Typed key for use in a ReportMap. Instances of this class identify an item of data generated when plotting a layer. They are classed as "general interest" or not. General interest keys represent data that clients could consider passing on to a human user, while non-general-interest ones are generally intended for consumption by parts of the implementation that understand the details of particular report types.- Since:
- 9 Dec 2014
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description ReportKey(ReportMeta meta, java.lang.Class<T> clazz, boolean isGeneralInterest)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ReportKey<java.lang.Double>
createDoubleKey(ReportMeta meta, boolean isGeneralInterest)
Constructs a double-precision-valued key.static ReportKey<java.lang.Integer>
createIntegerKey(ReportMeta meta, boolean isGeneralInterest)
Constructs an integer-valued key.static <T> ReportKey<T>
createObjectKey(ReportMeta meta, java.lang.Class<T> clazz, boolean isGeneralInterest)
Constructs a typed key with default stringification.static ReportKey<java.lang.String>
createStringKey(ReportMeta meta, boolean isGeneralInterest)
Constructs a string-valued key.static ReportKey<uk.ac.starlink.table.StarTable>
createTableKey(ReportMeta meta, boolean isGeneralInterest)
Constructs a StarTable-valued key.static <T> ReportKey<T>
createUnprintableKey(ReportMeta meta, java.lang.Class<T> clazz)
Constructs a non-general-interest key with no useful text serialization.ReportMeta
getMeta()
Returns this key's metadata.java.lang.Class<T>
getValueClass()
Returns the type of object identified by this key.boolean
isGeneralInterest()
Indicates whether this key represents a key of general interest.abstract java.lang.String
toText(T value)
Serializes a value associated with this key in a way that can be presented to a human user.
-
-
-
Constructor Detail
-
ReportKey
public ReportKey(ReportMeta meta, java.lang.Class<T> clazz, boolean isGeneralInterest)
Constructor.- Parameters:
meta
- metadata describing this keyclazz
- type of data item described by this keyisGeneralInterest
- indicates whether this key represents a general purpose report
-
-
Method Detail
-
getMeta
public ReportMeta getMeta()
Returns this key's metadata.- Returns:
- descriptive metadata
-
getValueClass
public java.lang.Class<T> getValueClass()
Returns the type of object identified by this key.- Returns:
- value class
-
isGeneralInterest
public boolean isGeneralInterest()
Indicates whether this key represents a key of general interest. General interest reports can/should be presented to the user by a general purpose UI as plot feedback and the corresponding values should have a sensible toString implemenatation. If the return value is false, the corresponding report is only intended for plotter-specific code that understands what it's getting.- Returns:
- true if general purpose code should present report items to the user in their stringified form
-
toText
public abstract java.lang.String toText(T value)
Serializes a value associated with this key in a way that can be presented to a human user.- Parameters:
value
- value for this key- Returns:
- short text representation
-
createStringKey
public static ReportKey<java.lang.String> createStringKey(ReportMeta meta, boolean isGeneralInterest)
Constructs a string-valued key.- Parameters:
meta
- metadata describing the keyisGeneralInterest
- indicates whether the key represents a general purpose report- Returns:
- new key
-
createDoubleKey
public static ReportKey<java.lang.Double> createDoubleKey(ReportMeta meta, boolean isGeneralInterest)
Constructs a double-precision-valued key.- Parameters:
meta
- metadata describing the keyisGeneralInterest
- indicates whether the key represents a general purpose report- Returns:
- new key
-
createIntegerKey
public static ReportKey<java.lang.Integer> createIntegerKey(ReportMeta meta, boolean isGeneralInterest)
Constructs an integer-valued key.- Parameters:
meta
- metadata describing the keyisGeneralInterest
- indicates whether the key represents a general purpose report- Returns:
- new key
-
createObjectKey
public static <T> ReportKey<T> createObjectKey(ReportMeta meta, java.lang.Class<T> clazz, boolean isGeneralInterest)
Constructs a typed key with default stringification.- Parameters:
meta
- metadata describing this keyclazz
- type of data item described by this keyisGeneralInterest
- indicates whether this key represents a general purpose report- Returns:
- new report key
-
createTableKey
public static ReportKey<uk.ac.starlink.table.StarTable> createTableKey(ReportMeta meta, boolean isGeneralInterest)
Constructs a StarTable-valued key.- Parameters:
meta
- metadata describing the keyisGeneralInterest
- indicates whether the key represents a general purpose report- Returns:
- new key
-
createUnprintableKey
public static <T> ReportKey<T> createUnprintableKey(ReportMeta meta, java.lang.Class<T> clazz)
Constructs a non-general-interest key with no useful text serialization.- Parameters:
meta
- metadata describing the keyclazz
- type of data item described by this key- Returns:
- new key
-
-