putStringIfNotEmpty

Adds a tag with a string value only if the value is not null or empty.

This is a convenience method that validates the string value before adding it to the bundle. If the value is null or empty (zero-length or whitespace-only), the tag is not added. Use this when you want to avoid setting tags with empty or meaningless values.

Example (Form Validation):


		// Safely add optional profile fields from user input
		String phoneNumber = editTextPhone.getText().toString().trim();
		String company = editTextCompany.getText().toString().trim();
		String referralCode = editTextReferral.getText().toString().trim();
		
		new TagsBundle.Builder()
		    .putString("email", email) // Required field, always set
		    .putStringIfNotEmpty("phone", phoneNumber) // Optional, only if provided
		    .putStringIfNotEmpty("company", company) // Optional, only if provided
		    .putStringIfNotEmpty("referral_code", referralCode) // Optional, only if provided
		    .build();
		

Return

this Builder instance for method chaining

Parameters

key

tag name (e.g., "phone", "company", "optional_field")

value

string value to store (will only be added if not null or empty)