#alternatives for 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>.
There are a few alternatives to custom annotations in Java:
-
Marker Interfaces: Instead of using annotations, you can define marker interfaces that classes can implement to indicate certain behaviors or characteristics. For example, you can define an interface like
Serializablewhich indicates that a class can be serialized. -
Naming Conventions: You can use naming conventions to indicate certain behaviors or characteristics instead of using annotations. For example, you can prefix method names with "get" or "set" to indicate that they are getter or setter methods.
-
Configuration Files: Instead of using annotations, you can use external configuration files (e.g., XML or properties files) to specify certain behaviors or configurations for your application.
-
Reflection: You can use reflection to inspect and manipulate classes at runtime, allowing you to achieve similar functionality as custom annotations. However, this approach is more complex and less convenient compared to using annotations.
It's important to note that custom annotations provide a more declarative and self-contained way of specifying metadata and behavior in your code, so they are often the preferred approach in many cases.
alternatives for custom annotation
Changed the title to alternatives for custom annotation.
Wdym
I have to use alternatives for customized annotation in Spring Boot. I have a list that contains some values. One of the value is lets say ABC but from db its coming ABC.D. I know that both are same. So, I have tell program that consider both as same
But I can't use customized annotation or conditional logic since simple IF condition won't be good at generic place.
I want some lenient way
So...like Validation annotation?
I'm still not quite sure I get your intent? I mean you could always use a mapper. But the advantage of that over an AutoApplied contributeconverter is eluding me?
I read that three times, still not any wiser...
If I read it correctly he just wants a specific conversion being applied, but for some reason without annotations.
So:
DB | Entity AAA | AAA BBB | BBB CCC | CCC ABC.D | ABC
I mean...could be done in setter, possibly wrapper class with overriden equals method? Depends on the usage