Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TeeTime-Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nelson Tavares de Sousa
TeeTime-Framework
Commits
94015a19
Commit
94015a19
authored
10 years ago
by
Nils Christian Ehmke
Browse files
Options
Downloads
Patches
Plain Diff
Modifications for performance reasons
parent
4591ba39
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/teetime/stage/MultipleInstanceOfFilter.java
+11
-2
11 additions, 2 deletions
src/main/java/teetime/stage/MultipleInstanceOfFilter.java
with
11 additions
and
2 deletions
src/main/java/teetime/stage/MultipleInstanceOfFilter.java
+
11
−
2
View file @
94015a19
...
@@ -13,6 +13,7 @@ import teetime.framework.OutputPort;
...
@@ -13,6 +13,7 @@ import teetime.framework.OutputPort;
public
final
class
MultipleInstanceOfFilter
<
I
>
extends
AbstractConsumerStage
<
I
>
{
public
final
class
MultipleInstanceOfFilter
<
I
>
extends
AbstractConsumerStage
<
I
>
{
private
final
Map
<
Class
<?
extends
I
>,
OutputPort
<?
super
I
>>
outputPortsMap
=
new
HashMap
<
Class
<?
extends
I
>,
OutputPort
<?
super
I
>>();
private
final
Map
<
Class
<?
extends
I
>,
OutputPort
<?
super
I
>>
outputPortsMap
=
new
HashMap
<
Class
<?
extends
I
>,
OutputPort
<?
super
I
>>();
private
Entry
<
Class
<?
extends
I
>,
OutputPort
<?
super
I
>>[]
cachedOutputPortsMap
;
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
<
T
extends
I
>
OutputPort
<
T
>
getOutputPortForType
(
final
Class
<
T
>
clazz
)
{
public
<
T
extends
I
>
OutputPort
<
T
>
getOutputPortForType
(
final
Class
<
T
>
clazz
)
{
...
@@ -22,13 +23,21 @@ public final class MultipleInstanceOfFilter<I> extends AbstractConsumerStage<I>
...
@@ -22,13 +23,21 @@ public final class MultipleInstanceOfFilter<I> extends AbstractConsumerStage<I>
return
(
OutputPort
<
T
>)
this
.
outputPortsMap
.
get
(
clazz
);
return
(
OutputPort
<
T
>)
this
.
outputPortsMap
.
get
(
clazz
);
}
}
@Override
@SuppressWarnings
(
"unchecked"
)
public
void
onStarting
()
throws
Exception
{
super
.
onStarting
();
// We cache the map to avoid the creating of iterators during runtime
cachedOutputPortsMap
=
(
Entry
<
Class
<?
extends
I
>,
OutputPort
<?
super
I
>>[])
outputPortsMap
.
entrySet
().
toArray
(
new
Entry
<?,
?>[
outputPortsMap
.
size
()]);
}
@Override
@Override
protected
void
execute
(
final
I
element
)
{
protected
void
execute
(
final
I
element
)
{
for
(
Entry
<
Class
<?
extends
I
>,
OutputPort
<?
super
I
>>
outputPortMapEntry
:
o
utputPortsMap
.
entrySet
()
)
{
for
(
Entry
<
Class
<?
extends
I
>,
OutputPort
<?
super
I
>>
outputPortMapEntry
:
cachedO
utputPortsMap
)
{
if
(
outputPortMapEntry
.
getKey
().
isInstance
(
element
))
{
if
(
outputPortMapEntry
.
getKey
().
isInstance
(
element
))
{
outputPortMapEntry
.
getValue
().
send
(
element
);
outputPortMapEntry
.
getValue
().
send
(
element
);
}
}
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment