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.pmd; 020 021import org.jdrupes.builder.api.Project; 022import org.jdrupes.builder.api.ResourceProvider; 023import org.jdrupes.builder.core.ResourceObject; 024 025/// A default implementation of [PmdResult]. 026/// 027public class DefaultPmdResult extends ResourceObject 028 implements PmdResult { 029 030 private final Project project; 031 private final ResourceProvider provider; 032 private final long checked; 033 private final long violations; 034 035 /// Initializes a new default PMD result. 036 /// 037 /// @param project the project 038 /// @param provider the provider 039 /// @param checked the number of checked files 040 /// @param violations the number of rule violations 041 /// 042 @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") 043 protected DefaultPmdResult(Project project, ResourceProvider provider, 044 long checked, long violations) { 045 super(PmdTypes.PmdResultType); 046 name("PmdChecker: " + checked + " checked, " 047 + violations + " violations"); 048 this.project = project; 049 this.provider = provider; 050 this.checked = checked; 051 this.violations = violations; 052 } 053 054 @Override 055 public Project project() { 056 return project; 057 } 058 059 @Override 060 public long checked() { 061 return checked; 062 } 063 064 @Override 065 public long violations() { 066 return violations; 067 } 068 069 @Override 070 public String toString() { 071 return PmdResult.class.getSimpleName() + " from " 072 + provider + ": " + checked + " checked, " 073 + violations + " violations"; 074 } 075}