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