RuntimeAuthors.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: RuntimeAuthors.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.Author;
  38. import org.jomc.model.Authors;

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

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

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

  85.         this.copyAuthors();
  86.     }

  87.     private void copyAuthors()
  88.     {
  89.         for ( int i = 0, s0 = this.getAuthor().size(); i < s0; i++ )
  90.         {
  91.             final Author a = this.getAuthor().get( i );
  92.             this.getAuthor().set( i, RuntimeModelObjects.getInstance().copyOf( a ) );
  93.         }
  94.     }

  95.     // SECTION-END
  96.     // SECTION-START[RuntimeModelObject]
  97.     public void gc()
  98.     {
  99.         this.gcOrClear( true, false );
  100.     }

  101.     public void clear()
  102.     {
  103.         this.gcOrClear( false, true );
  104.     }

  105.     private void gcOrClear( final boolean gc, final boolean clear )
  106.     {
  107.         if ( this.getAuthors() instanceof RuntimeModelObject )
  108.         {
  109.             if ( gc )
  110.             {
  111.                 ( (RuntimeModelObject) this.getAuthors() ).gc();
  112.             }
  113.             if ( clear )
  114.             {
  115.                 ( (RuntimeModelObject) this.getAuthors() ).clear();
  116.             }
  117.         }
  118.         if ( this.getDocumentation() instanceof RuntimeModelObject )
  119.         {
  120.             if ( gc )
  121.             {
  122.                 ( (RuntimeModelObject) this.getDocumentation() ).gc();
  123.             }
  124.             if ( clear )
  125.             {
  126.                 ( (RuntimeModelObject) this.getDocumentation() ).clear();
  127.             }
  128.         }

  129.         this.gcOrClearAuthors( gc, clear );
  130.     }

  131.     private void gcOrClearAuthors( final boolean gc, final boolean clear )
  132.     {
  133.         for ( int i = this.getAuthor().size() - 1; i >= 0; i-- )
  134.         {
  135.             final Author a = this.getAuthor().get( i );
  136.             if ( a instanceof RuntimeModelObject )
  137.             {
  138.                 if ( gc )
  139.                 {
  140.                     ( (RuntimeModelObject) a ).gc();
  141.                 }
  142.                 if ( clear )
  143.                 {
  144.                     ( (RuntimeModelObject) a ).clear();
  145.                 }
  146.             }
  147.         }
  148.     }

  149.     // SECTION-END
  150.     // SECTION-START[Constructors]
  151.     // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
  152.     /** Creates a new {@code RuntimeAuthors} instance. */
  153.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  154.     public RuntimeAuthors()
  155.     {
  156.         // SECTION-START[Default Constructor]
  157.         super();
  158.         // SECTION-END
  159.     }
  160.     // </editor-fold>
  161.     // SECTION-END
  162.     // SECTION-START[Dependencies]
  163.     // SECTION-END
  164.     // SECTION-START[Properties]
  165.     // SECTION-END
  166.     // SECTION-START[Messages]
  167.     // SECTION-END

  168. }