Skip to content

Commit

Permalink
refactor: 移除不必要的方法及属性
Browse files Browse the repository at this point in the history
  • Loading branch information
toggery committed Aug 22, 2022
1 parent 155c1ee commit d07db1c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 47 deletions.
12 changes: 4 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ plugins {
}

group = 'io.github.toggery'
version = '2.0.0'
version = '2.0.1'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

repositories {
mavenCentral()
}

ext {
jt808MessageBodyVersion = '2.0.0'
nettyVersion = '4.1.78.Final'
jupiterVersion = '5.8.2'
jt808MessageBodyVersion = '2.0.1'
nettyVersion = '4.1.79.Final'
jupiterVersion = '5.9.0'
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/toggery/jt808/codec/B0702Codec.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void encode(int version, ByteBuf buf, B0702 target) {
}

Codec.writeByte(buf, target.getResult());
if (!target.isSuccessful()) {
if (target.getResult() != B0702.RESULT_SUCCESSFUL) {
return;
}

Expand Down Expand Up @@ -56,7 +56,7 @@ public void decode(int version, ByteBuf buf, B0702 target) {
}

target.setResult(Codec.readByte(buf));
if (!target.isSuccessful()) {
if (target.getResult() != B0702.RESULT_SUCCESSFUL) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/toggery/jt808/codec/B0805Codec.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private B0805Codec() {}
public void encode(int version, ByteBuf buf, B0805 target) {
Codec.writeWord(buf, target.getReplySn());
Codec.writeByte(buf, target.getResult());
if (!target.isSuccessful()) {
if (target.getResult() != B0805.RESULT_SUCCESSFUL) {
return;
}

Expand All @@ -44,7 +44,7 @@ public void decode(int version, ByteBuf buf, B0805 target) {

target.setReplySn(Codec.readWord(buf));
target.setResult(Codec.readByte(buf));
if (!target.isSuccessful()) {
if (target.getResult() != B0805.RESULT_SUCCESSFUL) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/toggery/jt808/codec/B8100Codec.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private B8100Codec() {}
public void encode(int version, ByteBuf buf, B8100 target) {
Codec.writeWord(buf, target.getReplySn());
Codec.writeByte(buf, target.getResult());
if (target.isSuccessful()) {
if (target.getResult() == B8100.RESULT_SUCCESSFUL) {
Codec.writeString(buf, target.getToken());
}
}
Expand All @@ -28,7 +28,7 @@ public void encode(int version, ByteBuf buf, B8100 target) {
public void decode(int version, ByteBuf buf, B8100 target) {
target.setReplySn(Codec.readWord(buf));
target.setResult(Codec.readByte(buf));
target.setToken(target.isSuccessful() ? Codec.readString(buf) : null);
target.setToken(target.getResult() == B8100.RESULT_SUCCESSFUL ? Codec.readString(buf) : null);
}

@Override
Expand Down
33 changes: 0 additions & 33 deletions src/test/java/io/github/toggery/jt808/codec/MessageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ static B8001 b8001() {
b.setReplySn(1);
b.setReplyId(2);
b.setResult(B8001.RESULT_UNSUPPORTED);
b.setTerminalInfo(new MyTerminalInfo());

return b;
}
Expand Down Expand Up @@ -915,36 +914,4 @@ static void fillB8103(B8103 b) {
b.setX0110(new byte[]{1,2,3,4,5,6,7,8});
}

static class MyTerminalInfo extends AbstractToStringJoiner implements TerminalInfo {
@Override
protected void toStringJoiner(StringJoiner joiner) {
joiner
.add("simNo=" + getSimNo())
.add("model=" + getModel())
.add("group=" + getGroup())
.add(String.format("idleTime=%,ds", getIdleTime()))
;
}

@Override
public String getSimNo() {
return "18912345678";
}

@Override
public String getModel() {
return "unknown";
}

@Override
public String getGroup() {
return "togger";
}

@Override
public int getIdleTime() {
return 3600;
}
}

}

0 comments on commit d07db1c

Please sign in to comment.