001/*
002 * Copyright 2009-2020 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2009-2020 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2009-2020 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.persist;
037
038
039
040import java.lang.annotation.ElementType;
041import java.lang.annotation.Documented;
042import java.lang.annotation.Retention;
043import java.lang.annotation.RetentionPolicy;
044import java.lang.annotation.Target;
045
046
047
048/**
049 * This annotation type may be used to mark classes for objects that may be
050 * persisted in an LDAP directory server.  It may only be used to mark classes,
051 * and should not be used for interfaces or annotation types.  Classes with this
052 * annotation type must provide a default zero-argument constructor.  Fields in
053 * the associated class which are to be persisted should be marked with the
054 * {@link LDAPField} annotation type.
055 */
056@Documented()
057@Retention(RetentionPolicy.RUNTIME)
058@Target(value={ElementType.TYPE})
059public @interface LDAPObject
060{
061  /**
062   * Indicates whether to request all attributes when performing searches to
063   * retrieve objects of this type.  If this is {@code true}, then the search
064   * request will attempt to retrieve all user and operational attributes.  If
065   * this is {@code false}, then the search request will attempt to retrieve
066   * only those attributes which are referenced by an {@link LDAPField} or
067   * {@link LDAPSetter} annotation.  Note that if this is given a value of
068   * {@code true}, then lazy loading will be disabled.
069   *
070   * @return  {@code true} if all attributes should be requested, or
071   *          {@code false} if only referenced attributes should be requested.
072   */
073  boolean requestAllAttributes() default false;
074
075
076
077  /**
078   * The DN of the entry below which objects of this type will be created if no
079   * alternate parent DN is specified.  A value equal to the empty string
080   * indicates that there should be no default parent DN.
081   * <BR><BR>
082   * If a class marked with the {@code LDAPObject} annotation type does not
083   * specify a default parent DN but is a direct subclass of another class
084   * marked with {@code LDAPObject}, then the subclass will inherit the default
085   * parent DN from the superclass.
086   *
087   * @return  The DN of the entry below which objects of this type will be
088   *          created if no alternate parent DN is specified, or the empty
089   *          string if there should be no default parent DN.
090   */
091  String defaultParentDN() default "";
092
093
094
095  /**
096   * The name of a method that should be invoked on an object after all other
097   * decode processing has been performed for that object.  It may perform any
098   * additional work or validation that is not available as part of the LDAP SDK
099   * persistence framework.  If a method name is provided, then that method must
100   * exist in the associated class and it must not take any arguments.  It may
101   * throw any kind of exception if the object is not valid.
102   *
103   * @return  The name of a method that should be invoked on an object after all
104   *          other decode processing has been performed for that object, or an
105   *          empty string if no post-decode method has been defined.
106   */
107  String postDecodeMethod() default "";
108
109
110
111  /**
112   * The name of a method that should be invoked after an object has been
113   * encoded to an LDAP entry.  It may alter the generated entry in any way,
114   * including adding, removing, or replacing attributes, or altering the entry
115   * DN.  If a method name is provided, then that method must exist in the
116   * associated class and it must take exactly one argument, with a type of
117   * {@link com.unboundid.ldap.sdk.Entry}.  It may throw any kind of exception
118   * if a problem is found with the entry and it should not be used.
119   *
120   * @return  The name of a method that should be invoked after an object has
121   *          been encoded to an LDAP entry, or an empty string if no
122   *          post-encode method has been defined.
123   */
124  String postEncodeMethod() default "";
125
126
127
128  /**
129   * The name of the structural object class for LDAP entries created from the
130   * associated object type.  If no value is provided, then it will be assumed
131   * that the object class name is equal to the unqualified name of the Java
132   * class.
133   *
134   * @return  The name of the structural object class for LDAP entries created
135   *          from the associated object type, or an empty string if the object
136   *          class name will be assumed to be equal to the unqualified name of
137   *          the Java class.
138   */
139  String structuralClass() default "";
140
141
142
143  /**
144   * The name) of any auxiliary object classes for LDAP entries created from the
145   * associated object type.
146   *
147   * @return  The names of any auxiliary object classes for LDAP entries created
148   *          from the associated object type, or an empty array if entries
149   *          should not include any auxiliary object classes.
150   */
151  String[] auxiliaryClass() default {};
152
153
154
155  /**
156   * The names of any superior object classes for the structural and auxiliary
157   * object classes that should be included in generated entries.
158   *
159   * @return  The names of any superior object classes for the structural and
160   *          auxiliary object classes that should be included in generated
161   *          entries, or an empty array if no superior classes should be
162   *          included.
163   */
164  String[] superiorClass() default {};
165}