RuntimePerson.java

  1. // SECTION-START[License Header]
  2. // <editor-fold defaultstate="collapsed" desc=" Generated License ">
  3. /*
  4.  * Java Object Management and Configuration
  5.  * Copyright (C) Christian Schulte <cs@schulte.it>, 2011-313
  6.  * All rights reserved.
  7.  *
  8.  * Redistribution and use in source and binary forms, with or without
  9.  * modification, are permitted provided that the following conditions
  10.  * are met:
  11.  *
  12.  *   o Redistributions of source code must retain the above copyright
  13.  *     notice, this list of conditions and the following disclaimer.
  14.  *
  15.  *   o Redistributions in binary form must reproduce the above copyright
  16.  *     notice, this list of conditions and the following disclaimer in
  17.  *     the documentation and/or other materials provided with the
  18.  *     distribution.
  19.  *
  20.  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  21.  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  22.  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  23.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  25.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  29.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30.  *
  31.  * $JOMC: RuntimePerson.java 5061 2015-05-31 13:20:40Z schulte $
  32.  *
  33.  */
  34. // </editor-fold>
  35. // SECTION-END
  36. package org.jomc.ri.model;

  37. import org.jomc.model.Person;

  38. // SECTION-START[Documentation]
  39. // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
  40. /**
  41.  * Runtime {@code Person}.
  42.  *
  43.  * <dl>
  44.  *   <dt><b>Identifier:</b></dt><dd>org.jomc.ri.model.RuntimePerson</dd>
  45.  *   <dt><b>Name:</b></dt><dd>JOMC ⁑ RI ⁑ RuntimePerson</dd>
  46.  *   <dt><b>Specifications:</b></dt>
  47.  *     <dd>org.jomc.ri.model.RuntimeModelObject @ 1.2</dd>
  48.  *   <dt><b>Abstract:</b></dt><dd>No</dd>
  49.  *   <dt><b>Final:</b></dt><dd>No</dd>
  50.  *   <dt><b>Stateless:</b></dt><dd>No</dd>
  51.  * </dl>
  52.  *
  53.  * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.2
  54.  * @version 1.2
  55.  */
  56. // </editor-fold>
  57. // SECTION-END
  58. // SECTION-START[Annotations]
  59. // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
  60. @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  61. // </editor-fold>
  62. // SECTION-END
  63. public class RuntimePerson extends Person implements RuntimeModelObject
  64. {
  65.     // SECTION-START[RuntimePerson]

  66.     /**
  67.      * Creates a new {@code RuntimePerson} instance by deeply copying a given {@code Person} instance.
  68.      *
  69.      * @param person The instance to copy.
  70.      *
  71.      * @throws NullPointerException if {@code person} is {@code null}.
  72.      */
  73.     public RuntimePerson( final Person person )
  74.     {
  75.         super( person );

  76.         if ( this.getAuthors() != null )
  77.         {
  78.             this.setAuthors( RuntimeModelObjects.getInstance().copyOf( this.getAuthors() ) );
  79.         }
  80.         if ( this.getDocumentation() != null )
  81.         {
  82.             this.setDocumentation( RuntimeModelObjects.getInstance().copyOf( this.getDocumentation() ) );
  83.         }
  84.     }

  85.     // SECTION-END
  86.     // SECTION-START[RuntimeModelObject]
  87.     public void gc()
  88.     {
  89.         this.gcOrClear( true, false );
  90.     }

  91.     public void clear()
  92.     {
  93.         this.gcOrClear( false, true );
  94.     }

  95.     private void gcOrClear( final boolean gc, final boolean clear )
  96.     {
  97.         if ( this.getAuthors() instanceof RuntimeModelObject )
  98.         {
  99.             if ( gc )
  100.             {
  101.                 ( (RuntimeModelObject) this.getAuthors() ).gc();
  102.             }
  103.             if ( clear )
  104.             {
  105.                 ( (RuntimeModelObject) this.getAuthors() ).clear();
  106.             }
  107.         }
  108.         if ( this.getDocumentation() instanceof RuntimeModelObject )
  109.         {
  110.             if ( gc )
  111.             {
  112.                 ( (RuntimeModelObject) this.getDocumentation() ).gc();
  113.             }
  114.             if ( clear )
  115.             {
  116.                 ( (RuntimeModelObject) this.getDocumentation() ).clear();
  117.             }
  118.         }
  119.     }

  120.     // SECTION-END
  121.     // SECTION-START[Constructors]
  122.     // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
  123.     /** Creates a new {@code RuntimePerson} instance. */
  124.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  125.     public RuntimePerson()
  126.     {
  127.         // SECTION-START[Default Constructor]
  128.         super();
  129.         // SECTION-END
  130.     }
  131.     // </editor-fold>
  132.     // SECTION-END
  133.     // SECTION-START[Dependencies]
  134.     // SECTION-END
  135.     // SECTION-START[Properties]
  136.     // SECTION-END
  137.     // SECTION-START[Messages]
  138.     // SECTION-END

  139. }