-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
eric.bodden
committed
Jul 31, 2012
1 parent
89a321e
commit 8ec15fd
Showing
3 changed files
with
66 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
MOPBox/src/de/bodden/mopbox/finitestate/sync/SymbolSetSyncingTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package de.bodden.mopbox.finitestate.sync; | ||
|
||
import java.util.Set; | ||
|
||
import com.google.common.collect.Multiset; | ||
|
||
import de.bodden.mopbox.finitestate.OpenFSMMonitorTemplate; | ||
import de.bodden.mopbox.generic.ISymbol; | ||
|
||
/** | ||
* An {@link AbstractSyncingFSMMonitorTemplate} that models the gap of events missed by the set of symbols that were missed. | ||
*/ | ||
public abstract class SymbolSetSyncingTemplate<L, K, V> | ||
extends AbstractSyncingFSMMonitorTemplate<L, K, V, SymbolSetSyncingTemplate<L,K,V>.AbstractionBySymbolSet>{ | ||
|
||
public SymbolSetSyncingTemplate(OpenFSMMonitorTemplate<L, K, V> delegate, int max) { | ||
super(delegate, max); | ||
} | ||
|
||
protected AbstractionBySymbolSet abstraction(Multiset<ISymbol<L, K>> symbols) { | ||
return new AbstractionBySymbolSet(symbols.elementSet()); | ||
} | ||
|
||
public class AbstractionBySymbolSet | ||
extends AbstractSyncingFSMMonitorTemplate<L,K,V,AbstractionBySymbolSet>.SymbolMultisetAbstraction { | ||
|
||
private final Set<ISymbol<L, K>> symbols; | ||
|
||
protected AbstractionBySymbolSet(Set<ISymbol<L, K>> symbols) { | ||
this.symbols = symbols; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return symbols.toString(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result | ||
+ ((symbols == null) ? 0 : symbols.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
@SuppressWarnings("unchecked") | ||
AbstractionBySymbolSet other = (AbstractionBySymbolSet) obj; | ||
if (symbols == null) { | ||
if (other.symbols != null) | ||
return false; | ||
} else if (!symbols.equals(other.symbols)) | ||
return false; | ||
return true; | ||
} | ||
} | ||
} |