RuntimeModule.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: RuntimeModule.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.Module;

  38. // SECTION-START[Documentation]
  39. // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
  40. /**
  41.  * Runtime {@code Module}.
  42.  *
  43.  * <dl>
  44.  *   <dt><b>Identifier:</b></dt><dd>org.jomc.ri.model.RuntimeModule</dd>
  45.  *   <dt><b>Name:</b></dt><dd>JOMC ⁑ RI ⁑ RuntimeModule</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 RuntimeModule extends Module implements RuntimeModelObject
  64. {
  65.     // SECTION-START[RuntimeModule]

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

  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.         if ( this.getImplementations() != null )
  85.         {
  86.             this.setImplementations( RuntimeModelObjects.getInstance().copyOf( this.getImplementations() ) );
  87.         }
  88.         if ( this.getMessages() != null )
  89.         {
  90.             this.setMessages( RuntimeModelObjects.getInstance().copyOf( this.getMessages() ) );
  91.         }
  92.         if ( this.getProperties() != null )
  93.         {
  94.             this.setProperties( RuntimeModelObjects.getInstance().copyOf( this.getProperties() ) );
  95.         }
  96.         if ( this.getSpecifications() != null )
  97.         {
  98.             this.setSpecifications( RuntimeModelObjects.getInstance().copyOf( this.getSpecifications() ) );
  99.         }
  100.     }

  101.     // SECTION-END
  102.     // SECTION-START[RuntimeModelObject]
  103.     public void gc()
  104.     {
  105.         this.gcOrClear( true, false );
  106.     }

  107.     public void clear()
  108.     {
  109.         this.gcOrClear( false, true );
  110.     }

  111.     private void gcOrClear( final boolean gc, final boolean clear )
  112.     {
  113.         if ( this.getAuthors() instanceof RuntimeModelObject )
  114.         {
  115.             if ( gc )
  116.             {
  117.                 ( (RuntimeModelObject) this.getAuthors() ).gc();
  118.             }
  119.             if ( clear )
  120.             {
  121.                 ( (RuntimeModelObject) this.getAuthors() ).clear();
  122.             }
  123.         }
  124.         if ( this.getDocumentation() instanceof RuntimeModelObject )
  125.         {
  126.             if ( gc )
  127.             {
  128.                 ( (RuntimeModelObject) this.getDocumentation() ).gc();
  129.             }
  130.             if ( clear )
  131.             {
  132.                 ( (RuntimeModelObject) this.getDocumentation() ).clear();
  133.             }
  134.         }
  135.         if ( this.getImplementations() instanceof RuntimeModelObject )
  136.         {
  137.             if ( gc )
  138.             {
  139.                 ( (RuntimeModelObject) this.getImplementations() ).gc();
  140.             }
  141.             if ( clear )
  142.             {
  143.                 ( (RuntimeModelObject) this.getImplementations() ).clear();
  144.             }
  145.         }
  146.         if ( this.getMessages() instanceof RuntimeModelObject )
  147.         {
  148.             if ( gc )
  149.             {
  150.                 ( (RuntimeModelObject) this.getMessages() ).gc();
  151.             }
  152.             if ( clear )
  153.             {
  154.                 ( (RuntimeModelObject) this.getMessages() ).clear();
  155.             }
  156.         }
  157.         if ( this.getProperties() instanceof RuntimeModelObject )
  158.         {
  159.             if ( gc )
  160.             {
  161.                 ( (RuntimeModelObject) this.getProperties() ).gc();
  162.             }
  163.             if ( clear )
  164.             {
  165.                 ( (RuntimeModelObject) this.getProperties() ).clear();
  166.             }
  167.         }
  168.         if ( this.getSpecifications() instanceof RuntimeModelObject )
  169.         {
  170.             if ( gc )
  171.             {
  172.                 ( (RuntimeModelObject) this.getSpecifications() ).gc();
  173.             }
  174.             if ( clear )
  175.             {
  176.                 ( (RuntimeModelObject) this.getSpecifications() ).clear();
  177.             }
  178.         }
  179.     }

  180.     // SECTION-END
  181.     // SECTION-START[Constructors]
  182.     // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
  183.     /** Creates a new {@code RuntimeModule} instance. */
  184.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  185.     public RuntimeModule()
  186.     {
  187.         // SECTION-START[Default Constructor]
  188.         super();
  189.         // SECTION-END
  190.     }
  191.     // </editor-fold>
  192.     // SECTION-END
  193.     // SECTION-START[Dependencies]
  194.     // SECTION-END
  195.     // SECTION-START[Properties]
  196.     // SECTION-END
  197.     // SECTION-START[Messages]
  198.     // SECTION-END

  199. }