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

org.snapscript.core.attribute.AttributeResultBuilder Maven / Gradle / Ivy

package org.snapscript.core.attribute;

import java.util.List;

import org.snapscript.core.constraint.Constraint;
import org.snapscript.core.scope.Scope;

public class AttributeResultBuilder {

   private final Attribute attribute;

   public AttributeResultBuilder(Attribute attribute) {
      this.attribute = attribute;
   }

   public AttributeResult create(Scope scope) {
      Constraint returns = attribute.getConstraint();
      List generics = attribute.getGenerics();
      List constraints = returns.getGenerics(scope);
      String name = returns.getName(scope);
      int require = constraints.size();
      int optional = generics.size();

      if(name != null || optional + require > 0) {
         return new GenericAttributeResult(attribute);
      }
      return new StaticAttributeResult(attribute);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy