Class JvmFixtureEvaluation


  • public class JvmFixtureEvaluation
    extends java.lang.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, java.lang.Class<T> anExpectedType)
      Evaluates an Jvm annotation value which is expected to hold a single value of the specified type.
      <T> java.util.List<T> evaluateValues​(org.eclipse.xtext.common.types.JvmAnnotationValue anAnnotationValue, java.lang.Class<T> anExpectedType)
      Evaluates an Jvm annotation value which is expected to hold the specified type.
      java.util.List<org.eclipse.xtext.util.Pair<org.eclipse.xtext.common.types.JvmFormalParameter,​org.eclipse.xtext.common.types.JvmAnnotationReference>> getAllAnnotatedParameter​(MethodReference aMethod, java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> someAnnotationTypes)
      Processes the given method and returns a list of all annotated parameters.
      java.lang.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, java.lang.String aName)
      Extracts an annotation value by its name.
      protected com.google.common.base.Predicate<org.eclipse.xtext.common.types.JvmAnnotationReference> isOneOf​(java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> someAnnotationTypes)
      Produces a predicate that matches an annotation if it is one of the specified ones.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JvmFixtureEvaluation

        public JvmFixtureEvaluation()
    • Method Detail

      • getAllAnnotatedParameter

        public java.util.List<org.eclipse.xtext.util.Pair<org.eclipse.xtext.common.types.JvmFormalParameter,​org.eclipse.xtext.common.types.JvmAnnotationReference>> getAllAnnotatedParameter​(MethodReference aMethod,
                                                                                                                                                                                                   java.util.Set<java.lang.Class<? extends java.lang.annotation.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​(java.util.Set<java.lang.Class<? extends java.lang.annotation.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,
                                                                                java.lang.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 java.lang.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> java.util.List<T> evaluateValues​(org.eclipse.xtext.common.types.JvmAnnotationValue anAnnotationValue,
                                                    java.lang.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,
                                    java.lang.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.