| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.allocation.util; |
| 7 | |
| 8 | import java.util.Map; |
| 9 | |
| 10 | import org.eclipse.emf.common.util.DiagnosticChain; |
| 11 | import org.eclipse.emf.common.util.ResourceLocator; |
| 12 | import org.eclipse.emf.ecore.EPackage; |
| 13 | import org.eclipse.emf.ecore.util.EObjectValidator; |
| 14 | |
| 15 | import de.uka.ipd.sdq.identifier.util.IdentifierValidator; |
| 16 | import de.uka.ipd.sdq.pcm.allocation.*; |
| 17 | import de.uka.ipd.sdq.pcm.allocation.Allocation; |
| 18 | import de.uka.ipd.sdq.pcm.allocation.AllocationContext; |
| 19 | import de.uka.ipd.sdq.pcm.allocation.AllocationPackage; |
| 20 | |
| 21 | /** |
| 22 | * <!-- begin-user-doc --> |
| 23 | * The <b>Validator</b> for the model. |
| 24 | * <!-- end-user-doc --> |
| 25 | * @see de.uka.ipd.sdq.pcm.allocation.AllocationPackage |
| 26 | * @generated |
| 27 | */ |
| 28 | public class AllocationValidator extends EObjectValidator { |
| 29 | /** |
| 30 | * <!-- begin-user-doc --> |
| 31 | * <!-- end-user-doc --> |
| 32 | * @generated |
| 33 | */ |
| 34 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 35 | |
| 36 | /** |
| 37 | * The cached model package |
| 38 | * <!-- begin-user-doc --> |
| 39 | * <!-- end-user-doc --> |
| 40 | * @generated |
| 41 | */ |
| 42 | public static final AllocationValidator INSTANCE = new AllocationValidator(); |
| 43 | |
| 44 | /** |
| 45 | * A constant for the {@link org.eclipse.emf.common.util.Diagnostic#getSource() source} of diagnostic {@link org.eclipse.emf.common.util.Diagnostic#getCode() codes} from this package. |
| 46 | * <!-- begin-user-doc --> |
| 47 | * <!-- end-user-doc --> |
| 48 | * @see org.eclipse.emf.common.util.Diagnostic#getSource() |
| 49 | * @see org.eclipse.emf.common.util.Diagnostic#getCode() |
| 50 | * @generated |
| 51 | */ |
| 52 | public static final String DIAGNOSTIC_SOURCE = "de.uka.ipd.sdq.pcm.allocation"; |
| 53 | |
| 54 | /** |
| 55 | * The {@link org.eclipse.emf.common.util.Diagnostic#getCode() code} for constraint 'One Assembly Context Or One Event Channel Should Be Referred' of 'Context'. |
| 56 | * <!-- begin-user-doc --> |
| 57 | * <!-- end-user-doc --> |
| 58 | * @generated |
| 59 | */ |
| 60 | public static final int ALLOCATION_CONTEXT__ONE_ASSEMBLY_CONTEXT_OR_ONE_EVENT_CHANNEL_SHOULD_BE_REFERRED = 1; |
| 61 | |
| 62 | /** |
| 63 | * The {@link org.eclipse.emf.common.util.Diagnostic#getCode() code} for constraint 'Each Assembly Context Within System Has To Be Allocated Exactly Once' of 'Allocation'. |
| 64 | * <!-- begin-user-doc --> |
| 65 | * <!-- end-user-doc --> |
| 66 | * @generated |
| 67 | */ |
| 68 | public static final int ALLOCATION__EACH_ASSEMBLY_CONTEXT_WITHIN_SYSTEM_HAS_TO_BE_ALLOCATED_EXACTLY_ONCE = 2; |
| 69 | |
| 70 | /** |
| 71 | * The {@link org.eclipse.emf.common.util.Diagnostic#getCode() code} for constraint 'Communicating Servers Have To Be Connected By Linking Resource' of 'Allocation'. |
| 72 | * <!-- begin-user-doc --> |
| 73 | * <!-- end-user-doc --> |
| 74 | * @generated |
| 75 | */ |
| 76 | public static final int ALLOCATION__COMMUNICATING_SERVERS_HAVE_TO_BE_CONNECTED_BY_LINKING_RESOURCE = 3; |
| 77 | |
| 78 | /** |
| 79 | * A constant with a fixed name that can be used as the base value for additional hand written constants. |
| 80 | * <!-- begin-user-doc --> |
| 81 | * <!-- end-user-doc --> |
| 82 | * @generated |
| 83 | */ |
| 84 | private static final int GENERATED_DIAGNOSTIC_CODE_COUNT = 3; |
| 85 | |
| 86 | /** |
| 87 | * A constant with a fixed name that can be used as the base value for additional hand written constants in a derived class. |
| 88 | * <!-- begin-user-doc --> |
| 89 | * <!-- end-user-doc --> |
| 90 | * @generated |
| 91 | */ |
| 92 | protected static final int DIAGNOSTIC_CODE_COUNT = GENERATED_DIAGNOSTIC_CODE_COUNT; |
| 93 | |
| 94 | /** |
| 95 | * The cached base package validator. |
| 96 | * <!-- begin-user-doc --> |
| 97 | * <!-- end-user-doc --> |
| 98 | * @generated |
| 99 | */ |
| 100 | protected IdentifierValidator identifierValidator; |
| 101 | |
| 102 | /** |
| 103 | * Creates an instance of the switch. |
| 104 | * <!-- begin-user-doc --> |
| 105 | * <!-- end-user-doc --> |
| 106 | * @generated |
| 107 | */ |
| 108 | public AllocationValidator() { |
| 109 | super(); |
| 110 | identifierValidator = IdentifierValidator.INSTANCE; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Returns the package of this validator switch. |
| 115 | * <!-- begin-user-doc --> |
| 116 | * <!-- end-user-doc --> |
| 117 | * @generated |
| 118 | */ |
| 119 | @Override |
| 120 | protected EPackage getEPackage() { |
| 121 | return AllocationPackage.eINSTANCE; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Calls <code>validateXXX</code> for the corresponding classifier of the model. |
| 126 | * <!-- begin-user-doc --> |
| 127 | * <!-- end-user-doc --> |
| 128 | * @generated |
| 129 | */ |
| 130 | @Override |
| 131 | protected boolean validate(int classifierID, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 132 | switch (classifierID) { |
| 133 | case AllocationPackage.ALLOCATION_CONTEXT: |
| 134 | return validateAllocationContext((AllocationContext)value, diagnostics, context); |
| 135 | case AllocationPackage.ALLOCATION: |
| 136 | return validateAllocation((Allocation)value, diagnostics, context); |
| 137 | default: |
| 138 | return true; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * <!-- begin-user-doc --> |
| 144 | * <!-- end-user-doc --> |
| 145 | * @generated |
| 146 | */ |
| 147 | public boolean validateAllocationContext(AllocationContext allocationContext, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 148 | boolean result = validate_EveryMultiplicityConforms(allocationContext, diagnostics, context); |
| 149 | if (result || diagnostics != null) result &= validate_EveryDataValueConforms(allocationContext, diagnostics, context); |
| 150 | if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(allocationContext, diagnostics, context); |
| 151 | if (result || diagnostics != null) result &= validate_EveryProxyResolves(allocationContext, diagnostics, context); |
| 152 | if (result || diagnostics != null) result &= validate_UniqueID(allocationContext, diagnostics, context); |
| 153 | if (result || diagnostics != null) result &= validate_EveryKeyUnique(allocationContext, diagnostics, context); |
| 154 | if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(allocationContext, diagnostics, context); |
| 155 | if (result || diagnostics != null) result &= identifierValidator.validateIdentifier_idHasToBeUnique(allocationContext, diagnostics, context); |
| 156 | if (result || diagnostics != null) result &= validateAllocationContext_OneAssemblyContextOrOneEventChannelShouldBeReferred(allocationContext, diagnostics, context); |
| 157 | return result; |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Validates the OneAssemblyContextOrOneEventChannelShouldBeReferred constraint of '<em>Context</em>'. |
| 162 | * <!-- begin-user-doc --> |
| 163 | * <!-- end-user-doc --> |
| 164 | * @generated |
| 165 | */ |
| 166 | public boolean validateAllocationContext_OneAssemblyContextOrOneEventChannelShouldBeReferred(AllocationContext allocationContext, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 167 | return allocationContext.OneAssemblyContextOrOneEventChannelShouldBeReferred(diagnostics, context); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * <!-- begin-user-doc --> |
| 172 | * <!-- end-user-doc --> |
| 173 | * @generated |
| 174 | */ |
| 175 | public boolean validateAllocation(Allocation allocation, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 176 | boolean result = validate_EveryMultiplicityConforms(allocation, diagnostics, context); |
| 177 | if (result || diagnostics != null) result &= validate_EveryDataValueConforms(allocation, diagnostics, context); |
| 178 | if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(allocation, diagnostics, context); |
| 179 | if (result || diagnostics != null) result &= validate_EveryProxyResolves(allocation, diagnostics, context); |
| 180 | if (result || diagnostics != null) result &= validate_UniqueID(allocation, diagnostics, context); |
| 181 | if (result || diagnostics != null) result &= validate_EveryKeyUnique(allocation, diagnostics, context); |
| 182 | if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(allocation, diagnostics, context); |
| 183 | if (result || diagnostics != null) result &= identifierValidator.validateIdentifier_idHasToBeUnique(allocation, diagnostics, context); |
| 184 | if (result || diagnostics != null) result &= validateAllocation_EachAssemblyContextWithinSystemHasToBeAllocatedExactlyOnce(allocation, diagnostics, context); |
| 185 | if (result || diagnostics != null) result &= validateAllocation_CommunicatingServersHaveToBeConnectedByLinkingResource(allocation, diagnostics, context); |
| 186 | return result; |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * Validates the EachAssemblyContextWithinSystemHasToBeAllocatedExactlyOnce constraint of '<em>Allocation</em>'. |
| 191 | * <!-- begin-user-doc --> |
| 192 | * <!-- end-user-doc --> |
| 193 | * @generated |
| 194 | */ |
| 195 | public boolean validateAllocation_EachAssemblyContextWithinSystemHasToBeAllocatedExactlyOnce(Allocation allocation, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 196 | return allocation.EachAssemblyContextWithinSystemHasToBeAllocatedExactlyOnce(diagnostics, context); |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * Validates the CommunicatingServersHaveToBeConnectedByLinkingResource constraint of '<em>Allocation</em>'. |
| 201 | * <!-- begin-user-doc --> |
| 202 | * <!-- end-user-doc --> |
| 203 | * @generated |
| 204 | */ |
| 205 | public boolean validateAllocation_CommunicatingServersHaveToBeConnectedByLinkingResource(Allocation allocation, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 206 | return allocation.CommunicatingServersHaveToBeConnectedByLinkingResource(diagnostics, context); |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Returns the resource locator that will be used to fetch messages for this validator's diagnostics. |
| 211 | * <!-- begin-user-doc --> |
| 212 | * <!-- end-user-doc --> |
| 213 | * @generated |
| 214 | */ |
| 215 | @Override |
| 216 | public ResourceLocator getResourceLocator() { |
| 217 | // TODO |
| 218 | // Specialize this to return a resource locator for messages specific to this validator. |
| 219 | // Ensure that you remove @generated or mark it @generated NOT |
| 220 | return super.getResourceLocator(); |
| 221 | } |
| 222 | |
| 223 | } //AllocationValidator |