JsonToKotlinClass icon indicating copy to clipboard operation
JsonToKotlinClass copied to clipboard

Imports only used in root class

Open ViktorIngemarsson opened this issue 4 years ago • 5 comments

I have a project where there is a need to do imports in only the root class and then not use these imports in the sub classes within each class. An example can be see below. I can change the core of the project to make this possible but can't seem to do it with just creating an extension. Is this possible to do without changing the core of the plugin?

FROM THIS:

"RootClass": { "rootClassId": "001", "subClass": { "subClassId": "001", "value": "1" } }

TO THIS:

data class RootClass( val id: String, val subClass: SubClass ) : RootObject

data class SubClass( val subClassId: String, val value: String ) : Serializable

ViktorIngemarsson avatar Sep 08 '20 09:09 ViktorIngemarsson

@ViktorIngemarsson Hey. What's the imports

wuseal avatar Sep 08 '20 09:09 wuseal

Its project specific but could be as in the example above that I want to extend different classes depending on if its the root class or not; RootObject or Serializable

ViktorIngemarsson avatar Sep 08 '20 09:09 ViktorIngemarsson

@ViktorIngemarsson sorry, we can't determine if it is root class when code only inside the Extension class currently

wuseal avatar Sep 08 '20 11:09 wuseal

@ViktorIngemarsson in this case, I think we need to refactor the current code logic for more accesses

wuseal avatar Sep 08 '20 12:09 wuseal

I anticipated that, thanks for the quick answer!

ViktorIngemarsson avatar Sep 08 '20 12:09 ViktorIngemarsson