#How to mark a class as warning / unstable using a custom annotation
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
interface as follows:
public @interface NotFinished {
String value() default "";
}
Then you can simply apply this annotation to any class like this:
@NotFinished("This class is not fully implemented yet")
public class ExampleClass {
// class implementation here
}
You can also check for this annotation at runtime using reflection if needed. Remember that annotations do not affect the behavior of your code, they are just metadata that you can use for documentation or custom processing. Also, make sure to communicate clearly with your team about the meaning of your custom annotations so everyone understands their purpose.
that wont apply a warningn right..
uh what exactly do you want to do
what is the goal? log some message if an unfinished class is used? or prevent using it completely?
Do you want a warning during compilation or?
you know like when u use deprecated methods it becomes yellow in intellij and shows a warning when u hover over them
i just want to make a warning like that
ah well IDE integration is more effort
thanks :3
I think something like checkerframework can be configured
or you could write an annotation processor
which would work as a plugin to javac and be able to emit warnings/errors
actually - this feels like a crazy fun project
i cant lie i didnt thought it would be soo deep
i just wanted to add a fancy thing to my class
not too hard, but gotta learn stuff
well the checkerframework one isn't that deep
let me make sure im right about that
package io.github.unjoinable.skyblock.item.items;
import io.github.unjoinable.skyblock.annotations.NotFinished;
@NotFinished("A class purely for development purposes must not be used in production.")
public class TestSword {
}``` the class name speaks for it but ykk we gotta be out here being fancyy
ok lemme google chehckerframework
i might be wrong? idk
but this is a decent guide to the annotation processor thing
ty
one thing i could figure out was using documented
@Documented
public @interface NotFinished {
String value() default "";
}```
it would look like this then^
but i believe this is where i would be stopping for now since it was just a fancy tool i wanted
🤣
import java.lang.annotation.Documented;
@NotFinished("Unfinished class being unfinished be like...u get it?")
@Documented
public @interface NotFinished {
String value() default "";
}```
Out of curiousity, will you use this a lot more than the built in warnings for TODO and FIXME?
i am working on a rather bigger project soo i would like to know what class has what missing
i do not exactly know purpose of TODO and FIXME
thanks :3
i guess they are what i need but i would still like to have a IDE warning which i will look into
Generally any form of the word 'todo' will get picked up by the IDE and if you have it set as a warning in the settings, it can be quite annoying.