if (!(rawCreative instanceof InStreamVideoCreative)) {
System.out.printf("Unable to update creative with ID \"%s\": not an In-Stream video "
+ "creative.", creativeId);
} else {
InStreamVideoCreative inStreamVideoCreative = (InStreamVideoCreative) rawCreative;
// Modify the media files, companion ads, and/or non-linear ads.
if (inStreamVideoCreative.getMediaFiles() != null) {
for (InStreamMediaFile mediaFile : inStreamVideoCreative.getMediaFiles()) {
mediaFile.setPickedToServe(!mediaFile.isPickedToServe());
}
}
if (inStreamVideoCreative.getCompanionAds() != null) {
for (InStreamCompanionAd companionAd : inStreamVideoCreative.getCompanionAds()) {
companionAd.setAltText(companionAd.getAltText() + " Updated.");
}
}
if (inStreamVideoCreative.getNonLinearAds() != null) {
for (InStreamNonLinearAd nonLinearAd : inStreamVideoCreative.getNonLinearAds()) {
nonLinearAd.setScalable(!nonLinearAd.isScalable());
}
}
CreativeSaveResult creativeSaveResult =