001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package gov.nist.secauto.oscal.lib.profile.resolver.support; 007 008import gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem; 009import gov.nist.secauto.metaschema.core.metapath.item.node.IRootAssemblyNodeItem; 010import gov.nist.secauto.metaschema.core.util.ObjectUtils; 011 012import java.util.EnumSet; 013import java.util.Set; 014 015import edu.umd.cs.findbugs.annotations.NonNull; 016 017public abstract class AbstractIndexingVisitor<T, R> 018 extends AbstractCatalogEntityVisitor<T, R> { 019 020 public AbstractIndexingVisitor() { 021 this(ObjectUtils.notNull(EnumSet.allOf(IEntityItem.ItemType.class))); 022 } 023 024 public AbstractIndexingVisitor(@NonNull Set<IEntityItem.ItemType> itemTypesToIndex) { 025 super(itemTypesToIndex); 026 } 027 028 @NonNull 029 protected abstract IIndexer getIndexer(T state); 030 031 @Override 032 public R visitGroup(IAssemblyNodeItem item, R childResult, T state) { 033 getIndexer(state).addGroup(item); 034 return childResult; 035 } 036 037 @Override 038 public R visitControl(IAssemblyNodeItem item, R childResult, T state) { 039 getIndexer(state).addControl(item); 040 return childResult; 041 } 042 043 @Override 044 protected R visitParameter(@NonNull IAssemblyNodeItem parameterItem, 045 @NonNull IAssemblyNodeItem catalogOrGroupOrControl, T state) { 046 getIndexer(state).addParameter(parameterItem); 047 return newDefaultResult(state); 048 } 049 050 @Override 051 protected void visitPart(@NonNull IAssemblyNodeItem partItem, 052 @NonNull IAssemblyNodeItem catalogOrGroupOrControl, T state) { 053 getIndexer(state).addPart(partItem); 054 } 055 056 @Override 057 protected void visitRole(IAssemblyNodeItem roleItem, IAssemblyNodeItem metadataItem, T state) { 058 getIndexer(state).addRole(roleItem); 059 } 060 061 @Override 062 protected void visitLocation(IAssemblyNodeItem locationItem, IAssemblyNodeItem metadataItem, 063 T state) { 064 getIndexer(state).addLocation(locationItem); 065 } 066 067 @Override 068 protected void visitParty(IAssemblyNodeItem partyItem, IAssemblyNodeItem metadataItem, T state) { 069 getIndexer(state).addParty(partyItem); 070 } 071 072 @Override 073 protected void visitResource(IAssemblyNodeItem resourceItem, IRootAssemblyNodeItem rootItem, T state) { 074 getIndexer(state).addResource(resourceItem); 075 } 076}