class GroupValidator implements EntityValidator<Group> {

    @Override
    public Set<ConstraintViolation<Group>> validate(Group entity) {
        if (entity == null) {
            return null;
        }
        final String id = entity.getName();
        Set<ConstraintViolation<Group>> result = new HashSet<ConstraintViolation<Group>>(1);
        // Validate user name not empty.
        if (id == null || id.trim().length() == 0) {
            final String msg = getMessage(KEY_NAME_NOT_EMPTY);
            result.add(createViolation(entity,
                                       "name",
                                       msg));
        }
        return result;
    }

}