org.apache.commons.lang3.reflect.TypeUtils Java Examples

The following examples show how to use org.apache.commons.lang3.reflect.TypeUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExceptionMapperRegistryBuilder.java    From katharsis-framework with Apache License 2.0 6 votes vote down vote up
private Class<? extends Throwable> getGenericType(Class<? extends JsonApiExceptionMapper> mapper) {
  Type[] types = mapper.getGenericInterfaces();
  if (null == types || 0 == types.length ){
    types = new Type[]{mapper.getGenericSuperclass()};
  }

  for (Type type : types) {
    if (type instanceof ParameterizedType && (TypeUtils.isAssignable(((ParameterizedType) type).getRawType(),JsonApiExceptionMapper.class)
        || TypeUtils.isAssignable(((ParameterizedType) type).getRawType(),ExceptionMapper.class))) {
      //noinspection unchecked
      return (Class<? extends Throwable>) ((ParameterizedType) type).getActualTypeArguments()[0];
    }
  }
  //Won't get in here
  return null;
}
 
Example #2
Source File: FreeIpaClient.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
public Optional<User> userFind(String user) throws FreeIpaClientException {
    List<Object> flags = List.of(user);
    Map<String, Object> params = Map.of(
            "uid", user,
            "all", true
    );
    ParameterizedType type = TypeUtils
            .parameterize(List.class, User.class);
    List<User> foundUsers = (List<User>) invoke("user_find", flags, params, type).getResult();
    if (foundUsers.size() > 1) {
        LOGGER.error("Found more than 1 user with uid {}.", user);
    }
    if (foundUsers.isEmpty()) {
        return Optional.empty();
    } else {
        return Optional.of(foundUsers.get(0));
    }
}
 
Example #3
Source File: BeanParamInjectParamExtension.java    From swagger-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public List<Parameter> extractParameters(List<Annotation> annotations, Type type, Set<Type> typesToSkip, Iterator<SwaggerExtension> chain) {
    Class<?> cls = TypeUtils.getRawType(type, type);

    if (shouldIgnoreClass(cls) || typesToSkip.contains(type)) {
        // stop the processing chain
        typesToSkip.add(type);
        return Lists.newArrayList();
    }
    for (Annotation annotation : annotations) {
        if (annotation instanceof BeanParam || annotation instanceof InjectParam) {
            return reader.extractTypes(cls, typesToSkip, Lists.newArrayList());
        }
    }
    return super.extractParameters(annotations, type, typesToSkip, chain);
}
 
Example #4
Source File: RuntimeRulesBuilder.java    From yare with MIT License 6 votes vote down vote up
@Override
public ValueProvider create(String name, Type baseReferenceType, Type referenceType, String reference) {
    String referenceName = reference;
    String path = null;

    int dotIndex = reference.indexOf('.');
    if (dotIndex > -1) {
        referenceName = reference.substring(0, dotIndex);
        path = reference.substring(dotIndex + 1);
    }

    return ValueProviderFactory.createFromPath(
            TypeUtils.getRawType(baseReferenceType, null),
            referenceName,
            TypeUtils.getRawType(referenceType, null),
            path);
}
 
Example #5
Source File: SpringSwaggerExtension.java    From swagger-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public boolean shouldIgnoreType(Type type, Set<Type> typesToSkip) {
    Class<?> clazz = TypeUtils.getRawType(type, type);
    if (clazz == null) {
        return false;
    }

    String clazzName = clazz.getName();

    switch (clazzName) {
        case "javax.servlet.ServletRequest":
        case "javax.servlet.ServletResponse":
        case "javax.servlet.http.HttpSession":
        case "javax.servlet.http.PushBuilder":
        case "java.security.Principal":
        case "java.io.OutputStream":
        case "java.io.Writer":
            return true;
        default:
    }

    return clazzName.startsWith("org.springframework") &&
            !"org.springframework.web.multipart.MultipartFile".equals(clazzName);
}
 
Example #6
Source File: SpringSwaggerExtension.java    From swagger-maven-plugin with Apache License 2.0 6 votes vote down vote up
private Property readAsPropertyIfPrimitive(Type type) {
    if (com.github.kongchen.swagger.docgen.util.TypeUtils.isPrimitive(type)) {
        return ModelConverters.getInstance().readAsProperty(type);
    } else {
        String msg = String.format("Non-primitive type: %s used as request/path/cookie parameter", type);
        log.warn(msg);

        // fallback to string if type is simple wrapper for String to support legacy code
        JavaType ct = constructType(type);
        if (isSimpleWrapperForString(ct.getRawClass())) {
            log.warn(String.format("Non-primitive type: %s used as string for request/path/cookie parameter", type));
            return new StringProperty();
        }
    }
    return null;
}
 
Example #7
Source File: TypeCoercerImpl.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isSupportedType(Class<?> clazz, Type type) {
   if (type == null) {
      return false;
   }
   if (TypeUtils.isAssignable(type, clazz)) {
      return true;
   }
   TypeHandler<?> handler = getHandler(clazz);
   if (handler != null) {
      return handler.isSupportedType(type);
   }
   if (clazz.isEnum()) {
      return enumHandler.isSupportedType(clazz, type);
   }
   return false;
}
 
Example #8
Source File: Utils.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
private static Type doDeserializeType(String name) {
   int startIdx = name.indexOf('<');
   if(startIdx == -1) {
      return classForName(name);
   }
   else if(name.charAt(name.length() - 1) == '>') {
      Class<?> rawType = classForName(name.substring(0, startIdx));
      String [] typeNames = StringUtils.split(name.substring(startIdx+1, name.length() - 1), ',');
      Type [] typeParameters = new Type[typeNames.length];
      for(int i=0; i<typeNames.length; i++) {
         typeParameters[i] = doDeserializeType(typeNames[i]);
      }
      return TypeUtils.parameterize(rawType, typeParameters);
   }
   else {
      throw new IllegalArgumentException("Invalid class name, missing close '>': " + name);
   }
}
 
Example #9
Source File: AbstractReader.java    From swagger-maven-plugin with Apache License 2.0 5 votes vote down vote up
protected List<Parameter> getParameters(Type type, List<Annotation> annotations, Set<Type> typesToSkip) {
    if (!hasValidAnnotations(annotations) || isApiParamHidden(annotations)) {
        return Collections.emptyList();
    }

    Iterator<SwaggerExtension> chain = SwaggerExtensions.chain();
    List<Parameter> parameters = new ArrayList<>();
    Class<?> cls = TypeUtils.getRawType(type, type);
    LOG.debug("Looking for path/query/header/form/cookie params in " + cls);

    if (chain.hasNext()) {
        SwaggerExtension extension = chain.next();
        LOG.debug("trying extension " + extension);
        parameters = extension.extractParameters(annotations, type, typesToSkip, chain);
    }

    if (!parameters.isEmpty()) {
        for (Parameter parameter : parameters) {
            ParameterProcessor.applyAnnotations(swagger, parameter, type, annotations);
        }
    } else {
        LOG.debug("Looking for body params in " + cls);
        // parameters is guaranteed to be empty at this point, replace it with a mutable collection
        parameters = Lists.newArrayList();
        if (!typesToSkip.contains(type)) {
            Parameter param = ParameterProcessor.applyAnnotations(swagger, null, type, annotations);
            if (param != null) {
                parameters.add(param);
            }
        }
    }
    return parameters;
}
 
Example #10
Source File: FreeIpaClient.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
public Set<DnsZoneList> findDnsZone(String cidr) throws FreeIpaClientException {
    List<Object> flags = List.of();
    Map<String, Object> params = Map.of(
            "sizelimit", 0,
            "pkey_only", true,
            "raw", true,
            "name_from_ip", cidr
    );
    ParameterizedType type = TypeUtils
            .parameterize(Set.class, DnsZoneList.class);
    return (Set<DnsZoneList>) invoke("dnszone_find", flags, params, type).getResult();
}
 
Example #11
Source File: TypeConversionHandlerImpl.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Check to see if the conversion can be done using an explicit conversion
 * @param actual found argument type
 * @param formal expected formal type
 * @return true if actual class can be explicitely converted to expected formal type
 * @since 2.1
 */
@Override
public boolean isExplicitlyConvertible(Type formal, Class actual, boolean possibleVarArg)
{
    /*
     * for consistency, we also have to check standard implicit convertibility
     * since it may not have been checked before by the calling code
     */
    Class formalClass = IntrospectionUtils.getTypeClass(formal);
    if (formalClass != null && formalClass == actual ||
        IntrospectionUtils.isMethodInvocationConvertible(formal, actual, possibleVarArg) ||
        getNeededConverter(formal, actual) != null)
    {
        return true;
    }

    /* Check var arg */
    if (possibleVarArg && TypeUtils.isArrayType(formal))
    {
        if (actual.isArray())
        {
            actual = actual.getComponentType();
        }
        return isExplicitlyConvertible(TypeUtils.getArrayComponentType(formal), actual, false);
    }
    return false;
}
 
Example #12
Source File: MethodMap.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
Match(Method method, int applicability, Class[] unboxedArgs)
{
    this.method = method;
    this.applicability = applicability;
    this.methodTypes = method.getGenericParameterTypes();
    this.specificity = compare(methodTypes, unboxedArgs);
    this.varargs = methodTypes.length > 0 && TypeUtils.isArrayType(methodTypes[methodTypes.length - 1]);
}
 
Example #13
Source File: FreeIpaClient.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
public Set<Role> findAllRole() throws FreeIpaClientException {
    List<Object> flags = List.of();
    Map<String, Object> params = Map.of(
            "sizelimit", 0,
            "timelimit", 0
    );
    ParameterizedType type = TypeUtils
            .parameterize(Set.class, Role.class);
    return (Set<Role>) invoke("role_find", flags, params, type).getResult();
}
 
Example #14
Source File: FreeIpaClient.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
public List<TopologySegment> findTopologySegments(String topologySuffixCn) throws FreeIpaClientException {
    List<Object> flags = List.of(topologySuffixCn);
    Map<String, Object> params = Map.of();
    ParameterizedType type = TypeUtils
            .parameterize(List.class, TopologySegment.class);
    return (List<TopologySegment>) invoke("topologysegment_find", flags, params, type).getResult();
}
 
Example #15
Source File: FreeIpaClient.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
public List<TopologySuffix> findAllTopologySuffixes() throws FreeIpaClientException {
    List<Object> flags = List.of();
    Map<String, Object> params = Map.of();
    ParameterizedType type = TypeUtils
            .parameterize(List.class, TopologySuffix.class);
    return (List<TopologySuffix>) invoke("topologysuffix_find", flags, params, type).getResult();
}
 
Example #16
Source File: FreeIpaClient.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
public Set<DnsRecord> findAllDnsRecordInZone(String dnsZoneName) throws FreeIpaClientException {
    List<Object> flags = List.of(dnsZoneName);
    Map<String, Object> params = Map.of();
    ParameterizedType type = TypeUtils
            .parameterize(Set.class, DnsRecord.class);
    return (Set<DnsRecord>) invoke("dnsrecord_find", flags, params, type).getResult();
}
 
Example #17
Source File: FreeIpaClient.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
public Set<Service> findAllService() throws FreeIpaClientException {
    List<Object> flags = List.of();
    Map<String, Object> params = Map.of(
            "sizelimit", 0,
            "timelimit", 0
    );
    ParameterizedType type = TypeUtils
            .parameterize(Set.class, Service.class);
    return (Set<Service>) invoke("service_find", flags, params, type).getResult();
}
 
Example #18
Source File: FreeIpaClient.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
public Set<User> userFindAll() throws FreeIpaClientException {
    List<Object> flags = List.of();
    Map<String, Object> params = Map.of(
            "sizelimit", 0,
            "timelimit", 0,
            "all", true
    );
    ParameterizedType type = TypeUtils
            .parameterize(Set.class, User.class);
    return (Set<User>) invoke("user_find", flags, params, type).getResult();
}
 
Example #19
Source File: TracepointsTestUtils.java    From tracing-framework with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static MethodTracepointSpec getMethodSpec(Class<?> cls, String methodName)
        throws ClassNotFoundException {
    MethodTracepointSpec.Builder b = MethodTracepointSpec.newBuilder();
    b.setClassName(cls.getName());
    b.setMethodName(methodName);

    Method m = getMethod(cls, methodName);
    for (Class<?> paramClass : m.getParameterTypes()) {
        b.addParamClass(paramClass.getCanonicalName());
    }

    int paramCount = 0;
    for (Type paramType : m.getGenericParameterTypes()) {
        String paramName = String.format("$%d", ++paramCount);
        if (TypeUtils.isArrayType(paramType)) {
            Type arrayOfType = TypeUtils.getArrayComponentType(paramType);
            String arrayOf = TypeUtils.toString(arrayOfType);
            b.addAdviceArgBuilder().getMultiBuilder().setLiteral(paramName).setPostProcess("{}")
                    .setType(arrayOf);
        } else if (TypeUtils.isAssignable(paramType, Collection.class)) {
            ParameterizedType pt = (ParameterizedType) paramType;
            Type collectionOfType = pt.getActualTypeArguments()[0]; // doesn't work if multiple type params, but
                                                                    // good enough
            String collectionOf = TypeUtils.toString(collectionOfType);
            b.addAdviceArgBuilder().getMultiBuilder().setLiteral(paramName).setPostProcess("{}")
                    .setType(collectionOf);
        } else {
            b.addAdviceArgBuilder().setLiteral(paramName);
        }
    }

    return b.build();
}
 
Example #20
Source File: MCRRestObjects.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON + ";charset=UTF-8" })
@MCRCacheControl(maxAge = @MCRCacheControl.Age(time = 1, unit = TimeUnit.DAYS),
    sMaxAge = @MCRCacheControl.Age(time = 1, unit = TimeUnit.DAYS))
@Path("/{" + PARAM_MCRID + "}/versions")
@Operation(
    summary = "Returns MCRObject with the given " + PARAM_MCRID + ".",
    responses = @ApiResponse(content = @Content(
        array = @ArraySchema(uniqueItems = true, schema = @Schema(implementation = MCRMetadataVersion.class)))),
    tags = MCRRestUtils.TAG_MYCORE_OBJECT)
@JacksonFeatures(serializationDisable = { SerializationFeature.WRITE_DATES_AS_TIMESTAMPS })
@XmlElementWrapper(name = "versions")
public Response getObjectVersions(@Parameter(example = "mir_mods_00004711") @PathParam(PARAM_MCRID) MCRObjectID id)
    throws IOException {
    long modified = MCRXMLMetadataManager.instance().getLastModified(id);
    if (modified < 0) {
        throw MCRErrorResponse.fromStatus(Response.Status.NOT_FOUND.getStatusCode())
            .withErrorCode(MCRErrorCodeConstants.MCROBJECT_NOT_FOUND)
            .withMessage("MCRObject " + id + " not found")
            .toException();
    }
    Date lastModified = new Date(modified);
    Optional<Response> cachedResponse = MCRRestUtils.getCachedResponse(request, lastModified);
    if (cachedResponse.isPresent()) {
        return cachedResponse.get();
    }
    List<MCRMetadataVersion> versions = MCRXMLMetadataManager.instance().getVersionedMetaData(id)
        .listVersions();
    return Response.ok()
        .entity(new GenericEntity<>(versions, TypeUtils.parameterize(List.class, MCRMetadataVersion.class)))
        .lastModified(lastModified)
        .build();
}
 
Example #21
Source File: TestParamUtils.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void testGenericTypeInheritanceWithMethodUtils() throws Exception {
  List<Method> methods = MethodUtils.findSwaggerMethods(MyEndpoint.class);
  Assert.assertEquals(5, methods.size());
  assertEquals(PersonBean.class, ParamUtils
      .getGenericParameterType(MyEndpoint.class, methods.get(0).getDeclaringClass(),
          methods.get(0).getGenericReturnType())); // actual
  assertEquals(PersonBean.class, ParamUtils
      .getGenericParameterType(MyEndpoint.class, methods.get(0),
          methods.get(0).getParameters()[0])); // actual
  assertEquals(PersonBean.class, ParamUtils
      .getGenericParameterType(MyEndpoint.class, methods.get(1).getDeclaringClass(),
          methods.get(1).getGenericReturnType())); // hello
  assertEquals(PersonBean.class, ParamUtils
      .getGenericParameterType(MyEndpoint.class, methods.get(1),
          methods.get(1).getParameters()[0])); // hello
  assertEquals(PersonBean[].class, ParamUtils
      .getGenericParameterType(MyEndpoint.class, methods.get(2).getDeclaringClass(),
          methods.get(2).getGenericReturnType())); // helloBody
  assertEquals(PersonBean[].class, ParamUtils
      .getGenericParameterType(MyEndpoint.class, methods.get(2),
          methods.get(2).getParameters()[0])); // helloBody
  assertEquals(TypeUtils.parameterize(List.class, PersonBean.class), ParamUtils
      .getGenericParameterType(MyEndpoint.class, methods.get(3).getDeclaringClass(),
          methods.get(3).getGenericReturnType())); // helloList
  assertEquals(TypeUtils.parameterize(List.class, PersonBean.class), ParamUtils
      .getGenericParameterType(MyEndpoint.class, methods.get(3),
          methods.get(3).getParameters()[0])); // helloList
  assertEquals(TypeUtils.parameterize(List.class, MultipartFile.class), ParamUtils
      .getGenericParameterType(MyEndpoint.class, methods.get(4).getDeclaringClass(),
          methods.get(4).getGenericReturnType())); // parentHello
  assertEquals(TypeUtils.parameterize(List.class, MultipartFile.class), ParamUtils
      .getGenericParameterType(MyEndpoint.class, methods.get(4),
          methods.get(4).getParameters()[0])); // parentHello
}
 
Example #22
Source File: TypeTypeConverterTest.java    From yare with MIT License 5 votes vote down vote up
private static Stream<Arguments> conversionParameters() {
    return Stream.of(
            Arguments.of("String", String.class),
            Arguments.of("List<String>", TypeUtils.parameterize(List.class, String.class)),
            Arguments.of("Object", Object.class),
            Arguments.of("List<String>", TypeUtils.parameterize(List.class, String.class)),
            Arguments.of("Map<String,Object>", TypeUtils.parameterize(Map.class, String.class, Object.class)),
            Arguments.of(NestedClass.class.getCanonicalName(), NestedClass.class)
    );
}
 
Example #23
Source File: TypeTypeConverterTest.java    From yare with MIT License 5 votes vote down vote up
@Test
void shouldProperlyConvertNestedGenericToString() {
    String converted = typeConverter.toString(null,
            TypeUtils.parameterize(Map.class, String.class, TypeUtils.parameterize(List.class, Object.class)));

    assertThat(converted).isEqualTo("Map<String,List<Object>>");
}
 
Example #24
Source File: DefaultArgumentValueResolver.java    From yare with MIT License 5 votes vote down vote up
@Override
public Object resolve(VariableResolver variableResolver, Argument argument) {
    if (argument instanceof Argument.Value) {
        return ((Argument.Value) argument).getValue();
    }
    if (argument instanceof Argument.Values) {
        return ((Argument.Values) argument).getArguments().stream()
                .map(a -> resolve(variableResolver, a))
                .collect(Collectors.toList());
    }
    if (argument instanceof Argument.Reference) {
        if (!(variableResolver instanceof PredicateContext)) {
            throw new IllegalArgumentException("Expected PredicateContext as VariableResolver");
        }
        Argument.Reference reference = (Argument.Reference) argument;
        String path = reference.getReference();
        int dotIndex = path.indexOf(".");
        if (dotIndex == -1) {
            return variableResolver.resolve(path);
        }
        String identifier = path.substring(0, dotIndex);
        path = path.substring(dotIndex + 1);
        Object resolvedValue = variableResolver.resolve(identifier);
        Class referenceType = TypeUtils.getRawType(reference.getReferenceType(), null);
        referenceType = resolvedValue != null && Object.class.equals(referenceType)
                ? resolvedValue.getClass()
                : referenceType;
        return FieldReferringClassFactory.create(referenceType, identifier, path).get((PredicateContext) variableResolver);
    }
    if (argument instanceof Argument.Invocation) {
        if (!(variableResolver instanceof ProcessingContext)) {
            throw new IllegalArgumentException("Expected ProcessingContext as VariableResolver");
        }
        ProcessingContext processingContext = (ProcessingContext) variableResolver;
        Invocation<ProcessingContext, Object> value = processingInvocationFactory.create((Argument.Invocation) argument);
        return value.proceed(processingContext);
    }

    throw new IllegalArgumentException(String.format("Unsupported argument type %s", argument.getClass()));
}
 
Example #25
Source File: FieldReferMetadataCreator.java    From yare with MIT License 5 votes vote down vote up
@Override
public ReferMetadata getReferMetadata(Type type, String path) {
    String pathWithoutOperator = path.replace("[*]", "");
    Type refType;
    try {
        refType = TypeUtils.getRawType(type, null).getField(pathWithoutOperator).getGenericType();
    } catch (NoSuchFieldException e) {
        throw new RuntimeException(e);
    }
    return new ReferMetadata(refType, pathWithoutOperator, path);
}
 
Example #26
Source File: FieldReferMetadataCreator.java    From yare with MIT License 5 votes vote down vote up
@Override
public boolean isApplicable(Type type, String ref) {
    Field field;
    try {
        field = TypeUtils.getRawType(type, null).getField(ref);
    } catch (NoSuchFieldException e) {
        return false;
    }
    return Modifier.isPublic(field.getModifiers());
}
 
Example #27
Source File: LtZonedDateTime.java    From yare with MIT License 5 votes vote down vote up
private boolean isApplicable(Expression.Operator operator, ValueProvider[] valueProviders) {
    return Lt.OPERATOR_NAME.equals(operator.getCall()) &&
            operator.getArguments().size() == 2 &&
            valueProviders.length == 2 &&
            ZonedDateTime.class.isAssignableFrom(TypeUtils.getRawType(valueProviders[0].getType(), null)) &&
            ZonedDateTime.class.isAssignableFrom(TypeUtils.getRawType(valueProviders[1].getType(), null));
}
 
Example #28
Source File: ReflectUtil.java    From mPaaS with Apache License 2.0 5 votes vote down vote up
/**
 * 将type中的变量参数实例化
 *
 * @param type
 * @param resolver
 *            将变量转换成实际的类的方法
 * @return
 */
public static Type parameterize(Type type,
                                Function<TypeVariable<?>, Type> resolver) {
    // 类:String
    if (type instanceof Class) {
        return type;
    }
    // 变量:E
    if (type instanceof TypeVariable) {
        return resolver.apply((TypeVariable<?>) type);
    }
    // 泛型:List<E>
    if (type instanceof ParameterizedType) {
        ParameterizedType paramType = (ParameterizedType) type;
        Type[] oriTypes = paramType.getActualTypeArguments();
        // 若参数中出现了泛型或变量则使用递归
        boolean recursion = false;
        for (Type oriType : oriTypes) {
            if (!(oriType instanceof Class)) {
                recursion = true;
                break;
            }
        }
        if (recursion) {
            Type[] actTypes = new Type[oriTypes.length];
            for (int i = 0; i < oriTypes.length; i++) {
                actTypes[i] = parameterize(oriTypes[i], resolver);
            }
            return TypeUtils.parameterize((Class<?>) paramType.getRawType(),
                    actTypes);
        } else {
            return type;
        }
    }
    throw new RuntimeException("不支持的参数类型:" + type.getClass().getName());
}
 
Example #29
Source File: LeComparable.java    From yare with MIT License 5 votes vote down vote up
private boolean isApplicable(Expression.Operator operator, ValueProvider[] valueProviders) {
    return Le.OPERATOR_NAME.equals(operator.getCall()) &&
            operator.getArguments().size() == 2 &&
            valueProviders.length == 2 &&
            Comparable.class.isAssignableFrom(TypeUtils.getRawType(valueProviders[0].getType(), null)) &&
            Comparable.class.isAssignableFrom(TypeUtils.getRawType(valueProviders[1].getType(), null));
}
 
Example #30
Source File: EqObjectArray.java    From yare with MIT License 5 votes vote down vote up
private boolean isApplicable(Expression.Operator operator, ValueProvider[] valueProviders) {
    return Eq.OPERATOR_NAME.equals(operator.getCall()) &&
            operator.getArguments().size() == 2 &&
            valueProviders.length == 2 &&
            TypeUtils.getRawType(valueProviders[0].getType(), null).isArray() &&
            TypeUtils.getRawType(valueProviders[1].getType(), null).isArray();
}