@javax.annotation.Nullable private static AttributeValue toAttributeValueProto( io.opencensus.trace.AttributeValue attributeValue) { return attributeValue.match( stringAttributeValueFunction, booleanAttributeValueFunction, longAttributeValueFunction, doubleAttributeValueFunction, Functions.</*@Nullable*/ AttributeValue>returnNull()); }
@javax.annotation.Nullable private static String attributeValueToString(AttributeValue attributeValue) { return attributeValue.match( returnToString, returnToString, returnToString, returnToString, Functions.</*@Nullable*/ String>returnNull()); }
@javax.annotation.Nullable private static String attributeValueToString(AttributeValue attributeValue) { return attributeValue.match( returnToString, returnToString, returnToString, returnToString, Functions.</*@Nullable*/ String>returnNull()); }
@javax.annotation.Nullable private static AttributeValue toAttributeValueProto( io.opencensus.trace.AttributeValue attributeValue) { return attributeValue.match( stringAttributeValueFunction, booleanAttributeValueFunction, longAttributeValueFunction, doubleAttributeValueFunction, Functions.</*@Nullable*/ AttributeValue>returnNull()); }
@SuppressWarnings("nullness") private static String attributeValueToString(AttributeValue attributeValue) { return attributeValue.match( returnToString, returnToString, returnToString, returnToString, Functions.<String>returnConstant("")); }
@javax.annotation.Nullable private static AttributeValue toAttributeValueProto( io.opencensus.trace.AttributeValue attributeValue) { return attributeValue.match( stringAttributeValueFunction, booleanAttributeValueFunction, longAttributeValueFunction, doubleAttributeValueFunction, Functions.</*@Nullable*/ AttributeValue>returnNull()); }
private static List<Tag> attributesToTags( final Map<String, AttributeValue> attributes, @Nullable final Tag extraTag) { final List<Tag> tags = Lists.newArrayListWithExpectedSize(attributes.size() + 1); for (final Map.Entry<String, AttributeValue> entry : attributes.entrySet()) { final Tag tag = entry .getValue() .match( stringAttributeConverter, booleanAttributeConverter, longAttributeConverter, doubleAttributeConverter, defaultAttributeConverter); tag.setKey(entry.getKey()); tags.add(tag); } if (extraTag != null) { tags.add(extraTag); } return tags; }
private static String attributeValueToString(AttributeValue attributeValue) { return attributeValue.match( Functions.returnToString(), Functions.returnToString(), Functions.returnToString(), Functions.returnToString(), Functions.throwIllegalArgumentException()); }
@Test public void doubleAttributeValue_DeprecatedMatchFunction() { AttributeValue attribute = AttributeValue.doubleAttributeValue(1.23456); attribute.match( new Function<String, Object>() { @Override
@Test public void longAttributeValue() { AttributeValue attribute = AttributeValue.longAttributeValue(123456L); attribute.match( new Function<String, Object>() { @Override @Nullable public Object apply(String stringValue) { fail("Expected a Long"); return null; } }, new Function<Boolean, Object>() { @Override @Nullable public Object apply(Boolean booleanValue) { fail("Expected a Long"); return null; } }, new Function<Long, Object>() { @Override @Nullable public Object apply(Long longValue) { assertThat(longValue).isEqualTo(123456L); return null; } }, Functions.throwIllegalArgumentException()); }
@Test public void stringAttributeValue() { AttributeValue attribute = AttributeValue.stringAttributeValue("MyStringAttributeValue"); attribute.match( new Function<String, Object>() { @Override @Nullable public Object apply(String stringValue) { assertThat(stringValue).isEqualTo("MyStringAttributeValue"); return null; } }, new Function<Boolean, Object>() { @Override @Nullable public Object apply(Boolean booleanValue) { fail("Expected a String"); return null; } }, new Function<Long, Object>() { @Override @Nullable public Object apply(Long longValue) { fail("Expected a String"); return null; } }, Functions.throwIllegalArgumentException()); }
@Test public void booleanAttributeValue() { AttributeValue attribute = AttributeValue.booleanAttributeValue(true); attribute.match( new Function<String, Object>() { @Override @Nullable public Object apply(String stringValue) { fail("Expected a Boolean"); return null; } }, new Function<Boolean, Object>() { @Override @Nullable public Object apply(Boolean booleanValue) { assertThat(booleanValue).isTrue(); return null; } }, new Function<Long, Object>() { @Override @Nullable public Object apply(Long longValue) { fail("Expected a Boolean"); return null; } }, Functions.throwIllegalArgumentException()); }
@Test public void doubleAttributeValue() { AttributeValue attribute = AttributeValue.doubleAttributeValue(1.23456); attribute.match( new Function<String, Object>() { @Override