All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.snapscript.tree.define.FunctionPropertyGenerator Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
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);
         }
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy