001/* 002 * JDrupes Builder 003 * Copyright (C) 2026 Michael N. Lipp 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Affero General Public License as 007 * published by the Free Software Foundation, either version 3 of the 008 * License, or (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Affero General Public License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with this program. If not, see <https://www.gnu.org/licenses/>. 017 */ 018 019package org.jdrupes.builder.ext.checkstyle; 020 021import org.jdrupes.builder.api.FaultAware; 022import org.jdrupes.builder.api.Project; 023import org.jdrupes.builder.api.ResourceProvider; 024import org.jdrupes.builder.core.ResourceObject; 025 026/// A default implementation of [CheckstyleResult]. 027/// 028public class DefaultCheckstyleResult extends ResourceObject 029 implements CheckstyleResult { 030 031 private final Project project; 032 private final ResourceProvider provider; 033 private final long checked; 034 private final long errors; 035 private final long warnings; 036 private boolean isFaulty; 037 038 /// Initializes a new default checkstyle result. 039 /// 040 /// @param project the project 041 /// @param provider the provider 042 /// @param checked the number of checked files 043 /// @param errors the number of style violations with error severity 044 /// @param warnings the number of style violations with warning severity 045 /// 046 @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") 047 protected DefaultCheckstyleResult(Project project, 048 ResourceProvider provider, long checked, long errors, 049 long warnings) { 050 super(CheckstyleTypes.CheckstyleResultType); 051 name("CheckstyleChecker: " + checked + " checked, " + errors 052 + " errors, " + warnings + " warnings"); 053 this.project = project; 054 this.provider = provider; 055 this.checked = checked; 056 this.errors = errors; 057 this.warnings = warnings; 058 } 059 060 @Override 061 public Project project() { 062 return project; 063 } 064 065 @Override 066 public long checked() { 067 return checked; 068 } 069 070 @Override 071 public long errors() { 072 return errors; 073 } 074 075 @Override 076 public long warnings() { 077 return warnings; 078 } 079 080 @Override 081 public boolean isFaulty() { 082 return isFaulty; 083 } 084 085 @Override 086 public FaultAware setFaulty() { 087 isFaulty = true; 088 return this; 089 } 090 091 @Override 092 public String toString() { 093 return CheckstyleResult.class.getSimpleName() + " from " 094 + provider + ": " + checked + " checked, " + errors + " errors, " 095 + warnings + " warnings"; 096 } 097}