Markdown-Resource Java Conversion

I am working on adding a project resource to a module in Java, and working backwards from the Markdown resource project example

I am struggling in my conversion of the resource itself from:

Kotlin

data class MarkdownResource(val note: String) {
    companion object {
        val RESOURCE_TYPE = ResourceType(MODULE_ID, TYPE_ID)
        const val DATA_KEY = "note.md"
    }
}

And currently I have

Java

public class MarkdownResource {
    public static ResourceType RESOURCE_TYPE = new ResourceType(Constants.MODULE_ID, Constants.TYPE_ID);
    public static String DATA_KEY = "note.md";
    public String note = "";

    public MarkdownResource(String note) {
        this.note = note;
    }
}

Is this a valid conversion? My workspace is failing to initialize, and the error is leading me to believe I have something wrong with that resource.

Exception

15:10:37.893 [Designer-Startup] ERROR designer.main - Error starting up module Process Config Manager
java.lang.IncompatibleClassChangeError: Expected static field com.bwdesigngroup.ignition.configmanager.common.MarkdownResource.RESOURCE_TYPE
	at com.bwdesigngroup.ignition.configmanager.designer.ConfigManagerWorkspace.<init>(ConfigManagerWorkspace.java:40)
	at com.bwdesigngroup.ignition.configmanager.designer.ProcessConfigManagerDesignerHook.startup(ProcessConfigManagerDesignerHook.java:26)
	at com.inductiveautomation.ignition.designer.IgnitionDesigner$LoadedModule.startup(IgnitionDesigner.java:1951)
	at com.inductiveautomation.ignition.designer.IgnitionDesigner.startupModule(IgnitionDesigner.java:1185)
	at com.inductiveautomation.ignition.designer.IgnitionDesigner.lambda$loadProject$9(IgnitionDesigner.java:1005)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
	at com.inductiveautomation.ignition.designer.IgnitionDesigner.loadProject(IgnitionDesigner.java:1004)
	at com.inductiveautomation.ignition.designer.IgnitionDesigner$StartupProjectDialogHandler.lambda$new$2(IgnitionDesigner.java:2015)
	at java.base/java.lang.Thread.run(Unknown Source)

It says that the field should be static, but the field is static?

They weren’t constants! derp

public class MarkdownResource {
    public static final ResourceType RESOURCE_TYPE = new ResourceType(Constants.MODULE_ID, Constants.TYPE_ID);
    public static final String DATA_KEY = "note.md";
    public String note = "";

    public MarkdownResource(String note) {
        this.note = note;
    }
}
1 Like