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 2008 Sun Microsystems, Inc. 015 * Portions Copyright 2016 ForgeRock AS. 016 */ 017package org.forgerock.opendj.config; 018 019/** 020 * An interface for determining the default behavior of a property. A property 021 * exhibits default behavior when it has no values defined. There are four 022 * different types of default behavior: 023 * <ol> 024 * <li>there is no default behavior - e.g. leaving a "description" unset has no 025 * side-effects. This default behavior is represented using the 026 * {@link UndefinedDefaultBehaviorProvider} implementation 027 * <li>the property defaults to one or more real values of the property. This 028 * default behavior is represented using the 029 * {@link DefinedDefaultBehaviorProvider} implementation 030 * <li>the property defaults to some special behavior that cannot be represented 031 * using real property values. This default behavior is represented using the 032 * {@link AliasDefaultBehaviorProvider} implementation 033 * <li>the property inherits its values from property held in another managed 034 * object (e.g. the parent managed object). This default behavior is represented 035 * using the {@link AbsoluteInheritedDefaultBehaviorProvider} and 036 * {@link RelativeInheritedDefaultBehaviorProvider} implementations. 037 * </ol> 038 * An application can perform actions based on the type of the default behavior 039 * by implementing the {@link DefaultBehaviorProviderVisitor} interface. 040 * 041 * @param <T> 042 * The type of values represented by this provider. 043 */ 044public abstract class DefaultBehaviorProvider<T> { 045 046 /** Creates a new default behavior provider. */ 047 protected DefaultBehaviorProvider() { 048 // No implementation required. 049 } 050 051 /** 052 * Apply a visitor to this default behavior provider. 053 * 054 * @param <R> 055 * The return type of the visitor's methods. 056 * @param <P> 057 * The type of the additional parameters to the visitor's 058 * methods. 059 * @param v 060 * The default behavior visitor. 061 * @param p 062 * Optional additional visitor parameter. 063 * @return Returns a result as specified by the visitor. 064 */ 065 public abstract <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p); 066 067 /** 068 * Performs any run-time initialization required by this default behavior 069 * provider. This may include resolving managed object paths and property 070 * names. 071 * <p> 072 * The default implementation is to do nothing. 073 * 074 * @throws Exception 075 * If this default behavior provider could not be initialized. 076 */ 077 protected void initialize() throws Exception { 078 // Default implementation is to do nothing. 079 } 080 081}