001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2008 Sun Microsystems, Inc. 025 */ 026package org.opends.server.admin; 027 028 029 030/** 031 * An interface for determining the default behavior of a property. A 032 * property exhibits default behavior when it has no values defined. 033 * There are four different types of default behavior: 034 * <ol> 035 * <li>there is no default behavior - e.g. leaving a "description" 036 * unset has no side-effects. This default behavior is represented 037 * using the {@link UndefinedDefaultBehaviorProvider} implementation 038 * <li>the property defaults to one or more real values of the 039 * property. This default behavior is represented using the 040 * {@link DefinedDefaultBehaviorProvider} implementation 041 * <li>the property defaults to some special behavior that cannot be 042 * represented using real property values. This default behavior is 043 * represented using the {@link AliasDefaultBehaviorProvider} 044 * implementation 045 * <li>the property inherits its values from property held in another 046 * managed object (e.g. the parent managed object). This default 047 * behavior is represented using the 048 * {@link AbsoluteInheritedDefaultBehaviorProvider} and 049 * {@link RelativeInheritedDefaultBehaviorProvider} implementations. 050 * </ol> 051 * An application can perform actions based on the type of the default 052 * behavior by implementing the {@link DefaultBehaviorProviderVisitor} 053 * interface. 054 * 055 * @param <T> 056 * The type of values represented by this provider. 057 */ 058public abstract class DefaultBehaviorProvider<T> { 059 060 /** 061 * Creates a new default behavior provider. 062 */ 063 protected DefaultBehaviorProvider() { 064 // No implementation required. 065 } 066 067 068 069 /** 070 * Apply a visitor to this default behavior provider. 071 * 072 * @param <R> 073 * The return type of the visitor's methods. 074 * @param <P> 075 * The type of the additional parameters to the visitor's 076 * methods. 077 * @param v 078 * The default behavior visitor. 079 * @param p 080 * Optional additional visitor parameter. 081 * @return Returns a result as specified by the visitor. 082 */ 083 public abstract <R, P> 084 R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p); 085 086 087 088 /** 089 * Performs any run-time initialization required by this default 090 * behavior provider. This may include resolving managed object 091 * paths and property names. 092 * <p> 093 * The default implementation is to do nothing. 094 * 095 * @throws Exception 096 * If this default behavior provider could not be 097 * initialized. 098 */ 099 protected void initialize() throws Exception { 100 // Default implementation is to do nothing. 101 } 102 103}