Coverage Report - org.argouml.uml.cognitive.critics.ProfileCodeGeneration
 
Classes in this File Line Coverage Branch Coverage Complexity
ProfileCodeGeneration
98%
53/54
100%
2/2
1.2
 
 1  
 /* $Id: ProfileCodeGeneration.java 18258 2010-04-13 17:59:19Z tfmorris $
 2  
  *****************************************************************************
 3  
  * Copyright (c) 2009 Contributors - see below
 4  
  * All rights reserved. This program and the accompanying materials
 5  
  * are made available under the terms of the Eclipse Public License v1.0
 6  
  * which accompanies this distribution, and is available at
 7  
  * http://www.eclipse.org/legal/epl-v10.html
 8  
  *
 9  
  * Contributors:
 10  
  *    maurelio1234
 11  
  *****************************************************************************
 12  
  *
 13  
  * Some portions of this file was previously release using the BSD License:
 14  
  */
 15  
 
 16  
 // Copyright (c) 2008 The Regents of the University of California. All
 17  
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 18  
 // software and its documentation without fee, and without a written
 19  
 // agreement is hereby granted, provided that the above copyright notice
 20  
 // and this paragraph appear in all copies. This software program and
 21  
 // documentation are copyrighted by The Regents of the University of
 22  
 // California. The software program and documentation are supplied "AS
 23  
 // IS", without any accompanying services from The Regents. The Regents
 24  
 // does not warrant that the operation of the program will be
 25  
 // uninterrupted or error-free. The end-user understands that the program
 26  
 // was developed for research purposes and is advised not to rely
 27  
 // exclusively on the program for any reason. IN NO EVENT SHALL THE
 28  
 // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
 29  
 // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
 30  
 // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
 31  
 // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
 32  
 // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
 33  
 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 34  
 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
 35  
 // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
 36  
 // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
 37  
 // UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 38  
 
 39  
 package org.argouml.uml.cognitive.critics;
 40  
 
 41  
 import java.util.HashSet;
 42  
 import java.util.Set;
 43  
 
 44  
 import org.argouml.cognitive.CompoundCritic;
 45  
 import org.argouml.cognitive.Critic;
 46  
 import org.argouml.profile.Profile;
 47  
 
 48  
 /**
 49  
  * Profile which contains the critics that define stricter good practices for
 50  
  * UML models targeted for code generation
 51  
  * 
 52  
  * @author maurelio1234
 53  
  */
 54  
 public class ProfileCodeGeneration extends Profile {
 55  
 
 56  900
     private Set<Critic>  critics = null;
 57  
 
 58  
     private static Critic crMissingClassName;
 59  
     
 60  900
     private static Critic crDisambigClassName = new CrDisambigClassName();
 61  
 
 62  900
     private static Critic crNoTransitions = new CrNoTransitions();
 63  
 
 64  900
     private static Critic crNoIncomingTransitions =
 65  
         new CrNoIncomingTransitions();
 66  
 
 67  900
     private static Critic crNoOutgoingTransitions =
 68  
         new CrNoOutgoingTransitions();
 69  
         
 70  
     // Compound critics
 71  
 
 72  
     // only classes with name need a constructor
 73  
     private static CompoundCritic crCompoundConstructorNeeded;
 74  
 
 75  
     private static CompoundCritic clsNaming;
 76  
     
 77  900
     private static CompoundCritic noTrans1 =
 78  
         new CompoundCritic(crNoTransitions, crNoIncomingTransitions);
 79  
 
 80  900
     private static CompoundCritic noTrans2 =
 81  
         new CompoundCritic(crNoTransitions, crNoOutgoingTransitions);
 82  
         
 83  
     /**
 84  
      * Default Constructor 
 85  
      * 
 86  
      * @param profileGoodPractices the instance of the required profile 
 87  
      */
 88  900
     public ProfileCodeGeneration(ProfileGoodPractices profileGoodPractices) {
 89  900
         crMissingClassName = profileGoodPractices.getCrMissingClassName();
 90  900
         addProfileDependency("GoodPractices");
 91  900
     }
 92  
 
 93  
     private void loadCritics() {
 94  
 
 95  900
         critics = new HashSet<Critic>();
 96  
         
 97  900
         crCompoundConstructorNeeded = new CompoundCritic(
 98  
                 crMissingClassName, new CrConstructorNeeded());
 99  
 
 100  900
         clsNaming = new CompoundCritic(crMissingClassName,
 101  
                 crDisambigClassName);
 102  
             
 103  900
         critics.add(crCompoundConstructorNeeded);
 104  
         
 105  
         // code generation
 106  900
         critics.add(clsNaming);
 107  900
         critics.add(new CrDisambigStateName());
 108  900
         critics.add(crDisambigClassName);
 109  900
         critics.add(new CrIllegalName());
 110  900
         critics.add(new CrReservedName());
 111  900
         critics.add(new CrNoInitialState());
 112  900
         critics.add(new CrNoTriggerOrGuard());
 113  900
         critics.add(new CrNoGuard());
 114  
                    
 115  900
         critics.add(new CrOperNameConflict());
 116  900
         critics.add(new CrNoInstanceVariables());
 117  900
         critics.add(new CrNoAssociations());
 118  900
         critics.add(new CrNoOperations());
 119  900
         critics.add(new CrUselessAbstract());
 120  900
         critics.add(new CrUselessInterface());
 121  900
         critics.add(new CrNavFromInterface());
 122  900
         critics.add(new CrUnnavigableAssoc());
 123  900
         critics.add(new CrAlreadyRealizes());
 124  900
         critics.add(new CrMultipleInitialStates());
 125  900
         critics.add(new CrUnconventionalOperName());
 126  900
         critics.add(new CrUnconventionalAttrName());
 127  900
         critics.add(new CrUnconventionalClassName());
 128  900
         critics.add(new CrUnconventionalPackName());
 129  900
         critics.add(new CrNodeInsideElement());
 130  900
         critics.add(new CrNodeInstanceInsideElement());
 131  900
         critics.add(new CrComponentWithoutNode());
 132  900
         critics.add(new CrCompInstanceWithoutNode());
 133  900
         critics.add(new CrClassWithoutComponent());
 134  900
         critics.add(new CrInterfaceWithoutComponent());
 135  900
         critics.add(new CrObjectWithoutComponent());
 136  900
         critics.add(new CrInstanceWithoutClassifier());
 137  900
         critics.add(noTrans1);
 138  900
         critics.add(noTrans2);                                  
 139  
         
 140  900
         this.setCritics(critics);
 141  900
     }
 142  
     
 143  
     @Override
 144  
     public Set<Critic> getCritics() {
 145  2846
         if (critics == null) {
 146  900
             loadCritics();
 147  
         }
 148  2846
         return super.getCritics();
 149  
     }
 150  
     
 151  
     @Override
 152  
     public String getDisplayName() {
 153  195
         return "Critics for Code Generation";
 154  
     }
 155  
 
 156  
    /*
 157  
     * @see org.argouml.profile.Profile#getProfileIdentifier()
 158  
     */
 159  
     public String getProfileIdentifier() {
 160  0
         return "CodeGeneration";
 161  
     }
 162  
 }