1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one * 3 * or more contributor license agreements. See the NOTICE file * 4 * distributed with this work for additional information * 5 * regarding copyright ownership. The ASF licenses this file * 6 * to you under the Apache License, Version 2.0 (the * 7 * "License"); you may not use this file except in compliance * 8 * with the License. You may obtain a copy of the License at * 9 * * 10 * http://www.apache.org/licenses/LICENSE-2.0 * 11 * * 12 * Unless required by applicable law or agreed to in writing, * 13 * software distributed under the License is distributed on an * 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * 15 * KIND, either express or implied. See the License for the * 16 * specific language governing permissions and limitations * 17 * under the License. * 18 */ 19 20 package org.apache.rat.report.claim.impl; 21 22 import org.apache.rat.api.Document; 23 import org.apache.rat.api.MetaData; 24 import org.apache.rat.api.RatException; 25 import org.apache.rat.license.ILicense; 26 import org.apache.rat.report.AbstractReport; 27 28 29 /** 30 * Abstract base implementation of {@link AbstractReport}. 31 * It is strongly suggested, that implementations derive from 32 * this class. 33 */ 34 public abstract class AbstractClaimReporter extends AbstractReport { 35 /** 36 * Increment the document type counter. 37 * The default implementations does nothing. 38 * @param type The document type counter to increment. 39 */ 40 protected void handleDocumentCategoryClaim(Document.Type type) { 41 // Does nothing 42 } 43 44 /** 45 * Increment the approved license claim. 46 * The default implementation does nothing. 47 * @param metadata The metadata for the document 48 */ 49 protected void handleApprovedLicenseClaim(MetaData metadata) { 50 // Does nothing 51 } 52 53 /** 54 * Increment the counts associated with the license 55 * The default implementation does nothing. 56 * @param license the license to record the category for. 57 */ 58 protected void handleLicenseClaim(ILicense license) { 59 // Does nothing 60 } 61 62 @Override 63 public void report(Document subject) throws RatException { 64 final MetaData metaData = subject.getMetaData(); 65 metaData.licenses().forEach(this::handleLicenseClaim); 66 handleDocumentCategoryClaim(metaData.getDocumentType()); 67 handleApprovedLicenseClaim(metaData); 68 } 69 }