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 * Portions Copyright 2015 ForgeRock AS 026 */ 027package org.opends.server.admin; 028 029 030 031/** 032 * A default behavior provider which retrieves default values from a 033 * managed object in an absolute location. It should be used by 034 * properties which inherit their default value(s) from properties 035 * held in an other managed object. 036 * 037 * @param <T> 038 * The type of values represented by this provider. 039 */ 040public final class AbsoluteInheritedDefaultBehaviorProvider<T> extends 041 DefaultBehaviorProvider<T> { 042 043 /** The absolute path to the managed object containing the property. */ 044 private ManagedObjectPath<?, ?> path; 045 046 /** 047 * The string representation of the managed object path specifying 048 * the absolute location of the managed object. 049 */ 050 private final String pathString; 051 052 /** The name of the property containing the inherited default values. */ 053 private final String propertyName; 054 055 056 057 /** 058 * Create an absolute inherited default behavior provider associated 059 * with the managed object at the specified absolute location. 060 * 061 * @param pathString 062 * The string representation of the managed object path 063 * specifying the absolute location of the managed object. 064 * @param propertyName 065 * The name of the property containing the inherited 066 * default values. 067 */ 068 public AbsoluteInheritedDefaultBehaviorProvider(String pathString, 069 String propertyName) { 070 this.pathString = pathString; 071 this.propertyName = propertyName; 072 } 073 074 075 076 /** {@inheritDoc} */ 077 public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { 078 return v.visitAbsoluteInherited(this, p); 079 } 080 081 082 083 /** 084 * Get the definition of the parent managed object containing the 085 * inherited default values. 086 * 087 * @return Returns the definition of the parent managed object 088 * containing the inherited default values. 089 */ 090 public AbstractManagedObjectDefinition<?, ?> getManagedObjectDefinition() { 091 return path.getManagedObjectDefinition(); 092 } 093 094 095 096 /** 097 * Get the absolute path of the managed object containing the 098 * property which has the default values. 099 * 100 * @return Returns the absolute path of the managed object 101 * containing the property which has the default values. 102 */ 103 public ManagedObjectPath<?, ?> getManagedObjectPath() { 104 return path; 105 } 106 107 108 109 /** 110 * Gets the name of the property containing the inherited default 111 * values. 112 * 113 * @return Returns the name of the property containing the inherited 114 * default values. 115 */ 116 public String getPropertyName() { 117 return propertyName; 118 } 119 120 121 122 /** {@inheritDoc} */ 123 @Override 124 protected void initialize() throws Exception { 125 // Decode the path. 126 path = ManagedObjectPath.valueOf(pathString); 127 } 128 129}