Method: canBeGenerated()

1: /*
2: * #%~
3: * VDM Code Generator
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.codegen.utils;
23:
24: import java.util.HashSet;
25: import java.util.LinkedList;
26: import java.util.List;
27: import java.util.Set;
28:
29: import org.overture.codegen.ir.IrNodeInfo;
30: import org.overture.codegen.ir.VdmNodeInfo;
31:
32: public class Generated
33: {
34:         protected String content;
35:         protected Set<VdmNodeInfo> unsupportedInIr;
36:         protected Set<IrNodeInfo> unsupportedInTargLang;
37:         protected Set<IrNodeInfo> transformationWarnings;
38:         protected List<Exception> mergeErrors;
39:
40:         public Generated(String content, Set<VdmNodeInfo> unsupportedInIr,
41:                         Set<IrNodeInfo> unsupportedInTargLang, List<Exception> mergeErrors)
42:         {
43:                 this.content = content;
44:                 this.unsupportedInIr = unsupportedInIr;
45:                 this.unsupportedInTargLang = unsupportedInTargLang;
46:                 this.transformationWarnings = new HashSet<IrNodeInfo>();
47:                 this.mergeErrors = mergeErrors;
48:         }
49:
50:         public Generated(String content)
51:         {
52:                 this(content, new HashSet<VdmNodeInfo>(), new HashSet<IrNodeInfo>(), new LinkedList<Exception>());
53:         }
54:
55:         public Generated(Set<VdmNodeInfo> unsupportedNodes,
56:                         Set<IrNodeInfo> unsupportedInTargLang)
57:         {
58:                 this(null, unsupportedNodes, unsupportedInTargLang, new LinkedList<Exception>());
59:         }
60:
61:         public Generated(List<Exception> mergeErrrors)
62:         {
63:                 this(null, new HashSet<VdmNodeInfo>(), new HashSet<IrNodeInfo>(), mergeErrrors);
64:         }
65:
66:         public String getContent()
67:         {
68:                 return content;
69:         }
70:
71:         public Set<VdmNodeInfo> getUnsupportedInIr()
72:         {
73:                 return unsupportedInIr;
74:         }
75:
76:         public Set<IrNodeInfo> getUnsupportedInTargLang()
77:         {
78:                 return unsupportedInTargLang;
79:         }
80:
81:         public List<Exception> getMergeErrors()
82:         {
83:                 return mergeErrors;
84:         }
85:
86:         public boolean canBeGenerated()
87:         {
88:•                return unsupportedInIr.isEmpty() && unsupportedInTargLang.isEmpty();
89:         }
90:
91:         public boolean hasErrors()
92:         {
93:                 return !unsupportedInIr.isEmpty() || !unsupportedInTargLang.isEmpty()
94:                                 || !mergeErrors.isEmpty();
95:         }
96:
97:         public boolean hasUnsupportedIrNodes()
98:         {
99:                 return !unsupportedInIr.isEmpty();
100:         }
101:
102:         public boolean hasUnsupportedTargLangNodes()
103:         {
104:                 return !unsupportedInTargLang.isEmpty();
105:         }
106:
107:         public Set<IrNodeInfo> getTransformationWarnings()
108:         {
109:                 return transformationWarnings;
110:         }
111:
112:         public void setTransformationWarnings(
113:                         Set<IrNodeInfo> transformationWarnings)
114:         {
115:                 this.transformationWarnings = transformationWarnings;
116:         }
117:
118:         public boolean hasMergeErrors()
119:         {
120:                 return !mergeErrors.isEmpty();
121:         }
122: }