All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.vpro.validation.HasTitleValidator Maven / Gradle / Ivy

Go to download

The basic domain classes for 'media', the core of POMS. Also, the 'update' XML bindings for it. It also contains some closely related domain classes like the enum to contain NICAM kijkwijzer settings.

There is a newer version: 8.3.1
Show newest version
/*
 * Copyright (C) 2011 Licensed under the Apache License, Version 2.0
 * VPRO The Netherlands
 */
package nl.vpro.validation;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

import org.apache.commons.lang3.StringUtils;

import nl.vpro.domain.TextualObjectUpdate;
import nl.vpro.domain.TextualObjects;

/**
 * @since 7.7
 * @see HasTitle
 */
public class HasTitleValidator implements ConstraintValidator> {


    HasTitle annotation;

	@Override
    public void initialize(HasTitle constraintAnnotation) {
        this.annotation = constraintAnnotation;
	}


    @Override
    public boolean isValid(TextualObjectUpdate value, ConstraintValidatorContext context) {
        if (value == null) {
            return true;
        }

        return !StringUtils.isEmpty(TextualObjects.get(value.getTitles(), annotation.type()));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy