Skip to content
This repository was archived by the owner on Mar 25, 2019. It is now read-only.

Commit 02924b9

Browse files
elmotIlia Motornyi
authored and
Ilia Motornyi
committed
Fix incorrect reading of ResetType
1 parent 841a6ec commit 02924b9

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

src/xyz/elmot/clion/openocd/OpenOcdConfiguration.java

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,37 +53,27 @@ public static String toBeautyString(String obj) {
5353
}
5454

5555
public enum ResetType {
56-
RUN {
57-
@Override
58-
public String getCommand() {
59-
return "init;reset run;";
60-
}
61-
},
62-
INIT {
63-
@Override
64-
public String getCommand() {
65-
return "init;reset init;";
66-
}
67-
},
68-
HALT {
69-
@Override
70-
public String getCommand() {
71-
return "init;reset halt";
72-
}
73-
},
74-
NONE {
75-
@Override
76-
public String getCommand() {
77-
return "";
78-
}
79-
};
56+
RUN("init;reset run;"),
57+
INIT("init;reset init;"),
58+
HALT("init;reset halt"),
59+
NONE("");
8060

8161
@Override
8262
public String toString() {
8363
return toBeautyString(super.toString());
8464
}
8565

86-
public abstract String getCommand();
66+
ResetType(String command) {
67+
this.command = command;
68+
}
69+
70+
private final String command;
71+
72+
public final String getCommand() {
73+
return command;
74+
}
75+
76+
;
8777

8878
}
8979

@@ -120,7 +110,7 @@ private <T extends Enum> T readEnumAttr(@NotNull Element element, String name, T
120110
if (StringUtil.isEmpty(s)) return def;
121111
try {
122112
//noinspection unchecked
123-
return (T) Enum.valueOf(def.getClass(), s);
113+
return (T) Enum.valueOf(def.getDeclaringClass(), s);
124114
} catch (Throwable t) {
125115
return def;
126116
}

0 commit comments

Comments
 (0)