@Internal public class NameUtils extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
NameUtils.NameOverride
Classes may implement this interface to change how names are generated for their instances.
|
Constructor and Description |
---|
NameUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
approximatePTransformName(java.lang.Class<?> clazz)
Returns a name for a PTransform class.
|
static java.lang.String |
approximateSimpleName(java.lang.Object object)
As
approximateSimpleName(Object, String) but returning "Anonymous" when object is an instance of anonymous class. |
static java.lang.String |
approximateSimpleName(java.lang.Object object,
java.lang.String anonymousValue)
Returns a simple name describing a class that is being used as a function (eg., a
DoFn
or Combine.CombineFn , etc.). |
public static java.lang.String approximateSimpleName(java.lang.Object object)
approximateSimpleName(Object, String)
but returning "Anonymous"
when object
is an instance of anonymous class.public static java.lang.String approximateSimpleName(java.lang.Object object, java.lang.String anonymousValue)
DoFn
or Combine.CombineFn
, etc.).
Note: this is non-invertible - the name may be simplified to an extent that it cannot be mapped back to the original class.
This can be used to generate human-readable names. It removes the package and outer classes from the name, and removes common suffixes.
If the object is an instanceof NameUtils.NameOverride
, the result of NameUtils.NameOverride.getNameOverride()
is returned. This allows classes that act as wrappers to
override the handling of names by delegating to the objects they wrap.
If the class is anonymous, the string anonymousValue
is returned.
Examples:
some.package.Word.SummaryDoFn
becomes "Summary"
another.package.PairingFn
becomes "Pairing"
public static java.lang.String approximatePTransformName(java.lang.Class<?> clazz)
This can be used to generate human-readable transform names. It removes the package from the name, and removes common suffixes.
It is different than approximateSimpleName:
Examples:
some.package.Word.Summary
becomes "Word.Summary"
another.package.Pairing.Bound
becomes "Pairing"