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