move interface to primitive types

This commit is contained in:
Eyck Jentzsch 2021-02-27 13:59:00 +00:00
parent b7301733f0
commit 45c1396e0e
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();
@Override
public IEvent[] getEventsAtTime(Long time) {
public IEvent[] getEventsAtTime(long time) {
return getEvents().get(time);
}
@ -105,7 +105,7 @@ abstract class AbstractTxStream extends HierNode implements IWaveform {
}
@Override
public IEvent[] getEventsBeforeTime(Long time) {
public IEvent[] getEventsBeforeTime(long time) {
EventEntry e = events.floorEntry(time);
if(e==null)
return new IEvent[]{};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -52,7 +52,7 @@ class TxGenerator extends AbstractTxStream {
*/
@Override
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
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()
*/
@Override
public Long getMaxTime() {
public long getMaxTime() {
return maxTime;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -260,7 +260,7 @@ public class TransactionList extends Composite {
tx.getAttributes().forEach(attr -> propNames.put(attr.getName(), attr.getDataType()));
return tx;
})
.sorted((t1, t2)-> t1.getBeginTime().compareTo(t2.getBeginTime()))
.sorted((t1, t2)-> Long.compare(t1.getBeginTime(),t2.getBeginTime()))
.collect(Collectors.toList());
final List<AttributeNameBean> newAttrNames=propNames.entrySet().stream()
.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;
switch(field){
case NAME:
return new StyledString(iTx.getId().toString());
return new StyledString(String.format("%d", iTx.getId()));
case TX_TIME:
return new StyledString(waveformViewerPart.getScaledTime(iTx.getBeginTime()));
case TYPE:

View File

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

View File

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