Class JvmFixtureEvaluation


  • public class JvmFixtureEvaluation
    extends Object
    Evaluates JvmFixtures reflectively without loading them in the classpath.
    Author:
    tilois - Initial API and Implementation
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T evaluateSingle​(org.eclipse.xtext.common.types.JvmAnnotationValue anAnnotationValue, Class<T> anExpectedType)
      Evaluates an Jvm annotation value which is expected to hold a single value of the specified type.
      <T> List<T> evaluateValues​(org.eclipse.xtext.common.types.JvmAnnotationValue anAnnotationValue, Class<T> anExpectedType)
      Evaluates an Jvm annotation value which is expected to hold the specified type.
      List<org.eclipse.xtext.util.Pair<org.eclipse.xtext.common.types.JvmFormalParameter,​org.eclipse.xtext.common.types.JvmAnnotationReference>> getAllAnnotatedParameter​(MethodReference aMethod, Set<Class<? extends Annotation>> someAnnotationTypes)
      Processes the given method and returns a list of all annotated parameters.
      String getParameterNameOf​(ParameterName aParameterName)
      Returns the name of a single given parameter defined by a ParameterName instance.
      org.eclipse.xtext.common.types.JvmAnnotationValue getValueByName​(org.eclipse.xtext.common.types.JvmAnnotationReference anAnnotation, String aName)
      Extracts an annotation value by its name.
      protected com.google.common.base.Predicate<org.eclipse.xtext.common.types.JvmAnnotationReference> isOneOf​(Set<Class<? extends Annotation>> someAnnotationTypes)
      Produces a predicate that matches an annotation if it is one of the specified ones.
    • Constructor Detail

      • JvmFixtureEvaluation

        public JvmFixtureEvaluation()
    • Method Detail

      • getAllAnnotatedParameter

        public List<org.eclipse.xtext.util.Pair<org.eclipse.xtext.common.types.JvmFormalParameter,​org.eclipse.xtext.common.types.JvmAnnotationReference>> getAllAnnotatedParameter​(MethodReference aMethod,
                                                                                                                                                                                         Set<Class<? extends Annotation>> someAnnotationTypes)
        Processes the given method and returns a list of all annotated parameters. Only supports one annotation per parameter.
        Parameters:
        aMethod - Method to be checked.
        someAnnotationTypes - Types that should be collected.
        Returns:
        A list of all parameters linked to the annotation of the given types for this method.
      • isOneOf

        protected com.google.common.base.Predicate<org.eclipse.xtext.common.types.JvmAnnotationReference> isOneOf​(Set<Class<? extends Annotation>> someAnnotationTypes)
        Produces a predicate that matches an annotation if it is one of the specified ones.
        Parameters:
        someAnnotationTypes - Annotations that should match.
        Returns:
        true if the annotation represents one of the specified ones, false otherwise.
      • getValueByName

        public org.eclipse.xtext.common.types.JvmAnnotationValue getValueByName​(org.eclipse.xtext.common.types.JvmAnnotationReference anAnnotation,
                                                                                String aName)
        Extracts an annotation value by its name.
        Parameters:
        anAnnotation - Annotation where to search.
        aName - Name to be searched.
        Returns:
        annotation value if it got found, null otherwise.
      • getParameterNameOf

        public String getParameterNameOf​(ParameterName aParameterName)
        Returns the name of a single given parameter defined by a ParameterName instance.
        Parameters:
        aParameterName - the parameter name instance
        Returns:
        the parameter name string
      • evaluateValues

        public <T> List<T> evaluateValues​(org.eclipse.xtext.common.types.JvmAnnotationValue anAnnotationValue,
                                          Class<T> anExpectedType)
        Evaluates an Jvm annotation value which is expected to hold the specified type.
        Parameters:
        anAnnotationValue - Annotation value to evaluate.
        anExpectedType - Expected type of the value.
        Returns:
        a list of all values
      • evaluateSingle

        public <T> T evaluateSingle​(org.eclipse.xtext.common.types.JvmAnnotationValue anAnnotationValue,
                                    Class<T> anExpectedType)
        Evaluates an Jvm annotation value which is expected to hold a single value of the specified type.
        Parameters:
        anAnnotationValue - Annotation value to evaluate.
        anExpectedType - Expected type of the value.
        Returns:
        the value
        See Also:
        does the same for an arbitrary list of values.