Class NameUtils
- java.lang.Object
-
- org.apache.beam.sdk.util.NameUtils
-
@Internal public class NameUtils extends java.lang.Object
Helpers for extracting the name of objects and classes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
NameUtils.NameOverride
Classes may implement this interface to change how names are generated for their instances.
-
Constructor Summary
Constructors Constructor Description NameUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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)
AsapproximateSimpleName(Object, String)
but returning"Anonymous"
whenobject
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., aDoFn
orCombine.CombineFn
, etc.).
-
-
-
Method Detail
-
approximateSimpleName
public static java.lang.String approximateSimpleName(java.lang.Object object)
AsapproximateSimpleName(Object, String)
but returning"Anonymous"
whenobject
is an instance of anonymous class.
-
approximateSimpleName
public 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., aDoFn
orCombine.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 ofNameUtils.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"
-
approximatePTransformName
public static java.lang.String approximatePTransformName(java.lang.Class<?> clazz)
Returns a name for a PTransform class.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:
- 1. It keeps the outer classes names.
- 2. It removes the common transform inner class: "Bound".
- 3. For classes generated by AutoValue, whose names start with AutoValue_, it delegates to the (parent) class declared in the user's source code.
Examples:
some.package.Word.Summary
becomes "Word.Summary"another.package.Pairing.Bound
becomes "Pairing"
-
-