org.snapscript.tree.define.FunctionPropertyGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap-all Show documentation
Show all versions of snap-all Show documentation
Dynamic scripting for the JVM
package org.snapscript.tree.define;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.snapscript.core.function.Function;
import org.snapscript.core.property.Property;
import org.snapscript.core.type.Type;
import org.snapscript.core.type.index.FunctionPropertyCollector;
public class FunctionPropertyGenerator {
private final FunctionPropertyCollector collector;
public FunctionPropertyGenerator() {
this.collector = new FunctionPropertyCollector();
}
public void generate(Type type) throws Exception {
List functions = type.getFunctions();
List properties = type.getProperties();
if(!functions.isEmpty()) {
Set ignore = new HashSet();
for(Property property : properties) {
String name = property.getName();
if(name != null) {
ignore.add(name);
}
}
List extended = collector.collect(functions, ignore);
if(!extended.isEmpty()) {
properties.addAll(extended);
}
}
}
}