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, 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: RuntimePersons.java 4712 2013-01-02 13:56:12Z schulte $ 32 * 33 */ 34 // </editor-fold> 35 // SECTION-END 36 package org.jomc.ri.model; 37 38 import org.jomc.model.Person; 39 import org.jomc.model.Persons; 40 41 // SECTION-START[Documentation] 42 // <editor-fold defaultstate="collapsed" desc=" Generated Documentation "> 43 /** 44 * Runtime {@code Persons}. 45 * 46 * <dl> 47 * <dt><b>Identifier:</b></dt><dd>org.jomc.ri.model.RuntimePersons</dd> 48 * <dt><b>Name:</b></dt><dd>JOMC ⁑ RI ⁑ RuntimePersons</dd> 49 * <dt><b>Specifications:</b></dt> 50 * <dd>org.jomc.ri.model.RuntimeModelObject @ 1.2</dd> 51 * <dt><b>Abstract:</b></dt><dd>No</dd> 52 * <dt><b>Final:</b></dt><dd>No</dd> 53 * <dt><b>Stateless:</b></dt><dd>No</dd> 54 * </dl> 55 * 56 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.2 57 * @version 1.2 58 */ 59 // </editor-fold> 60 // SECTION-END 61 // SECTION-START[Annotations] 62 // <editor-fold defaultstate="collapsed" desc=" Generated Annotations "> 63 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" ) 64 // </editor-fold> 65 // SECTION-END 66 public class RuntimePersons extends Persons implements RuntimeModelObject 67 { 68 // SECTION-START[RuntimePersons] 69 70 /** 71 * Creates a new {@code RuntimePersons} instance by deeply copying a given {@code Persons} instance. 72 * 73 * @param persons The instance to copy. 74 * 75 * @throws NullPointerException if {@code persons} is {@code null}. 76 */ 77 public RuntimePersons( final Persons persons ) 78 { 79 super( persons ); 80 81 if ( this.getAuthors() != null ) 82 { 83 this.setAuthors( RuntimeModelObjects.getInstance().copyOf( this.getAuthors() ) ); 84 } 85 if ( this.getDocumentation() != null ) 86 { 87 this.setDocumentation( RuntimeModelObjects.getInstance().copyOf( this.getDocumentation() ) ); 88 } 89 90 this.copyPersons(); 91 } 92 93 private void copyPersons() 94 { 95 for ( int i = 0, s0 = this.getPerson().size(); i < s0; i++ ) 96 { 97 final Person p = this.getPerson().get( i ); 98 this.getPerson().set( i, RuntimeModelObjects.getInstance().copyOf( p ) ); 99 } 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.getDocumentation() instanceof RuntimeModelObject ) 128 { 129 if ( gc ) 130 { 131 ( (RuntimeModelObject) this.getDocumentation() ).gc(); 132 } 133 if ( clear ) 134 { 135 ( (RuntimeModelObject) this.getDocumentation() ).clear(); 136 } 137 } 138 139 this.gcOrClearPersons( gc, clear ); 140 } 141 142 private void gcOrClearPersons( final boolean gc, final boolean clear ) 143 { 144 for ( int i = this.getPerson().size() - 1; i >= 0; i-- ) 145 { 146 final Person p = this.getPerson().get( i ); 147 if ( p instanceof RuntimeModelObject ) 148 { 149 if ( gc ) 150 { 151 ( (RuntimeModelObject) p ).gc(); 152 } 153 if ( clear ) 154 { 155 ( (RuntimeModelObject) p ).clear(); 156 } 157 } 158 } 159 } 160 // SECTION-END 161 // SECTION-START[Constructors] 162 // <editor-fold defaultstate="collapsed" desc=" Generated Constructors "> 163 /** Creates a new {@code RuntimePersons} instance. */ 164 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" ) 165 public RuntimePersons() 166 { 167 // SECTION-START[Default Constructor] 168 super(); 169 // SECTION-END 170 } 171 // </editor-fold> 172 // SECTION-END 173 // SECTION-START[Dependencies] 174 // SECTION-END 175 // SECTION-START[Properties] 176 // SECTION-END 177 // SECTION-START[Messages] 178 // SECTION-END 179 }