blob: 36e65ec4c1d87b88d8cce0f52d594404c613530a [file] [log] [blame]
<!--
/***************************************************************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
***************************************************************************************************************************/
-->
@ParentProperty Annotation
<p>
The {@link oaj.annotation.ParentProperty @ParentProperty} annotation is used to
identify a setter as a method for adding a parent reference to a child object.
</p>
<p>
A commonly-used case is when you're parsing beans and a child bean has a reference to a parent bean.
</p>
<p class='bpcode w800'>
<jk>public class</jk> AddressBook {
<jk>public</jk> List&lt;Person&gt; <jf>people</jf>;
}
<jk>public class</jk> Person {
<ja>@ParentProperty</ja>
<jk>public</jk> AddressBook <jf>addressBook</jf>; <jc>// A reference to the containing address book.</jc>
<jk>public</jk> String <jf>name</jf>;
<jk>public char</jk> <jf>sex</jf>;
}
</p>
<p>
Parsers will automatically set this field for you in the child beans.
</p>