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

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

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);
         }
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy