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.List;
import java.util.Map;
import java.util.Set;
import org.snapscript.core.function.Function;
import org.snapscript.core.property.Property;
import org.snapscript.core.property.PropertyTableBuilder;
import org.snapscript.core.type.Type;
import org.snapscript.core.type.index.FunctionPropertyCollector;
public class FunctionPropertyGenerator {
private final FunctionPropertyCollector collector;
private final PropertyTableBuilder builder;
public FunctionPropertyGenerator(String... ignore) {
this.builder = new PropertyTableBuilder(ignore, false);
this.collector = new FunctionPropertyCollector();
}
public void generate(Type type) throws Exception {
List functions = type.getFunctions();
if(!functions.isEmpty()) {
List properties = type.getProperties();
Map available = builder.getProperties(type);
Set ignore = available.keySet();
List extended = collector.collect(functions, ignore);
if(!extended.isEmpty()) {
properties.addAll(extended);
}
}
}
}