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