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