Asked  7 Months ago    Answers:  5   Viewed   22 times

I am trying to convert DO to DTO using java and looking for automated tool before start writing my own. I just wanted to know if there any free tool available for the same.

 Answers

21

You could try Dozer.

Dozer is a Java Bean to Java Bean mapper that recursively copies data from one object to another. Typically, these Java Beans will be of different complex types.

Dozer supports simple property mapping, complex type mapping, bi-directional mapping, implicit-explicit mapping, as well as recursive mapping. This includes mapping collection attributes that also need mapping at the element level.

Tuesday, June 1, 2021
 
Rocket
answered 7 Months ago
92

If you're using something supporting DataAnnotations, you should be able to use a metadata class to contain your validation attributes:

public class ProductMetadata 
{
    [NotEmpty, NotShorterThan10Characters, NotLongerThan100Characters]
    public string Name { get; set; }

    [NotLessThan0]
    public decimal Price { get; set;}
}

and add it in the MetadataTypeAttribute on both the domain entity & DTO:

[MetadataType(typeof(ProductMetadata))]
public class Product

and

[MetadataType(typeof(ProductMetadata))]
public class ProductViewModel

This won't work out of the box with all validators - you may need to extend your validation framework of choice to implement a similar approach.

Sunday, August 1, 2021
 
Andrew
answered 4 Months ago
60

There is no such tools for converting Swift code to Objective-C. There are some reasons. One is because Objective-C is a semantic subset of Swift, i. e. Objective-C doesn't have any equivalent of some fundamental features of Swift such as Generics, Algebraic data types, Pattern matching and other. Theoretically it is possible to make, but generated Objective-C code should be boilerplate and inefficient.

It is recommended to migrate your codebase to Swift to avoid technical debt there are many tools which can be used to convert Objective-C to Swift.

Sunday, August 1, 2021
 
aurelijusv
answered 4 Months ago
30

Damon, Prettier is probably going to do everything you want wrt painless javascript code formatting. It will convert your code to an AST and then pretty print it back into your file so it auto-formats as you go. You can even add it as a precommit hook or run it on a folder full of files (pretty quickly, too!) so that your entire codebase will be immediately pretty.

Here is a video from ReactConf that explains it pretty well

Sunday, August 8, 2021
 
Stephtheboss
answered 4 Months ago
98

Since 1.3 MapStruct supports Immutables. Look here for more details.

Sunday, October 10, 2021
 
Andras Zoltan
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share