001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nicolas Chapurlat <nchapurlat@nuxeo.com> 016 */ 017 018package org.nuxeo.ecm.core.api.validation; 019 020import java.util.Collections; 021import java.util.List; 022 023/** 024 * A managed set of {@link ConstraintViolation}. 025 * 026 * @since 7.1 027 */ 028public class DocumentValidationReport { 029 030 protected List<ConstraintViolation> violations; 031 032 public DocumentValidationReport(List<ConstraintViolation> violations) { 033 super(); 034 this.violations = violations; 035 } 036 037 public boolean hasError() { 038 return !violations.isEmpty(); 039 } 040 041 public int numberOfErrors() { 042 return violations.size(); 043 } 044 045 public List<ConstraintViolation> asList() { 046 return Collections.unmodifiableList(violations); 047 } 048 049}