![JAR search and dependency download from the Maven repository](/logo.png)
org.snapscript.tree.define.GenericParameter Maven / Gradle / Ivy
package org.snapscript.tree.define;
import static org.snapscript.core.constraint.Constraint.OBJECT;
import java.util.List;
import org.snapscript.core.constraint.Constraint;
import org.snapscript.core.constraint.GenericParameterConstraint;
import org.snapscript.core.scope.Scope;
import org.snapscript.core.type.Type;
import org.snapscript.tree.NameReference;
import org.snapscript.tree.literal.TextLiteral;
public class GenericParameter {
private final NameReference reference;
private final Constraint constraint;
public GenericParameter(TextLiteral identifier) {
this(identifier, OBJECT);
}
public GenericParameter(TextLiteral identifier, Constraint constraint) {
this.reference = new NameReference(identifier);
this.constraint = constraint;
}
public Constraint getGeneric(Scope scope) throws Exception {
String parameter = reference.getName(scope);
Type type = constraint.getType(scope);
List generics = constraint.getGenerics(scope);
return new GenericParameterConstraint(type, generics, parameter);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy