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

org.snapscript.core.type.index.ClassPropertyBuilder Maven / Gradle / Ivy

package org.snapscript.core.type.index;

import static org.snapscript.core.constraint.Constraint.TYPE;

import java.util.ArrayList;
import java.util.List;

import org.snapscript.core.error.InternalStateException;
import org.snapscript.core.property.ClassProperty;
import org.snapscript.core.property.Property;
import org.snapscript.core.property.ThisProperty;
import org.snapscript.core.type.Type;

public class ClassPropertyBuilder {

   private final TypeIndexer indexer;
   
   public ClassPropertyBuilder(TypeIndexer indexer){
      this.indexer = indexer;
   }

   public List create(Class source) throws Exception {
      Type type = indexer.loadType(source);
      
      if(type == null) {
         throw new InternalStateException("Could not load type for " + source);
      }
      List properties = new ArrayList();
      Property thisProperty = new ThisProperty(type);
      Property classProperty = new ClassProperty(type, TYPE);
      
      properties.add(thisProperty);
      properties.add(classProperty);
      
      return properties;        
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy