001/*
002 * Portions of this software was developed by employees of the National Institute
003 * of Standards and Technology (NIST), an agency of the Federal Government and is
004 * being made available as a public service. Pursuant to title 17 United States
005 * Code Section 105, works of NIST employees are not subject to copyright
006 * protection in the United States. This software may be subject to foreign
007 * copyright. Permission in the United States and in foreign countries, to the
008 * extent that NIST may hold copyright, to use, copy, modify, create derivative
009 * works, and distribute this software and its documentation without fee is hereby
010 * granted on a non-exclusive basis, provided that this notice and disclaimer
011 * of warranty appears in all copies.
012 *
013 * THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER
014 * EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY
015 * THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF
016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM
017 * INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE
018 * SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE.  IN NO EVENT
019 * SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT,
020 * INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM,
021 * OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY,
022 * CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR
023 * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT
024 * OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER.
025 */
026
027package gov.nist.secauto.oscal.lib.profile.resolver.support;
028
029import gov.nist.secauto.metaschema.model.common.metapath.item.IRequiredValueModelNodeItem;
030
031import edu.umd.cs.findbugs.annotations.NonNull;
032
033/**
034 * Used to visit a catalog containing groups and controls.
035 *
036 * @param <T>
037 *          the type of the context object used to pass calling context
038 *          information
039 * @param <R>
040 *          the type of the result for visiting a collection of groups and/or
041 *          controls
042 */
043public interface ICatalogVisitor<T, R> {
044
045  /**
046   * Called when visiting a group.
047   * <p>
048   * Can be overridden by classes extending this interface to support processing
049   * of the visited object.
050   *
051   * @param item
052   *          the Metapath item for the group
053   * @param childResult
054   *          the result of evaluating the group's children
055   * @param state
056   *          the calling context information
057   * @return a meaningful result of the given type
058   */
059  default R visitGroup(@NonNull IRequiredValueModelNodeItem item, R childResult, T state) {
060    // do nothing by default
061    return childResult;
062  }
063
064  /**
065   * Called when visiting a control.
066   * <p>
067   * Can be overridden by classes extending this interface to support processing
068   * of the visited object.
069   *
070   * @param item
071   *          the Metapath item for the control
072   * @param childResult
073   *          the result of evaluating the control's children
074   * @param state
075   *          the calling context information
076   * @return a meaningful result of the given type
077   */
078  default R visitControl(@NonNull IRequiredValueModelNodeItem item, R childResult, T state) {
079    // do nothing by default
080    return childResult;
081  }
082}