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 * Portions Copyright 2016 ForgeRock AS. 016 */ 017 018package org.forgerock.opendj.config; 019 020import java.util.Collection; 021import java.util.Collections; 022 023/** An interface which can be used to initialize the contents of a managed object. */ 024public interface PropertyProvider { 025 026 /** A property provider which always returns empty property values, indicating default behavior. */ 027 PropertyProvider DEFAULT_PROVIDER = new PropertyProvider() { 028 029 @Override 030 public <T> Collection<T> getPropertyValues(PropertyDefinition<T> d) { 031 return Collections.<T> emptySet(); 032 } 033 034 }; 035 036 /** 037 * Get the property values associated with the specified property 038 * definition. 039 * <p> 040 * Implementations are not required to validate the values that they 041 * provide. Specifically: 042 * <ul> 043 * <li>they do not need to guarantee that the provided values are valid 044 * according to the property's syntax 045 * <li>they do not need to provide values for mandatory properties 046 * <li>they do not need to ensure that single-valued properties do contain 047 * at most one value. 048 * </ul> 049 * The returned set of values is allowed to contain duplicates. 050 * 051 * @param <T> 052 * The underlying type of the property. 053 * @param d 054 * The Property definition. 055 * @return Returns a newly allocated set containing a copy of the property's 056 * values. An empty set indicates that the property has no values 057 * defined and any default behavior is applicable. 058 * @throws IllegalArgumentException 059 * If this property provider does not recognise the requested 060 * property definition. 061 */ 062 <T> Collection<T> getPropertyValues(PropertyDefinition<T> d); 063}