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