Orika - ParameterNamesNotFoundException: One or more #Named annotations missing for class - orika

I am getting the following exception in Orika
ParameterNamesNotFoundException: One or more #Named annotations missing for class
I have 2 simple pojos and I want to map them.

Move your pojo class declarations to outter classes. Orika cannot handle inner classes.

Related

What is the difference between sealed and internal in Kotlin?

What is the difference between sealed and internal in Kotlin? I have read Kotlin's documentation on sealed classes and visibility modifiers; however, it is still not clear to me when to use sealed vs. internal. Maybe someone could provide real-world code samples?
Sealed classes | Kotlin & Visibility modifiers | Kotlin resources.
sealed class will be visible in all modules, but extendable only in the same module. This means if you have this:
sealed class MyClass {} then you can do this in the same module:
class MyExtensionClass: MyClass() {}
But you can't do the same thing in another module. But you can still use both MyClass and MyExtensionClass in another module.
For example you can do this in another module:
val x: MyClass = MyExtensionClass()
You can't instantiate a sealed class directly neither in the same or another module. This means you can't do this nowhere:
val x = MyClass()
So sealed class is basically an abstract class which can only be implemented in the same module.
internal class can be used and extended in the same module just like a sealed class, but you can do neither in another module. So you can't even use or instantiate it in another module. Also you can directly instantiate an internal class as long as you are doing it in the same module.
So: Use sealed to better control extending something. For example you create a library and you want a class from this library to be used but not extended. Use internal if you wan't your class to be invisible to other modules (you create a library, but certain class in this library shouldn't even be directly compile time usable by libraries users)
A good use case for sealed class:
You build a library and have some abstract class or interface which has multiple different implementations, but you want to make sure the libraries user doesn't add its own implementations (you wan't to be in control of implementation details).
A good use case for internal class:
You have some interface and a factory that creates implementations, but you don't want the implementing class to be compile-time visible to libraries users. They just use the factory and don't need to worry about the implementation. They might build their own implementation though and therefor not use the factory you provided and this is OK.
These are not mutually exclusive. You can have an internal sealed class as well.
internal is about visibility, and sealed is about inheritance rules.
internal means the class type is only visible within the module. In other modules, you can't even mention the name of the type.
sealed means it is open (can be subclassed), but subclasses (or implementations if it's a sealed interface) can only be defined in the same module, and the compiler keeps track of an exhaustive list of all subclasses. Another rule is that you can't create anonymous subclasses of it (object: MySealedClass). The advantage of a sealed type is that the compiler knows when you've exhaustively checked a type in when statements, if/else chains, etc. It can also be used in a library to ensure that only known implementations of a class or interface are ever passed to it (prevent users from creating subclasses of something and passing them into the library).
Bonus:
Visibility modifier keywords: public, internal, private, protected
Inheritance modifier keywords: open, final, sealed
data and value also cause a class to be final implicitly as a side effect.

Why sealed modifier cannot be used with object in Kotlin?

Why sealed class User compiles successfully but sealed object User throws a compilation error?
I went through Kotlin docs but got nothing. I am playing a bit with Kotlin and just wanted to know the reason behind this?
sealed classes are supposed to be open, however all objects are final: sealed classes have a certain quantity of subclasses (inside the file, where the sealed class is declared), but objects are singletons, so they cannot have any subclasses. Consequently, sealed object declaration does not make any sense and can't be compiled.

Is there a solution to "Cannot access '<init>': it is private in XYZ?

I included a library I'd like to use, but in accessing to one of its classes I get the error message,
"Cannot access '<init>': it is private in [class name]
Is there something I can do to rectify this on my side, or am I just stuck to not use the package?
The error means the constructor is private. Given your comment, I'm assuming you're using a library. If this is the case, you'll have to find a different way to initialize it. Some libraries have factories or builders for classes, so look up any applicable documentation (if it is a library or framework). Others also use the singleton pattern, or other forms of initialization where you, the developer, don't use the constructor directly.
If, however, it is your code, remove private from the constructor(s). If it's internal and you're trying to access it outside the module, remove internal. Remember, the default accessibility is public. Alternatively, you can use the builder pattern, factory pattern, or anything similar yourself if you want to keep the constructor private or internal.
I came across this issue when trying to extend a sealed class in another file. Without seeing the library code it is hard to know if that is also what you are attempting to do.
The sealed classes have the following unique features:
A sealed class can have subclasses, but all of them must be declared in the same file as the sealed class itself.
A sealed class is abstract by itself, it cannot be instantiated directly and can have abstract members.
Sealed classes are not allowed to have non-private constructors (their constructors are private by default).
Classes that extend subclasses of a sealed class (indirect inheritors) can be placed anywhere, not necessarily in the same file.
For more info, have a read at https://www.ericdecanini.com/2019/10/14/kotlins-sealed-class-enums-on-steroids/
Hopefully, this will help others new to Kotlin who are also encountering this issue.
Class constructors are package-private by default. Just add the public keyword before declaring the constructor.
By default constructor is public so need to remove internal keyword.

Class inheritance in Mule Java / POJO Component

I am trying to use a base class with common methods and to extend it other more specific classes.
public class myClass extends myBaseClass {}
The extended class I am using as a Java component in a flow:
<component class="org.example.MyClass" doc:name="Java"/>
When I am not calling methods from the parent class, everything works well. But each time I try calling one Mule is throwing an exception:
DefaultJavaComponent{vtigersapFlow1.component.9760166}. Message payload is of type: String
In my base class I am using:
#Lookup
private MuleContext muleContext;
and and a NullPointerExcception is thrown when I am doing:
muleContext.getRegistry().get("system.uri");
It's possible that the #Lookup annotation is not honoured correctly in a class hierarchy.
Instead of looking values in the registry, you should receive them by injection, i.e. get system.uri by injection.
You may find that switching to Spring beans will help a lot in doing so. component class= is really for basic stuff.

VB.NET Creating Classes, What is Public Class MyClass(Of Type)?

I'm still learning ASP.NET and I often see code like this throughout parts of our framework:
Public MustInherit Class DBFileManager(Of F As IDBFile, FC As IDBFileContent, FT As IDBFileThumb)
Can anybody tell me what this means? Much thanks!
Its a generic. That means a DBFileManager can be created that acts on 3 classes that implement the 3 named Interfaces
see http://msdn.microsoft.com/en-us/library/w256ka79(VS.80).aspx for more information
To build on what #Jimmy said: It is also an Abstract Class, which means it acts as a base class - you can't use it directly, you must sub class it to use. That subclass must implement the 3 types in the class header.