RuntimeSpecificationReference.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: RuntimeSpecificationReference.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.SpecificationReference;

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

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

  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.     }

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

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

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

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

  140. }