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 2015 ForgeRock AS. 015 */ 016package org.forgerock.audit.events; 017 018/** 019 * Builder for audit activity events. 020 * <p> 021 * This builder should not be used directly but be specialized for each product to allow to define 022 * new specific fields, e.g 023 * <pre> 024 * <code> 025 * class OpenProductActivityAuditEventBuilder{@code <T extends OpenProductActivityAuditEventBuilder<T>>} 026 * extends ActivityAuditEventBuilder{@code <T>} { 027 * 028 * public static {@code <T>} OpenProductActivityAuditEventBuilder{@code <?>} productActivityEvent() { 029 * return new OpenProductActivityAuditEventBuilder(); 030 * } 031 * 032 * public T someField(String v) { 033 * jsonValue.put("someField", v); 034 * return self(); 035 * } 036 * 037 * ... 038 * } 039 * </code> 040 * </pre> 041 * 042 * @param <T> the type of the builder 043 */ 044public class ActivityAuditEventBuilder<T extends ActivityAuditEventBuilder<T>> extends StateChangeAuditEventBuilder<T> { 045 046 /** 047 * Creates the builder. 048 */ 049 protected ActivityAuditEventBuilder() { 050 // Reduce visibility of the default constructor 051 } 052 053 /** 054 * Starts to build an audit activity event. 055 * <p> 056 * Note: it is preferable to use a specialized builder that allow to add 057 * fields specific to a product. 058 * 059 * @return an audit activity event builder 060 */ 061 @SuppressWarnings("rawtypes") 062 public static ActivityAuditEventBuilder<?> activityEvent() { 063 return new ActivityAuditEventBuilder(); 064 } 065 066}