001// SECTION-START[License Header]
002// <editor-fold defaultstate="collapsed" desc=" Generated License ">
003/*
004 *   Java Object Management and Configuration
005 *   Copyright (C) Christian Schulte, 2011-313
006 *   All rights reserved.
007 *
008 *   Redistribution and use in source and binary forms, with or without
009 *   modification, are permitted provided that the following conditions
010 *   are met:
011 *
012 *     o Redistributions of source code must retain the above copyright
013 *       notice, this list of conditions and the following disclaimer.
014 *
015 *     o Redistributions in binary form must reproduce the above copyright
016 *       notice, this list of conditions and the following disclaimer in
017 *       the documentation and/or other materials provided with the
018 *       distribution.
019 *
020 *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
021 *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
022 *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
023 *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
024 *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
025 *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
026 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
027 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
028 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
029 *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030 *
031 *   $JOMC: RuntimeDependency.java 4588 2012-06-03 06:01:30Z schulte2005 $
032 *
033 */
034// </editor-fold>
035// SECTION-END
036package org.jomc.ri.model;
037
038import org.jomc.model.Dependency;
039
040// SECTION-START[Documentation]
041// <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
042/**
043 * Runtime {@code Dependency}.
044 *
045 * <dl>
046 *   <dt><b>Identifier:</b></dt><dd>org.jomc.ri.model.RuntimeDependency</dd>
047 *   <dt><b>Name:</b></dt><dd>JOMC RI RuntimeDependency</dd>
048 *   <dt><b>Specifications:</b></dt>
049 *     <dd>org.jomc.ri.model.RuntimeModelObject @ 1.2</dd>
050 *   <dt><b>Abstract:</b></dt><dd>No</dd>
051 *   <dt><b>Final:</b></dt><dd>No</dd>
052 *   <dt><b>Stateless:</b></dt><dd>No</dd>
053 * </dl>
054 *
055 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.2
056 * @version 1.2
057 */
058// </editor-fold>
059// SECTION-END
060// SECTION-START[Annotations]
061// <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
062@javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
063// </editor-fold>
064// SECTION-END
065public class RuntimeDependency extends Dependency implements RuntimeModelObject
066{
067    // SECTION-START[RuntimeDependency]
068
069    /**
070     * Creates a new {@code RuntimeDependency} instance by deeply copying a given {@code Dependency} instance.
071     *
072     * @param dependency The instance to copy.
073     *
074     * @throws NullPointerException if {@code dependency} is {@code null}.
075     */
076    public RuntimeDependency( final Dependency dependency )
077    {
078        super( dependency );
079
080        if ( this.getAuthors() != null )
081        {
082            this.setAuthors( RuntimeModelObjects.getInstance().copyOf( this.getAuthors() ) );
083        }
084        if ( this.getDependencies() != null )
085        {
086            this.setDependencies( RuntimeModelObjects.getInstance().copyOf( this.getDependencies() ) );
087        }
088        if ( this.getDocumentation() != null )
089        {
090            this.setDocumentation( RuntimeModelObjects.getInstance().copyOf( this.getDocumentation() ) );
091        }
092        if ( this.getMessages() != null )
093        {
094            this.setMessages( RuntimeModelObjects.getInstance().copyOf( this.getMessages() ) );
095        }
096        if ( this.getProperties() != null )
097        {
098            this.setProperties( RuntimeModelObjects.getInstance().copyOf( this.getProperties() ) );
099        }
100    }
101
102    // SECTION-END
103    // SECTION-START[RuntimeModelObject]
104    public void gc()
105    {
106        this.gcOrClear( true, false );
107    }
108
109    public void clear()
110    {
111        this.gcOrClear( false, true );
112    }
113
114    private void gcOrClear( final boolean gc, final boolean clear )
115    {
116        if ( this.getAuthors() instanceof RuntimeModelObject )
117        {
118            if ( gc )
119            {
120                ( (RuntimeModelObject) this.getAuthors() ).gc();
121            }
122            if ( clear )
123            {
124                ( (RuntimeModelObject) this.getAuthors() ).clear();
125            }
126        }
127        if ( this.getDependencies() instanceof RuntimeModelObject )
128        {
129            if ( gc )
130            {
131                ( (RuntimeModelObject) this.getDependencies() ).gc();
132            }
133            if ( clear )
134            {
135                ( (RuntimeModelObject) this.getDependencies() ).clear();
136            }
137        }
138        if ( this.getDocumentation() instanceof RuntimeModelObject )
139        {
140            if ( gc )
141            {
142                ( (RuntimeModelObject) this.getDocumentation() ).gc();
143            }
144            if ( clear )
145            {
146                ( (RuntimeModelObject) this.getDocumentation() ).clear();
147            }
148        }
149        if ( this.getMessages() instanceof RuntimeModelObject )
150        {
151            if ( gc )
152            {
153                ( (RuntimeModelObject) this.getMessages() ).gc();
154            }
155            if ( clear )
156            {
157                ( (RuntimeModelObject) this.getMessages() ).clear();
158            }
159        }
160        if ( this.getProperties() instanceof RuntimeModelObject )
161        {
162            if ( gc )
163            {
164                ( (RuntimeModelObject) this.getProperties() ).gc();
165            }
166            if ( clear )
167            {
168                ( (RuntimeModelObject) this.getProperties() ).clear();
169            }
170        }
171    }
172
173    // SECTION-END
174    // SECTION-START[Constructors]
175    // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
176    /** Creates a new {@code RuntimeDependency} instance. */
177    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
178    public RuntimeDependency()
179    {
180        // SECTION-START[Default Constructor]
181        super();
182        // SECTION-END
183    }
184    // </editor-fold>
185    // SECTION-END
186    // SECTION-START[Dependencies]
187    // SECTION-END
188    // SECTION-START[Properties]
189    // SECTION-END
190    // SECTION-START[Messages]
191    // SECTION-END
192}