Package io.opencensus.trace
Class AttributeValue
- java.lang.Object
-
- io.opencensus.trace.AttributeValue
-
- Direct Known Subclasses:
AttributeValue.AttributeValueBoolean
,AttributeValue.AttributeValueDouble
,AttributeValue.AttributeValueLong
,AttributeValue.AttributeValueString
@Immutable public abstract class AttributeValue extends java.lang.Object
A class that represents all the possible values for an attribute. An attribute can have 3 types of values:String
,Boolean
orLong
.- Since:
- 0.5
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
AttributeValue.AttributeValueBoolean
(package private) static class
AttributeValue.AttributeValueDouble
(package private) static class
AttributeValue.AttributeValueLong
(package private) static class
AttributeValue.AttributeValueString
-
Constructor Summary
Constructors Constructor Description AttributeValue()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static AttributeValue
booleanAttributeValue(boolean booleanValue)
Returns anAttributeValue
with a boolean value.static AttributeValue
doubleAttributeValue(double doubleValue)
Returns anAttributeValue
with a double value.static AttributeValue
longAttributeValue(long longValue)
Returns anAttributeValue
with a long value.abstract <T> T
match(Function<? super java.lang.String,T> stringFunction, Function<? super java.lang.Boolean,T> booleanFunction, Function<? super java.lang.Long,T> longFunction, Function<? super java.lang.Double,T> doubleFunction, Function<java.lang.Object,T> defaultFunction)
Applies a function to the underlying value.abstract <T> T
match(Function<? super java.lang.String,T> stringFunction, Function<? super java.lang.Boolean,T> booleanFunction, Function<? super java.lang.Long,T> longFunction, Function<java.lang.Object,T> defaultFunction)
Deprecated.static AttributeValue
stringAttributeValue(java.lang.String stringValue)
Returns anAttributeValue
with a string value.
-
-
-
Method Detail
-
stringAttributeValue
public static AttributeValue stringAttributeValue(java.lang.String stringValue)
Returns anAttributeValue
with a string value.- Parameters:
stringValue
- The new value.- Returns:
- an
AttributeValue
with a string value. - Throws:
java.lang.NullPointerException
- ifstringValue
isnull
.- Since:
- 0.5
-
booleanAttributeValue
public static AttributeValue booleanAttributeValue(boolean booleanValue)
Returns anAttributeValue
with a boolean value.- Parameters:
booleanValue
- The new value.- Returns:
- an
AttributeValue
with a boolean value. - Since:
- 0.5
-
longAttributeValue
public static AttributeValue longAttributeValue(long longValue)
Returns anAttributeValue
with a long value.- Parameters:
longValue
- The new value.- Returns:
- an
AttributeValue
with a long value. - Since:
- 0.5
-
doubleAttributeValue
public static AttributeValue doubleAttributeValue(double doubleValue)
Returns anAttributeValue
with a double value.- Parameters:
doubleValue
- The new value.- Returns:
- an
AttributeValue
with a double value. - Since:
- 0.17
-
match
@Deprecated public abstract <T> T match(Function<? super java.lang.String,T> stringFunction, Function<? super java.lang.Boolean,T> booleanFunction, Function<? super java.lang.Long,T> longFunction, Function<java.lang.Object,T> defaultFunction)
Deprecated.Applies a function to the underlying value. The function that is called depends on the value's type, which can beString
,Long
, orBoolean
.- Parameters:
stringFunction
- the function that should be applied if the value has typeString
.longFunction
- the function that should be applied if the value has typeLong
.booleanFunction
- the function that should be applied if the value has typeBoolean
.defaultFunction
- the function that should be applied if the value has a type that was added after thismatch
method was added to the API. SeeFunctions
for some common functions for handling unknown types.- Returns:
- the result of the function applied to the underlying value.
- Since:
- 0.5
-
match
public abstract <T> T match(Function<? super java.lang.String,T> stringFunction, Function<? super java.lang.Boolean,T> booleanFunction, Function<? super java.lang.Long,T> longFunction, Function<? super java.lang.Double,T> doubleFunction, Function<java.lang.Object,T> defaultFunction)
Applies a function to the underlying value. The function that is called depends on the value's type, which can beString
,Long
, orBoolean
.- Parameters:
stringFunction
- the function that should be applied if the value has typeString
.longFunction
- the function that should be applied if the value has typeLong
.booleanFunction
- the function that should be applied if the value has typeBoolean
.doubleFunction
- the function that should be applied if the value has typeDouble
.defaultFunction
- the function that should be applied if the value has a type that was added after thismatch
method was added to the API. SeeFunctions
for some common functions for handling unknown types.- Returns:
- the result of the function applied to the underlying value.
- Since:
- 0.17
-
-