Package: PDefinitionSet

PDefinitionSet

nameinstructionbranchcomplexitylinemethod
PDefinitionSet(ITypeCheckerAssistantFactory)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
add(PDefinition)
M: 0 C: 10
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
asList()
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
contains(Object)
M: 0 C: 22
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * #%~
3: * The VDM Type Checker
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.typechecker.assistant.definition;
23:
24: import java.util.HashSet;
25: import java.util.List;
26: import java.util.Vector;
27:
28: import org.overture.ast.definitions.PDefinition;
29: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
30:
31: public class PDefinitionSet extends HashSet<PDefinition>
32: {
33:
34:         /**
35:          *
36:          */
37:         private static final long serialVersionUID = 2315113629324204849L;
38:
39:         protected ITypeCheckerAssistantFactory af;
40:
41:         public PDefinitionSet(ITypeCheckerAssistantFactory af)
42:         {
43:                 this.af = af;
44:         }
45:
46:         @Override
47:         public boolean add(PDefinition e)
48:         {
49:•                if (!contains(e))
50:                 {
51:                         return super.add(e);
52:                 }
53:
54:                 return false;
55:         }
56:
57:         @Override
58:         public boolean contains(Object o)
59:         {
60:•                for (PDefinition def : this)
61:                 {
62:•                        if (af.createPDefinitionAssistant().equals(def, o))
63:                         {
64:                                 return true;
65:                         }
66:                 }
67:
68:                 return false;
69:         }
70:
71:         public List<PDefinition> asList()
72:         {
73:                 List<PDefinition> list = new Vector<PDefinition>();
74:                 list.addAll(this);
75:                 return list;
76:         }
77: }