File tree Expand file tree Collapse file tree 3 files changed +28
-15
lines changed
lib/src/main/java/ch/akuhn/fame Expand file tree Collapse file tree 3 files changed +28
-15
lines changed Original file line number Diff line number Diff line change @@ -340,7 +340,7 @@ private void acceptClass(MetaDescription metaDescription) throws IOException {
340340 }
341341 // Properties from my traits that are not in my own properties
342342 Set <PropertyDescription > propertyDescriptionSet = new HashSet <>();
343- metaDescription .getTraits ().stream ()
343+ metaDescription .computeAllTraits ().stream ()
344344 .map (c -> c .getProperties ().stream ()
345345 .filter (traitProperty -> propertyDescriptions .stream ().noneMatch (myProperty -> myProperty .getName ().equals (traitProperty .getName ())))
346346 .collect (Collectors .toList ()))
@@ -365,7 +365,7 @@ private void acceptTrait(FM3Trait m) throws IOException {
365365 code .setTraits (m .getTraits ().stream ().map (FM3Type ::getName ).collect (Collectors .toList ()));
366366 code .addImport (FameDescription .class );
367367 code .addImport (FamePackage .class );
368- for (FM3Trait t : m .computeAllTraits ()) {
368+ for (FM3Trait t : m .getTraits ()) {
369369 code .addImport (packageName (t .getPackage ()), t .getName ());
370370 }
371371
Original file line number Diff line number Diff line change @@ -86,13 +86,21 @@ public FM3Trait(String name) {
8686 super (name );
8787 }
8888
89- FM3Type traitOwner ;
90- @ FameProperty (name = "owner" , opposite = "traits" )
91- public FM3Type getTraitOwner () {
92- return traitOwner ;
89+ private Map <String , FM3Type > users = new HashMap <String , FM3Type >();
90+
91+ @ FameProperty (name = "users" , opposite = "traits" )
92+ public Collection <FM3Type > getUsers () {
93+ return users .values ();
9394 }
94- public void setTraitOwner (FM3Type traitOwner ){
95- this .traitOwner = traitOwner ;
95+
96+ public void setUsers (Collection <FM3Type > users ){
97+ for (FM3Type user : users ) {
98+ this .addUser (user );
99+ }
96100 }
97101
98- }
102+ public void addUser (FM3Type user ) {
103+ users .put (user .getName (), user );
104+ }
105+
106+ }
Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ public void setTraits(Collection<FM3Trait> traits) {
156156 }
157157 }
158158
159- @ FameProperty (name ="traits" , opposite = "owner " )
159+ @ FameProperty (name ="traits" , opposite = "users " )
160160 public Collection <FM3Trait > getTraits () {
161161 return traits .values ();
162162 }
@@ -174,11 +174,16 @@ public boolean isRoot() {
174174 }
175175
176176 public Set <FM3Trait > computeAllTraits () {
177- Set <FM3Trait > traits = new HashSet <>();
178- traits .addAll (getTraits ());
179- for (FM3Trait t : traits ) {
180- traits .addAll (t .computeAllTraits ());
177+ Set <FM3Trait > computedTraits = new HashSet <>();
178+ computedTraits .addAll (getTraits ());
179+ Set <FM3Trait > transitiveTraits = new HashSet <>();
180+
181+ for (FM3Trait t : computedTraits ) {
182+ transitiveTraits .addAll (t .computeAllTraits ());
181183 }
182- return traits ;
184+
185+ computedTraits .addAll (transitiveTraits );
186+ return computedTraits ;
183187 }
188+
184189}
You can’t perform that action at this time.
0 commit comments