Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
sort name method and attribute
  • Loading branch information
badetitou committed Dec 7, 2020
1 parent 4b6789a commit 839b859
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/ch/akuhn/fame/codegen/CodeGeneration.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;

import ch.akuhn.fame.FameDescription;
Expand Down Expand Up @@ -321,13 +318,18 @@ private void acceptClass(MetaDescription m) throws IOException {
code.addSuperclass(this.packageName(m.getSuperclass().getPackage()), className(m.getSuperclass()));
}
// My own properties
for (PropertyDescription property : m.getProperties()) {
List<PropertyDescription> propertyDescriptions = m.getProperties().stream().collect(Collectors.toList());
propertyDescriptions.sort(Comparator.comparing(Element::getName));
for (PropertyDescription property : propertyDescriptions) {
this.acceptProperty(property, m);
}
// Properties from my traits
Set<PropertyDescription> propertyDescriptionSet = new HashSet<>();
m.getAllTraits().stream().map( c -> c.getProperties()).forEach(propertyDescriptionSet::addAll);
for (PropertyDescription propertyDescription: propertyDescriptionSet) {
propertyDescriptions.clear();
propertyDescriptions.addAll(propertyDescriptionSet);
propertyDescriptions.sort(Comparator.comparing(Element::getName));
for (PropertyDescription propertyDescription: propertyDescriptions) {
this.acceptProperty(propertyDescription, m);
}

Expand Down Expand Up @@ -371,7 +373,7 @@ private void acceptPackage(PackageDescription m) throws IOException {
}
}

String name = toUpperFirstChar(m.getName()) + "Model";
String name = toUpperFirstChar(m.getName().replaceAll("-", "") + "Model");
Template template = Template.get("Package");
String packageName = this.packageName(m);
template.set("PACKAGE", packageName);
Expand Down

0 comments on commit 839b859

Please sign in to comment.