// Get the LabelService.
LabelServiceInterface labelService =
dfpServices.get(session, LabelServiceInterface.class);
// Create a competitive exclusion label.
Label competitiveExclusionLabel = new Label();
competitiveExclusionLabel.setName(
"Car company label #" + new Random().nextInt(Integer.MAX_VALUE));
competitiveExclusionLabel.setTypes(new LabelType[] {LabelType.COMPETITIVE_EXCLUSION});
// Create an ad unit frequency cap label.
Label adUnitFrequencyCapLabel = new Label();
adUnitFrequencyCapLabel.setName(
"Don't run too often label #" + new Random().nextInt(Integer.MAX_VALUE));
adUnitFrequencyCapLabel.setTypes(new LabelType[] {LabelType.AD_UNIT_FREQUENCY_CAP});
// Create the labels on the server.
Label[] labels =
labelService.createLabels(new Label[] {competitiveExclusionLabel, adUnitFrequencyCapLabel});