Skip to content

Commit

Permalink
new abstraction: symbol sets
Browse files Browse the repository at this point in the history
  • Loading branch information
eric.bodden committed Jul 31, 2012
1 parent 89a321e commit 8ec15fd
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,7 @@ protected AbstractionBySizeAndSymbols(int size, Set<ISymbol<L, K>> symbols) {
this.size = size;
this.symbols = symbols;
}

public int getSize() {
return size;
}

public Set<ISymbol<L, K>> getSymbols() {
return symbols;
}


@Override
public String toString() {
return "("+size+","+symbols+")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ protected AbstractionBySize(int size) {
this.size = size;
}

public int getSize() {
return size;
}

@Override
public String toString() {
return Integer.toString(size);
Expand Down
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;
}
}
}

0 comments on commit 8ec15fd

Please sign in to comment.