001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions copyright [year] [name of copyright owner]". 013 * 014 * Copyright © 2012 ForgeRock AS. All rights reserved. 015 */ 016 017package org.forgerock.json.resource; 018 019 020/** 021 * A visitor of {@code Request}s, in the style of the visitor design pattern. 022 * <p> 023 * Classes implementing this interface can perform actions based on the type of 024 * a request in a type-safe manner. When a visitor is passed to a request's 025 * accept method, the corresponding visit method associated with the type of the 026 * request is invoked. 027 * 028 * @param <R> 029 * The return type of this visitor's methods. Use 030 * {@link java.lang.Void} for visitors that do not need to return 031 * results. 032 * @param <P> 033 * The type of the additional parameter to this visitor's methods. 034 * Use {@link java.lang.Void} for visitors that do not need an 035 * additional parameter. 036 */ 037public interface RequestVisitor<R, P> { 038 039 /** 040 * Visits an action request. 041 * 042 * @param p 043 * A visitor specified parameter. 044 * @param request 045 * The action request. 046 * @return Returns a visitor specified result. 047 */ 048 R visitActionRequest(P p, ActionRequest request); 049 050 /** 051 * Visits a create request. 052 * 053 * @param p 054 * A visitor specified parameter. 055 * @param request 056 * The create request. 057 * @return Returns a visitor specified result. 058 */ 059 R visitCreateRequest(P p, CreateRequest request); 060 061 /** 062 * Visits a delete request. 063 * 064 * @param p 065 * A visitor specified parameter. 066 * @param request 067 * The delete request. 068 * @return Returns a visitor specified result. 069 */ 070 R visitDeleteRequest(P p, DeleteRequest request); 071 072 /** 073 * Visits a patch request. 074 * 075 * @param p 076 * A visitor specified parameter. 077 * @param request 078 * The patch request. 079 * @return Returns a visitor specified result. 080 */ 081 R visitPatchRequest(P p, PatchRequest request); 082 083 /** 084 * Visits a query request. 085 * 086 * @param p 087 * A visitor specified parameter. 088 * @param request 089 * The query request. 090 * @return Returns a visitor specified result. 091 */ 092 R visitQueryRequest(P p, QueryRequest request); 093 094 /** 095 * Visits a read request. 096 * 097 * @param p 098 * A visitor specified parameter. 099 * @param request 100 * The read request. 101 * @return Returns a visitor specified result. 102 */ 103 R visitReadRequest(P p, ReadRequest request); 104 105 /** 106 * Visits an update request. 107 * 108 * @param p 109 * A visitor specified parameter. 110 * @param request 111 * The update request. 112 * @return Returns a visitor specified result. 113 */ 114 R visitUpdateRequest(P p, UpdateRequest request); 115 116}