mtedone / podam

PODAM - POjo DAta Mocker
https://mtedone.github.io/podam
MIT License
323 stars 750 forks source link

Exclude some attributes #256

Closed sayadi closed 6 years ago

sayadi commented 6 years ago

To avoid circular filling (and eventually a StackOverflow error), or for any other reason, it would be helpful to have the ability to exclude some attributes from being filled.

A common scenario in POJOs modeling tables in a relational database is some classes will reference each other in a ManyToMany relationship:

public ClassA {
   // Annotations for many to many relationship
   ClassB b;
}
public ClassB {
   // Annotations for many to many relationship
   ClassA a;
}
daivanov commented 6 years ago

You cannot have StackOverflow error as Podam will stop after 3 levels of objects are filled.

There are several ways to do what you want, but probably the best one consist of overriding boolean ClassAttributeApprover.approve(ClassAttribute attribute) in DefaultClassInfoStrategy (or whatever ClassInfoStrategy you are using).

daivanov commented 6 years ago

Closing this as this is not an issue.