move interface to primitive types

This commit is contained in:
Eyck Jentzsch 2021-02-27 13:59:00 +00:00
parent 182a036ade
commit b6963f38d6
25 changed files with 53 additions and 54 deletions

View File

@ -90,7 +90,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
protected abstract Map<Integer, ITx> getTransactions(); protected abstract Map<Integer, ITx> getTransactions();
@Override @Override
public IEvent[] getEventsAtTime(Long time) { public IEvent[] getEventsAtTime(long time) {
return getEvents().get(time); return getEvents().get(time);
} }
@ -105,7 +105,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
} }
@Override @Override
public IEvent[] getEventsBeforeTime(Long time) { public IEvent[] getEventsBeforeTime(long time) {
EventEntry e = events.floorEntry(time); EventEntry e = events.floorEntry(time);
if(e==null) if(e==null)
return new IEvent[]{}; return new IEvent[]{};

View File

@ -48,7 +48,7 @@ public class SQLiteDbLoader implements IWaveformDbLoader {
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this); protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
@Override @Override
public Long getMaxTime() { public long getMaxTime() {
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class, SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
database, "time = (SELECT MAX(time) FROM ScvTxEvent)"); database, "time = (SELECT MAX(time) FROM ScvTxEvent)");
try { try {

View File

@ -37,8 +37,8 @@ public class Tx implements ITx {
private TxGenerator trGenerator; private TxGenerator trGenerator;
private ScvTx scvTx; private ScvTx scvTx;
private List<ITxAttribute> attributes; private List<ITxAttribute> attributes;
private Long begin; private long begin=-1;
private Long end; private long end=-1;
private List<ITxRelation> incoming; private List<ITxRelation> incoming;
private List<ITxRelation> outgoing; private List<ITxRelation> outgoing;
@ -50,7 +50,7 @@ public class Tx implements ITx {
} }
@Override @Override
public Long getId() { public long getId() {
return (long) scvTx.getId(); return (long) scvTx.getId();
} }
@ -69,8 +69,8 @@ public class Tx implements ITx {
} }
@Override @Override
public Long getBeginTime() { public long getBeginTime() {
if(begin==null){ if(begin<0){
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class, SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
database, "tx="+scvTx.getId()+" AND type="+ AssociationType.BEGIN.ordinal()); database, "tx="+scvTx.getId()+" AND type="+ AssociationType.BEGIN.ordinal());
try { try {
@ -85,8 +85,8 @@ public class Tx implements ITx {
} }
@Override @Override
public Long getEndTime() { public long getEndTime() {
if(end==null){ if(end<0){
SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class, SQLiteDatabaseSelectHandler<ScvTxEvent> handler = new SQLiteDatabaseSelectHandler<>(ScvTxEvent.class,
database, "tx="+scvTx.getId()+" AND type="+ AssociationType.END.ordinal()); database, "tx="+scvTx.getId()+" AND type="+ AssociationType.END.ordinal());
try { try {
@ -178,11 +178,11 @@ public class Tx implements ITx {
@Override @Override
public int compareTo(ITx o) { public int compareTo(ITx o) {
int res = this.getBeginTime().compareTo(o.getBeginTime()); int res = Long.compare(this.getBeginTime(), o.getBeginTime());
if(res!=0) if(res!=0)
return res; return res;
else else
return this.getId().compareTo(o.getId()); return Long.compare(this.getId(), o.getId());
} }
@Override @Override

View File

@ -28,7 +28,7 @@ public class TxEvent implements ITxEvent {
} }
@Override @Override
public Long getTime() { public long getTime() {
return type==EventKind.BEGIN?tx.getBeginTime():tx.getEndTime(); return type==EventKind.BEGIN?tx.getBeginTime():tx.getEndTime();
} }

View File

@ -39,7 +39,7 @@ public class TxGenerator extends AbstractTxStream {
} }
@Override @Override
public Long getId() { public long getId() {
return (long) scvGenerator.getId(); return (long) scvGenerator.getId();
} }
@ -50,7 +50,7 @@ public class TxGenerator extends AbstractTxStream {
@Override @Override
public boolean isSame(IWaveform other) { public boolean isSame(IWaveform other) {
return(other instanceof TxGenerator && this.getId().equals(other.getId())); return(other instanceof TxGenerator && this.getId() == other.getId());
} }
@Override @Override

View File

@ -49,7 +49,7 @@ public class TxStream extends AbstractTxStream {
} }
@Override @Override
public Long getId() { public long getId() {
return (long) scvStream.getId(); return (long) scvStream.getId();
} }
@ -89,13 +89,13 @@ public class TxStream extends AbstractTxStream {
} }
@Override @Override
public IEvent[] getEventsAtTime(Long time) { public IEvent[] getEventsAtTime(long time) {
return getEvents().get(time); return getEvents().get(time);
} }
@Override @Override
public boolean isSame(IWaveform other) { public boolean isSame(IWaveform other) {
return(other instanceof TxStream && this.getId().equals(other.getId())); return(other instanceof TxStream && this.getId() == other.getId());
} }
@Override @Override

View File

@ -93,7 +93,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
* @return the events at time * @return the events at time
*/ */
@Override @Override
public IEvent[] getEventsAtTime(Long time) { public IEvent[] getEventsAtTime(long time) {
return events.get(time); return events.get(time);
} }
@ -104,7 +104,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
* @return the events before time * @return the events before time
*/ */
@Override @Override
public IEvent[] getEventsBeforeTime(Long time) { public IEvent[] getEventsBeforeTime(long time) {
EventEntry e = events.floorEntry(time); EventEntry e = events.floorEntry(time);
if (e == null) if (e == null)
return new IEvent[] {}; return new IEvent[] {};
@ -128,7 +128,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
* @return the id * @return the id
*/ */
@Override @Override
public Long getId() { public long getId() {
return id; return id;
} }

View File

@ -131,7 +131,7 @@ public class TextDbLoader implements IWaveformDbLoader {
* @return the max time * @return the max time
*/ */
@Override @Override
public Long getMaxTime() { public long getMaxTime() {
return maxTime; return maxTime;
} }

View File

@ -102,11 +102,11 @@ class Tx implements ITx {
*/ */
@Override @Override
public int compareTo(ITx o) { public int compareTo(ITx o) {
int res = getBeginTime().compareTo(o.getBeginTime()); int res = Long.compare(getBeginTime(), o.getBeginTime());
if (res != 0) if (res != 0)
return res; return res;
else else
return getId().compareTo(o.getId()); return Long.compare(getId(), o.getId());
} }
/** /**
@ -150,7 +150,7 @@ class Tx implements ITx {
* @return the id * @return the id
*/ */
@Override @Override
public Long getId() { public long getId() {
return getScvTx().id; return getScvTx().id;
} }
@ -180,7 +180,7 @@ class Tx implements ITx {
* @return the begin time * @return the begin time
*/ */
@Override @Override
public Long getBeginTime() { public long getBeginTime() {
if (beginTime < 0) { if (beginTime < 0) {
ScvTx tx = scvTx==null?loader.getScvTx(id):getScvTx(); ScvTx tx = scvTx==null?loader.getScvTx(id):getScvTx();
beginTime = tx.beginTime; beginTime = tx.beginTime;
@ -195,7 +195,7 @@ class Tx implements ITx {
* @return the end time * @return the end time
*/ */
@Override @Override
public Long getEndTime() { public long getEndTime() {
if (endTime < 0) { if (endTime < 0) {
ScvTx tx = scvTx==null?loader.getScvTx(id):getScvTx(); ScvTx tx = scvTx==null?loader.getScvTx(id):getScvTx();
beginTime = tx.beginTime; beginTime = tx.beginTime;

View File

@ -95,7 +95,7 @@ class TxEvent implements ITxEvent {
* @return the time * @return the time
*/ */
@Override @Override
public Long getTime() { public long getTime() {
return time; return time;
} }

View File

@ -52,7 +52,7 @@ class TxGenerator extends AbstractTxStream {
*/ */
@Override @Override
public boolean isSame(IWaveform other) { public boolean isSame(IWaveform other) {
return (other instanceof TxGenerator && this.getId().equals(other.getId())); return (other instanceof TxGenerator && this.getId()==other.getId());
} }
/** /**

View File

@ -42,7 +42,7 @@ class TxStream extends AbstractTxStream {
*/ */
@Override @Override
public boolean isSame(IWaveform other) { public boolean isSame(IWaveform other) {
return (other instanceof TxStream && this.getId().equals(other.getId())); return (other instanceof TxStream && this.getId() == other.getId());
} }
/** /**

View File

@ -146,7 +146,7 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
* @see com.minres.scviewer.database.ITrDb#getMaxTime() * @see com.minres.scviewer.database.ITrDb#getMaxTime()
*/ */
@Override @Override
public Long getMaxTime() { public long getMaxTime() {
return maxTime; return maxTime;
} }

View File

@ -62,7 +62,7 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
} }
@Override @Override
public Long getId() { public long getId() {
return id; return id;
} }
@ -76,12 +76,12 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
} }
@Override @Override
public IEvent[] getEventsAtTime(Long time) { public IEvent[] getEventsAtTime(long time) {
return values.get(time); return values.get(time);
} }
@Override @Override
public IEvent[] getEventsBeforeTime(Long time) { public IEvent[] getEventsBeforeTime(long time) {
EventEntry e = values.floorEntry(time); EventEntry e = values.floorEntry(time);
if(e==null) if(e==null)
return new IEvent[] {}; return new IEvent[] {};
@ -91,7 +91,7 @@ public class VCDSignal<T extends IEvent> extends HierNode implements IWaveform {
@Override @Override
public boolean isSame(IWaveform other) { public boolean isSame(IWaveform other) {
return( other instanceof VCDSignal<?> && this.getId().equals(other.getId())); return( other instanceof VCDSignal<?> && this.getId() == other.getId());
} }
@Override @Override

View File

@ -1,7 +1,6 @@
package com.minres.scviewer.database; package com.minres.scviewer.database;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;

View File

@ -24,7 +24,7 @@ public interface IWaveform extends IHierNode {
* *
* @return the id * @return the id
*/ */
public Long getId(); public long getId();
/** /**
* Checks if is same. * Checks if is same.
@ -47,7 +47,7 @@ public interface IWaveform extends IHierNode {
* @param time the time * @param time the time
* @return the events at time * @return the events at time
*/ */
public IEvent[] getEventsAtTime(Long time); public IEvent[] getEventsAtTime(long time);
/** /**
* Gets the events before time. * Gets the events before time.
@ -55,7 +55,7 @@ public interface IWaveform extends IHierNode {
* @param time the time * @param time the time
* @return the events before time * @return the events before time
*/ */
public IEvent[] getEventsBeforeTime(Long time); public IEvent[] getEventsBeforeTime(long time);
/** /**
* Gets the type. * Gets the type.

View File

@ -23,7 +23,7 @@ public interface IWaveformDb extends IHierNode {
* *
* @return the max time * @return the max time
*/ */
public Long getMaxTime(); public long getMaxTime();
/** /**
* Gets the stream by name. * Gets the stream by name.

View File

@ -69,7 +69,7 @@ public interface IWaveformDbLoader {
* *
* @return the max time * @return the max time
*/ */
public Long getMaxTime(); public long getMaxTime();
/** /**
* Gets the all waves. * Gets the all waves.

View File

@ -45,7 +45,7 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL
private Map<String, IWaveform> waveforms; private Map<String, IWaveform> waveforms;
/** The max time. */ /** The max time. */
private Long maxTime; private long maxTime = -1;
/** /**
* Bind. * Bind.
@ -90,7 +90,7 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL
* @return the max time * @return the max time
*/ */
@Override @Override
public Long getMaxTime() { public long getMaxTime() {
return maxTime; return maxTime;
} }

View File

@ -25,7 +25,7 @@ public interface ITx extends Comparable<ITx> {
* *
* @return the id * @return the id
*/ */
public Long getId(); public long getId();
/** /**
* Gets the stream. * Gets the stream.
@ -46,14 +46,14 @@ public interface ITx extends Comparable<ITx> {
* *
* @return the begin time * @return the begin time
*/ */
public Long getBeginTime(); public long getBeginTime();
/** /**
* Gets the end time. * Gets the end time.
* *
* @return the end time * @return the end time
*/ */
public Long getEndTime(); public long getEndTime();
/** /**
* Gets the attributes. * Gets the attributes.

View File

@ -22,7 +22,7 @@ public interface ITxEvent extends IEvent {
* *
* @return the time * @return the time
*/ */
public Long getTime(); public long getTime();
/** /**
* Gets the transaction. * Gets the transaction.

View File

@ -260,7 +260,7 @@ public class TransactionList extends Composite {
tx.getAttributes().forEach(attr -> propNames.put(attr.getName(), attr.getDataType())); tx.getAttributes().forEach(attr -> propNames.put(attr.getName(), attr.getDataType()));
return tx; return tx;
}) })
.sorted((t1, t2)-> t1.getBeginTime().compareTo(t2.getBeginTime())) .sorted((t1, t2)-> Long.compare(t1.getBeginTime(),t2.getBeginTime()))
.collect(Collectors.toList()); .collect(Collectors.toList());
final List<AttributeNameBean> newAttrNames=propNames.entrySet().stream() final List<AttributeNameBean> newAttrNames=propNames.entrySet().stream()
.sorted((e1,e2)->e1.getKey().compareTo(e2.getKey())) .sorted((e1,e2)->e1.getKey().compareTo(e2.getKey()))

View File

@ -69,7 +69,7 @@ public class AttributeLabelProvider extends LabelProvider implements IStyledLabe
ITx iTx = (ITx) element; ITx iTx = (ITx) element;
switch(field){ switch(field){
case NAME: case NAME:
return new StyledString(iTx.getId().toString()); return new StyledString(String.format("%d", iTx.getId()));
case TX_TIME: case TX_TIME:
return new StyledString(waveformViewerPart.getScaledTime(iTx.getBeginTime())); return new StyledString(waveformViewerPart.getScaledTime(iTx.getBeginTime()));
case TYPE: case TYPE:

View File

@ -182,9 +182,9 @@ public class RelatedProperty extends AbstractPropertySection implements ISelecti
else if (columnIndex == 2 && element instanceof ITxRelation){ else if (columnIndex == 2 && element instanceof ITxRelation){
ITxRelation rel = (ITxRelation) element; ITxRelation rel = (ITxRelation) element;
if(rel.getTarget()==iTr) if(rel.getTarget()==iTr)
return ((ITxRelation) element).getSource().getId().toString(); return String.format("%d", ((ITxRelation) element).getSource().getId());
else else
return ((ITxRelation) element).getTarget().getId().toString(); return String.format("%d", ((ITxRelation) element).getTarget().getId());
} }
else else
return null; return null;

View File

@ -76,11 +76,11 @@ public class DatabaseServicesTest {
assertEquals(3, waveforms.size()); assertEquals(3, waveforms.size());
assertEquals(1, waveformDb.getChildNodes().size()); assertEquals(1, waveformDb.getChildNodes().size());
for(IWaveform w:waveforms) { for(IWaveform w:waveforms) {
if(w.getId().equals(1l)) { if(w.getId()==1) {
assertEquals(2, w.getRowCount()); assertEquals(2, w.getRowCount());
} else if(w.getId().equals(2l)) { } else if(w.getId()==2l) {
assertEquals(1, w.getRowCount()); assertEquals(1, w.getRowCount());
} else if(w.getId().equals(3l)) { } else if(w.getId()==3l) {
assertEquals(1, w.getRowCount()); assertEquals(1, w.getRowCount());
} }
} }