Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
API
Commits
4418a90d
Commit
4418a90d
authored
Dec 17, 2015
by
Alexander Frömmgen
Browse files
Tossa reverse VariableAssignment
parent
badf8c71
Changes
2
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
4418a90d
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<properties>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
</properties>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
maki
</groupId>
<groupId>
maki
</groupId>
<artifactId>
simonstrator-api
</artifactId>
<artifactId>
simonstrator-api
</artifactId>
<version>
2.4
</version>
<version>
2.4
</version>
<name>
Simonstrator-API
</name>
<name>
Simonstrator-API
</name>
<build>
<build>
<sourceDirectory>
src
</sourceDirectory>
<sourceDirectory>
src
</sourceDirectory>
<resources>
<resources>
<resource>
<resource>
<directory>
src
</directory>
<directory>
src
</directory>
<excludes>
<excludes>
<exclude>
**/*.java
</exclude>
<exclude>
**/*.java
</exclude>
</excludes>
</excludes>
</resource>
</resource>
</resources>
</resources>
<plugins>
<plugins>
<plugin>
<plugin>
<artifactId>
maven-compiler-plugin
</artifactId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.1
</version>
<version>
3.1
</version>
<configuration>
<configuration>
<source>
1.7
</source>
<source>
1.7
</source>
<target>
1.7
</target>
<target>
1.7
</target>
</configuration>
</configuration>
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
<repositories>
<repositories>
<!-- uk maven central, since the local central server is slow as hell -->
<!-- uk maven central, since the local central server is slow as hell -->
<repository>
<repository>
<id>
uk.maven.org
</id>
<id>
uk.maven.org
</id>
<url>
http://uk.maven.org/maven2
</url>
<url>
http://uk.maven.org/maven2
</url>
</repository>
</repository>
<!-- simonstrator-repository -->
<!-- simonstrator-repository -->
<repository>
<repository>
<id>
simonstrator
</id>
<id>
simonstrator
</id>
<url>
https://dev.kom.e-technik.tu-darmstadt.de/mvn/
</url>
<url>
https://dev.kom.e-technik.tu-darmstadt.de/mvn/
</url>
</repository>
</repository>
</repositories>
</repositories>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
com.esotericsoftware
</groupId>
<groupId>
com.esotericsoftware
</groupId>
<artifactId>
kryonet
</artifactId>
<artifactId>
kryonet
</artifactId>
<version>
2.22.0-RC1
</version>
<version>
2.22.0-RC1
</version>
</dependency>
</dependency>
</dependencies>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
18.0
</version>
</dependency>
</dependencies>
</project>
</project>
\ No newline at end of file
src/de/tudarmstadt/maki/simonstrator/api/component/topology/VariableAssignment.java
View file @
4418a90d
package
de.tudarmstadt.maki.simonstrator.api.component.topology
;
package
de.tudarmstadt.maki.simonstrator.api.component.topology
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
de.tudarmstadt.maki.simonstrator.api.common.UniqueID
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.EdgeID
;
import
com.google.common.collect.BiMap
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.IElement
;
import
com.google.common.collect.HashBiMap
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID
;
import
de.tudarmstadt.maki.simonstrator.api.common.UniqueID
;
/**
import
de.tudarmstadt.maki.simonstrator.api.common.graph.EdgeID
;
* This class represents a binding of pattern variables to graph elements
import
de.tudarmstadt.maki.simonstrator.api.common.graph.IElement
;
*/
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID
;
public
final
class
VariableAssignment
{
/**
private
final
Map
<
INodeID
,
INodeID
>
nodeBinding
;
* This class represents a binding of pattern variables to graph elements
private
final
Map
<
EdgeID
,
EdgeID
>
linkBinding
;
*/
public
final
class
VariableAssignment
{
public
VariableAssignment
()
{
this
.
nodeBinding
=
new
HashMap
<>();
private
final
BiMap
<
INodeID
,
INodeID
>
nodeBinding
;
this
.
linkBinding
=
new
HashMap
<>();
private
final
Map
<
EdgeID
,
EdgeID
>
linkBinding
;
}
public
VariableAssignment
()
{
public
VariableAssignment
(
final
VariableAssignment
other
)
{
this
.
nodeBinding
=
HashBiMap
.
create
();
this
();
this
.
linkBinding
=
new
HashMap
<>();
this
.
nodeBinding
.
putAll
(
other
.
nodeBinding
);
}
this
.
linkBinding
.
putAll
(
other
.
linkBinding
);
}
public
VariableAssignment
(
final
VariableAssignment
other
)
{
this
();
public
INodeID
getNodeVariableBinding
(
final
INodeID
variable
)
{
this
.
nodeBinding
.
putAll
(
other
.
nodeBinding
);
return
this
.
nodeBinding
.
get
(
variable
);
this
.
linkBinding
.
putAll
(
other
.
linkBinding
);
}
}
public
INodeID
getNodeVariableBinding
(
final
String
key
)
{
public
INodeID
getNodeVariableBinding
(
final
INodeID
variable
)
{
return
nodeBinding
.
get
(
INodeID
.
get
(
key
));
return
this
.
nodeBinding
.
get
(
variable
);
}
}
public
void
bindVariable
(
UniqueID
variable
,
IElement
candidate
)
{
public
INodeID
getInverseVariableBinding
(
final
INodeID
variable
)
{
if
(
variable
instanceof
INodeID
)
{
return
this
.
nodeBinding
.
inverse
().
get
(
variable
);
this
.
bindNodeVariable
((
INodeID
)
variable
,
(
INodeID
)
candidate
);
}
}
else
if
(
variable
instanceof
EdgeID
)
{
this
.
bindLinkVariable
((
EdgeID
)
variable
,
(
EdgeID
)
candidate
);
public
INodeID
getNodeVariableBinding
(
final
String
key
)
{
}
else
{
return
nodeBinding
.
get
(
INodeID
.
get
(
key
));
throw
new
IllegalArgumentException
(
"Cannot handle variable type: "
+
variable
);
}
}
}
public
Set
<
Map
.
Entry
<
INodeID
,
INodeID
>>
getNodeBindingEntrySet
()
{
return
nodeBinding
.
entrySet
();
public
void
bindNodeVariable
(
final
INodeID
nodeVariable
,
final
INodeID
value
)
{
}
nodeBinding
.
put
(
nodeVariable
,
value
);
}
public
void
bindVariable
(
UniqueID
variable
,
IElement
candidate
)
{
if
(
variable
instanceof
INodeID
)
{
public
void
unbindNodeVariable
(
final
INodeID
nodeVariable
)
{
this
.
bindNodeVariable
((
INodeID
)
variable
,
(
INodeID
)
candidate
);
nodeBinding
.
remove
(
nodeVariable
);
}
else
if
(
variable
instanceof
EdgeID
)
{
}
this
.
bindLinkVariable
((
EdgeID
)
variable
,
(
EdgeID
)
candidate
);
}
else
{
public
boolean
isBound
(
final
INodeID
variable
)
{
throw
new
IllegalArgumentException
(
"Cannot handle variable type: "
+
variable
);
return
nodeBinding
.
containsKey
(
variable
);
}
}
}
public
boolean
isUnbound
(
final
INodeID
variable
)
{
public
void
bindNodeVariable
(
final
INodeID
nodeVariable
,
final
INodeID
value
)
{
return
!
this
.
isBound
(
variable
);
nodeBinding
.
put
(
nodeVariable
,
value
);
}
}
/**
public
void
unbindNodeVariable
(
final
INodeID
nodeVariable
)
{
* Returns whether there exists some variable that is bound by the given
nodeBinding
.
remove
(
nodeVariable
);
* nodeId.
}
*/
public
boolean
isBindingForSomeVariable
(
final
INodeID
bindingValue
)
{
public
boolean
isBound
(
final
INodeID
variable
)
{
return
nodeBinding
.
containsValue
(
bindingValue
);
return
nodeBinding
.
containsKey
(
variable
);
}
}
public
EdgeID
getLinkVariableBinding
(
final
EdgeID
edgeVariable
)
{
public
boolean
isUnbound
(
final
INodeID
variable
)
{
return
this
.
getLinkVariableBinding
(
edgeVariable
);
return
!
this
.
isBound
(
variable
);
}
}
public
EdgeID
getLinkVariableBinding
(
final
String
linkVariableId
)
{
/**
return
this
.
linkBinding
.
get
(
EdgeID
.
get
(
linkVariableId
));
* Returns whether there exists some variable that is bound by the given
}
* nodeId.
*/
public
void
bindLinkVariable
(
final
EdgeID
linkVariable
,
final
EdgeID
edge
)
{
public
boolean
isBindingForSomeVariable
(
final
INodeID
bindingValue
)
{
this
.
linkBinding
.
put
(
linkVariable
,
edge
);
return
nodeBinding
.
containsValue
(
bindingValue
);
}
}
public
void
removeAllLinkBindings
()
{
public
EdgeID
getLinkVariableBinding
(
final
EdgeID
edgeVariable
)
{
this
.
linkBinding
.
clear
();
return
this
.
getLinkVariableBinding
(
edgeVariable
);
}
}
@Override
public
EdgeID
getLinkVariableBinding
(
final
String
linkVariableId
)
{
public
int
hashCode
()
{
return
this
.
linkBinding
.
get
(
EdgeID
.
get
(
linkVariableId
));
final
int
prime
=
31
;
}
int
result
=
1
;
result
=
prime
*
result
+
((
linkBinding
==
null
)
?
0
:
linkBinding
.
hashCode
());
public
void
bindLinkVariable
(
final
EdgeID
linkVariable
,
final
EdgeID
edge
)
{
result
=
prime
*
result
+
((
nodeBinding
==
null
)
?
0
:
nodeBinding
.
hashCode
());
this
.
linkBinding
.
put
(
linkVariable
,
edge
);
return
result
;
}
}
public
void
removeAllLinkBindings
()
{
@Override
this
.
linkBinding
.
clear
();
public
boolean
equals
(
final
Object
obj
)
{
}
if
(
this
==
obj
)
{
return
true
;
@Override
}
public
int
hashCode
()
{
if
(
obj
==
null
)
{
final
int
prime
=
31
;
return
false
;
int
result
=
1
;
}
result
=
prime
*
result
+
((
linkBinding
==
null
)
?
0
:
linkBinding
.
hashCode
());
if
(
getClass
()
!=
obj
.
getClass
())
{
result
=
prime
*
result
+
((
nodeBinding
==
null
)
?
0
:
nodeBinding
.
hashCode
());
return
false
;
return
result
;
}
}
final
VariableAssignment
other
=
(
VariableAssignment
)
obj
;
if
(
linkBinding
==
null
)
{
@Override
if
(
other
.
linkBinding
!=
null
)
{
public
boolean
equals
(
final
Object
obj
)
{
return
false
;
if
(
this
==
obj
)
{
}
return
true
;
}
else
if
(!
linkBinding
.
equals
(
other
.
linkBinding
))
{
}
return
false
;
if
(
obj
==
null
)
{
}
return
false
;
if
(
nodeBinding
==
null
)
{
}
if
(
other
.
nodeBinding
!=
null
)
{
if
(
getClass
()
!=
obj
.
getClass
())
{
return
false
;
return
false
;
}
}
}
else
if
(!
nodeBinding
.
equals
(
other
.
nodeBinding
))
{
final
VariableAssignment
other
=
(
VariableAssignment
)
obj
;
return
false
;
if
(
linkBinding
==
null
)
{
}
if
(
other
.
linkBinding
!=
null
)
{
return
true
;
return
false
;
}
}
}
else
if
(!
linkBinding
.
equals
(
other
.
linkBinding
))
{
@Override
return
false
;
public
String
toString
()
{
}
return
"VariableAssignment [nodeBinding:"
+
this
.
nodeBinding
+
", linkBinding: "
+
this
.
linkBinding
.
toString
()
if
(
nodeBinding
==
null
)
{
+
"]"
;
if
(
other
.
nodeBinding
!=
null
)
{
}
return
false
;
}
}
else
if
(!
nodeBinding
.
equals
(
other
.
nodeBinding
))
{
return
false
;
}
}
return
true
;
}
@Override
public
String
toString
()
{
return
"VariableAssignment [nodeBinding:"
+
this
.
nodeBinding
+
", linkBinding: "
+
this
.
linkBinding
.
toString
()
+
"]"
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment