当前位置: 首页>>代码示例>>Java>>正文


Java ReflectionUtils类代码示例

本文整理汇总了Java中io.swagger.util.ReflectionUtils的典型用法代码示例。如果您正苦于以下问题:Java ReflectionUtils类的具体用法?Java ReflectionUtils怎么用?Java ReflectionUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ReflectionUtils类属于io.swagger.util包,在下文中一共展示了ReflectionUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyConsumes

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
@Override
public void applyConsumes(ReaderContext context, Operation operation, Method method) {
	final List<String> consumes = new ArrayList<String>();
	final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);

	if (apiOperation != null) {
		consumes.addAll(parseStringValues(apiOperation.consumes()));
	}

	if (consumes.isEmpty()) {
		final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
		if (apiAnnotation != null) {
			consumes.addAll(parseStringValues(apiAnnotation.consumes()));
		}
		consumes.addAll(context.getParentConsumes());
	}

	for (String consume : consumes) {
		operation.consumes(consume);
	}

}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:23,代码来源:DubboReaderExtension.java

示例2: applyProduces

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
@Override
public void applyProduces(ReaderContext context, Operation operation, Method method) {
	final List<String> produces = new ArrayList<String>();
	final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);

	if (apiOperation != null) {
		produces.addAll(parseStringValues(apiOperation.produces()));
	}

	if (produces.isEmpty()) {
		final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
		if (apiAnnotation != null) {
			produces.addAll(parseStringValues(apiAnnotation.produces()));
		}
		produces.addAll(context.getParentProduces());
	}

	for (String produce : produces) {
		operation.produces(produce);
	}

}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:23,代码来源:DubboReaderExtension.java

示例3: applySchemes

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
@Override
public void applySchemes(ReaderContext context, Operation operation, Method method) {
	final List<Scheme> schemes = new ArrayList<Scheme>();
	final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
	final Api apiAnnotation = context.getCls().getAnnotation(Api.class);

	if (apiOperation != null) {
		schemes.addAll(parseSchemes(apiOperation.protocols()));
	}

	if (schemes.isEmpty() && apiAnnotation != null) {
		schemes.addAll(parseSchemes(apiAnnotation.protocols()));
	}

	for (Scheme scheme : schemes) {
		operation.scheme(scheme);
	}

}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:20,代码来源:DubboReaderExtension.java

示例4: parseResponseHeaders

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
private static Map<String, Property> parseResponseHeaders(ReaderContext context,
		ResponseHeader[] headers) {
	Map<String, Property> responseHeaders = null;
	for (ResponseHeader header : headers) {
		final String name = header.name();
		if (StringUtils.isNotEmpty(name)) {
			if (responseHeaders == null) {
				responseHeaders = new HashMap<String, Property>();
			}
			final Class<?> cls = header.response();
			if (!ReflectionUtils.isVoid(cls)) {
				final Property property = ModelConverters.getInstance().readAsProperty(cls);
				if (property != null) {
					final Property responseProperty = ContainerWrapper.wrapContainer(
							header.responseContainer(), property, ContainerWrapper.ARRAY,
							ContainerWrapper.LIST, ContainerWrapper.SET);
					responseProperty.setDescription(header.description());
					responseHeaders.put(name, responseProperty);
					appendModels(context.getSwagger(), cls);
				}
			}
		}
	}
	return responseHeaders;
}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:26,代码来源:DubboReaderExtension.java

示例5: parseResponseHeaders

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
private static Map<String, Property> parseResponseHeaders(Swagger swagger, ReaderContext context, ResponseHeader[] headers) {
    Map<String, Property> responseHeaders = null;
    for (ResponseHeader header : headers) {
        final String name = header.name();
        if (StringUtils.isNotEmpty(name)) {
            if (responseHeaders == null) {
                responseHeaders = new HashMap<String, Property>();
            }
            final Class<?> cls = header.response();
            if (!ReflectionUtils.isVoid(cls)) {
                final Property property = ModelConverters.getInstance().readAsProperty(cls);
                if (property != null) {
                    final Property responseProperty = ContainerWrapper.wrapContainer(header.responseContainer(),
                            property, ContainerWrapper.ARRAY, ContainerWrapper.LIST, ContainerWrapper.SET);
                    responseProperty.setDescription(header.description());
                    responseHeaders.put(name, responseProperty);
                    appendModels(swagger, cls);
                }
            }
        }
    }
    return responseHeaders;
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:24,代码来源:ControllerReaderExtension.java

示例6: applyConsumes

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
public void applyConsumes(ReaderContext context, Operation operation, Method method) {
    final List<String> consumes = new ArrayList<String>();
    final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);

    if (apiOperation != null) {
        consumes.addAll(parseStringValues(apiOperation.consumes()));
    }

    if (consumes.isEmpty()) {
        final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
        if (apiAnnotation != null) {
            consumes.addAll(parseStringValues(apiAnnotation.consumes()));
        }
        consumes.addAll(context.getParentConsumes());
    }

    for (String consume : consumes) {
        operation.consumes(consume);
    }
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:21,代码来源:ControllerReaderExtension.java

示例7: applyProduces

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
public void applyProduces(ReaderContext context, Operation operation, Method method) {
    final List<String> produces = new ArrayList<String>();
    final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);

    if (apiOperation != null) {
        produces.addAll(parseStringValues(apiOperation.produces()));
    }

    if (produces.isEmpty()) {
        final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
        if (apiAnnotation != null) {
            produces.addAll(parseStringValues(apiAnnotation.produces()));
        }
        produces.addAll(context.getParentProduces());
    }

    for (String produce : produces) {
        operation.produces(produce);
    }
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:21,代码来源:ControllerReaderExtension.java

示例8: applySchemes

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
public void applySchemes(ReaderContext context, Operation operation, Method method) {
    final List<Scheme> schemes = new ArrayList<Scheme>();
    final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
    final Api apiAnnotation = context.getCls().getAnnotation(Api.class);

    if (apiOperation != null) {
        schemes.addAll(parseSchemes(apiOperation.protocols()));
    }

    if (schemes.isEmpty() && apiAnnotation != null) {
        schemes.addAll(parseSchemes(apiAnnotation.protocols()));
    }

    for (Scheme scheme : schemes) {
        operation.scheme(scheme);
    }
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:18,代码来源:ControllerReaderExtension.java

示例9: applySecurityRequirements

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
public void applySecurityRequirements(ReaderContext context, Operation operation, Method method) {
    final List<SecurityRequirement> securityRequirements = new ArrayList<SecurityRequirement>();
    final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
    final Api apiAnnotation = context.getCls().getAnnotation(Api.class);

    if (apiOperation != null) {
        securityRequirements.addAll(parseAuthorizations(apiOperation.authorizations()));
    }

    if (securityRequirements.isEmpty() && apiAnnotation != null) {
        securityRequirements.addAll(parseAuthorizations(apiAnnotation.authorizations()));
    }

    for (SecurityRequirement securityRequirement : securityRequirements) {
        operation.security(securityRequirement);
    }
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:18,代码来源:ControllerReaderExtension.java

示例10: getOperationPaths

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
public static Set<String> getOperationPaths(final Class<?> cls) {
    final Set<String> operationPaths = new HashSet<String>();
    final javax.ws.rs.Path apiPath = cls.getAnnotation(javax.ws.rs.Path.class);
    final Method methods[] = cls.getMethods();
    for (Method method : methods) {
        if (ReflectionUtils.isOverriddenMethod(method, cls)) {
            continue;
        }
        final javax.ws.rs.Path methodPath = getAnnotation(method, javax.ws.rs.Path.class);
        String operationPath = getPath(apiPath, methodPath);
        final Map<String, String> regexMap = new HashMap<String, String>();
        operationPath = PathUtils.parsePath(operationPath, regexMap);
        if (operationPath != null) {
            operationPaths.add(operationPath);
        }
    }
    return Collections.unmodifiableSet(operationPaths);
}
 
开发者ID:WASdev,项目名称:tool.swagger.docgen,代码行数:19,代码来源:JAXRSAnnotationsUtil.java

示例11: createParameter

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
public static Parameter createParameter(Swagger swagger, ApiImplicitParam paramAnnotation) {
  Parameter parameter = createParameterInstance(paramAnnotation);
  Type dataType = ReflectionUtils.typeFromString(paramAnnotation.dataType());
  parameter = ParameterProcessor.applyAnnotations(swagger,
      parameter,
      dataType,
      Arrays.asList(paramAnnotation));
  return parameter;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:10,代码来源:AnnotationUtils.java

示例12: createResponseProperty

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
protected Property createResponseProperty() {
  Type responseType = providerMethod.getReturnType();
  if (ReflectionUtils.isVoid(responseType)) {
    return null;
  }

  ResponseTypeProcessor processor = context.findResponseTypeProcessor(responseType);
  return processor.process(this);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:10,代码来源:OperationGenerator.java

示例13: getHttpMethod

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
@Override
public String getHttpMethod(ReaderContext context, Method method) {
    ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
    if (apiOperation != null && apiOperation.httpMethod() != null && !apiOperation.httpMethod().isEmpty()) {
        return apiOperation.httpMethod();
    }
    else {
        // JAX-RS annotations
        GET get = ReflectionUtils.getAnnotation(method, GET.class);
        if (get != null)
            return "get";
        PUT put = ReflectionUtils.getAnnotation(method, PUT.class);
        if (put != null) {
            if (method.getName().equalsIgnoreCase("patch"))
                return "patch";
            return "put";
        }
        POST post = ReflectionUtils.getAnnotation(method, POST.class);
        if (post != null)
            return "post";
        DELETE delete = ReflectionUtils.getAnnotation(method, DELETE.class);
        if (delete != null)
            return "delete";

        // return our method name
        if (RestService.class.isAssignableFrom(method.getDeclaringClass()))
            return method.getName();

        return null;
    }
}
 
开发者ID:limberest,项目名称:limberest,代码行数:32,代码来源:SwaggerReaderExtension.java

示例14: getPath

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
@Override
public String getPath(ReaderContext context, Method method) {
    String p = null;
    Api apiAnnotation = context.getCls().getAnnotation(Api.class);
    ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
    String operationPath = apiOperation == null ? null : apiOperation.nickname();
    if (operationPath != null && !operationPath.isEmpty()) {
        // same logic as ServletReaderExtension
        p = PathUtils.collectPath(context.getParentPath(),
                apiAnnotation == null ? null : apiAnnotation.value(), operationPath);
    }
    else {
        // try JAX-RS annotations
        Path parentPath = ReflectionUtils.getAnnotation(method.getDeclaringClass(), Path.class);
        if (parentPath != null && parentPath.value() != null && !parentPath.value().isEmpty()) {
            p = parentPath.value();
        }
        Path path = ReflectionUtils.getAnnotation(method, Path.class);
        if (path != null && path.value() != null && !path.value().isEmpty()) {
            if (p == null)
                p = path.value();
            else {
                if (path.value().startsWith("/"))
                    p += path.value();
                else
                    p = p + "/" + path.value();
            }
        }
    }
    return p;
}
 
开发者ID:limberest,项目名称:limberest,代码行数:32,代码来源:SwaggerReaderExtension.java

示例15: applyOperationId

import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
@Override
public void applyOperationId(Operation operation, Method method) {
    ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
    if (apiOperation != null && StringUtils.isNotBlank(apiOperation.nickname())) {
        operation.operationId(apiOperation.nickname());
    } 
}
 
开发者ID:limberest,项目名称:limberest,代码行数:8,代码来源:SwaggerReaderExtension.java


注:本文中的io.swagger.util.ReflectionUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。