001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package dev.metaschema.oscal.lib.profile.resolver.support; 007 008import dev.metaschema.core.metapath.item.node.IAssemblyNodeItem; 009import edu.umd.cs.findbugs.annotations.NonNull; 010 011/** 012 * Used to visit a catalog containing groups and controls. 013 * 014 * @param <T> 015 * the type of the context object used to pass calling context 016 * information 017 * @param <R> 018 * the type of the result for visiting a collection of groups and/or 019 * controls 020 */ 021public interface ICatalogVisitor<T, R> { 022 023 /** 024 * Called when visiting a group. 025 * <p> 026 * Can be overridden by classes extending this interface to support processing 027 * of the visited object. 028 * 029 * @param group 030 * the Metapath item for the group 031 * @param childResult 032 * the result of evaluating the group's children 033 * @param state 034 * the calling context information 035 * @return a meaningful result of the given type 036 */ 037 default R visitGroup(@NonNull IAssemblyNodeItem group, R childResult, T state) { 038 // do nothing by default 039 return childResult; 040 } 041 042 /** 043 * Called when visiting a control. 044 * <p> 045 * Can be overridden by classes extending this interface to support processing 046 * of the visited object. 047 * 048 * @param control 049 * the Metapath item for the control 050 * @param childResult 051 * the result of evaluating the control's children 052 * @param state 053 * the calling context information 054 * @return a meaningful result of the given type 055 */ 056 default R visitControl(@NonNull IAssemblyNodeItem control, R childResult, T state) { 057 // do nothing by default 058 return childResult; 059 } 060}