java.lang.Class.toGenericString()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(14.8k)|赞(0)|评价(0)|浏览(285)

本文整理了Java中java.lang.Class.toGenericString()方法的一些代码示例,展示了Class.toGenericString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Class.toGenericString()方法的具体详情如下:
包路径:java.lang.Class
类名称:Class
方法名:toGenericString

Class.toGenericString介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

  1. public static Method getCombineFunction(Class<?> clazz, Class<?> stateClass)
  2. {
  3. // Only include methods that match this state class
  4. List<Method> combineFunctions = FunctionsParserHelper.findPublicStaticMethodsWithAnnotation(clazz, CombineFunction.class).stream()
  5. .filter(method -> method.getParameterTypes()[AggregationImplementation.Parser.findAggregationStateParamId(method, 0)] == stateClass)
  6. .filter(method -> method.getParameterTypes()[AggregationImplementation.Parser.findAggregationStateParamId(method, 1)] == stateClass)
  7. .collect(toImmutableList());
  8. checkArgument(combineFunctions.size() == 1, String.format("There must be exactly one @CombineFunction in class %s for the @AggregationState %s ", clazz.toGenericString(), stateClass.toGenericString()));
  9. return getOnlyElement(combineFunctions);
  10. }

代码示例来源:origin: prestodb/presto

  1. private static Optional<Method> getAggregationStateSerializerFactory(Class<?> aggregationDefinition, Class<?> stateClass)
  2. {
  3. // Only include methods that match this state class
  4. List<Method> stateSerializerFactories = FunctionsParserHelper.findPublicStaticMethodsWithAnnotation(aggregationDefinition, AggregationStateSerializerFactory.class).stream()
  5. .filter(method -> ((AggregationStateSerializerFactory) method.getAnnotation(AggregationStateSerializerFactory.class)).value().equals(stateClass))
  6. .collect(toImmutableList());
  7. if (stateSerializerFactories.isEmpty()) {
  8. return Optional.empty();
  9. }
  10. checkArgument(stateSerializerFactories.size() == 1,
  11. String.format(
  12. "Expect at most 1 @AggregationStateSerializerFactory(%s.class) annotation, found %s in %s",
  13. stateClass.toGenericString(),
  14. stateSerializerFactories.size(),
  15. aggregationDefinition.toGenericString()));
  16. return Optional.of(getOnlyElement(stateSerializerFactories));
  17. }

代码示例来源:origin: stackoverflow.com

  1. import java.util.ArrayList;
  2. class MyClass {
  3. ArrayList<String> stringList;
  4. public ArrayList<String> getStringList() {
  5. return stringList;
  6. }
  7. }
  8. public class Foo {
  9. public static void main(String... args) throws NoSuchMethodException {
  10. ArrayList<Integer> intList = new ArrayList<>();
  11. System.out.println(intList.getClass().toGenericString());
  12. System.out.println(MyClass.class.getMethod("getStringList").toGenericString());
  13. }
  14. }

代码示例来源:origin: prestosql/presto

  1. public static Method getCombineFunction(Class<?> clazz, Class<?> stateClass)
  2. {
  3. // Only include methods that match this state class
  4. List<Method> combineFunctions = FunctionsParserHelper.findPublicStaticMethodsWithAnnotation(clazz, CombineFunction.class).stream()
  5. .filter(method -> method.getParameterTypes()[AggregationImplementation.Parser.findAggregationStateParamId(method, 0)] == stateClass)
  6. .filter(method -> method.getParameterTypes()[AggregationImplementation.Parser.findAggregationStateParamId(method, 1)] == stateClass)
  7. .collect(toImmutableList());
  8. checkArgument(combineFunctions.size() == 1, String.format("There must be exactly one @CombineFunction in class %s for the @AggregationState %s ", clazz.toGenericString(), stateClass.toGenericString()));
  9. return getOnlyElement(combineFunctions);
  10. }

代码示例来源:origin: in.erail/glue

  1. @Override
  2. public String toString() {
  3. return MoreObjects
  4. .toStringHelper(this)
  5. .add("mFactoryClass", mFactoryClass)
  6. .add("mFactoryInstance", mFactoryInstance)
  7. .add("mFactoryMethodName", mFactoryMethodName)
  8. .add("mFactoryParamValues", mFactoryParamValues != null ? Joiner.on(",").join(mFactoryParamValues) : null)
  9. .add("mFactoryParamType", mFactoryParamType != null ? Joiner.on(",").join(mFactoryParamType) : null)
  10. .add("mParamType", mParamType != null ? Joiner.on(",").join(mParamType) : null)
  11. .add("mComponentPath", mComponentPath)
  12. .add("mFactoryEnable", mFactoryEnable)
  13. .add("mMethod", mMethod != null ? mMethod.getName() : null)
  14. .add("mMethodParam", mMethodParam != null ? Joiner.on(",").join(mMethodParam) : null)
  15. .add("mMethodClass", mMethodClass != null ? mMethodClass.getCanonicalName() : null)
  16. .add("mMethodClassInstance", mMethodClassInstance != null ? mMethodClassInstance.getClass().toGenericString() : null)
  17. .toString();
  18. }

代码示例来源:origin: io.prestosql/presto-main

  1. public static Method getCombineFunction(Class<?> clazz, Class<?> stateClass)
  2. {
  3. // Only include methods that match this state class
  4. List<Method> combineFunctions = FunctionsParserHelper.findPublicStaticMethodsWithAnnotation(clazz, CombineFunction.class).stream()
  5. .filter(method -> method.getParameterTypes()[AggregationImplementation.Parser.findAggregationStateParamId(method, 0)] == stateClass)
  6. .filter(method -> method.getParameterTypes()[AggregationImplementation.Parser.findAggregationStateParamId(method, 1)] == stateClass)
  7. .collect(toImmutableList());
  8. checkArgument(combineFunctions.size() == 1, String.format("There must be exactly one @CombineFunction in class %s for the @AggregationState %s ", clazz.toGenericString(), stateClass.toGenericString()));
  9. return getOnlyElement(combineFunctions);
  10. }

代码示例来源:origin: io.prestosql/presto-main

  1. private static Optional<Method> getAggregationStateSerializerFactory(Class<?> aggregationDefinition, Class<?> stateClass)
  2. {
  3. // Only include methods that match this state class
  4. List<Method> stateSerializerFactories = FunctionsParserHelper.findPublicStaticMethodsWithAnnotation(aggregationDefinition, AggregationStateSerializerFactory.class).stream()
  5. .filter(method -> ((AggregationStateSerializerFactory) method.getAnnotation(AggregationStateSerializerFactory.class)).value().equals(stateClass))
  6. .collect(toImmutableList());
  7. if (stateSerializerFactories.isEmpty()) {
  8. return Optional.empty();
  9. }
  10. checkArgument(stateSerializerFactories.size() == 1,
  11. String.format(
  12. "Expect at most 1 @AggregationStateSerializerFactory(%s.class) annotation, found %s in %s",
  13. stateClass.toGenericString(),
  14. stateSerializerFactories.size(),
  15. aggregationDefinition.toGenericString()));
  16. return Optional.of(getOnlyElement(stateSerializerFactories));
  17. }

代码示例来源:origin: NyaaCat/RPGItems-reloaded

  1. public static void registerOverride(NamespacedKey origin, NamespacedKey override) {
  2. if (overrides.containsKey(origin)) {
  3. throw new IllegalArgumentException("Cannot override a already overridden power: " + origin + " " + override);
  4. }
  5. Class<? extends Power> originPower = getPower(origin);
  6. Class<? extends Power> overridePower = getPower(override);
  7. if (originPower == null) {
  8. throw new IllegalArgumentException("Overriding not registered power: " + origin);
  9. }
  10. if (overridePower == null) {
  11. throw new IllegalArgumentException("Override not found: " + override);
  12. }
  13. if (!originPower.isAssignableFrom(overridePower)) {
  14. throw new IllegalArgumentException("Not overrideable: " + origin + "@" + originPower.toGenericString() + " " + override + "@" + overridePower.toGenericString());
  15. }
  16. overrides.put(origin, override);
  17. }
  18. }

代码示例来源:origin: bonitasoft/bonita-engine

  1. public Object invokeJavaMethod(final String typeOfValueToSet, final Object valueToSetObjectWith, final Object objectToInvokeJavaMethodOn,
  2. final String operator, final String operatorParameterClassName) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException,
  3. IllegalArgumentException, InvocationTargetException {
  4. final Class<?> expressionResultType = getClassOrPrimitiveClass(typeOfValueToSet);
  5. final Class<?> dataType = Thread.currentThread().getContextClassLoader().loadClass(objectToInvokeJavaMethodOn.getClass().getName());
  6. final Method method = MethodUtils.getMatchingAccessibleMethod(dataType, operator, new Class[]{getClassOrPrimitiveClass(operatorParameterClassName)});
  7. if (method != null) {
  8. final Object o = dataType.cast(objectToInvokeJavaMethodOn);
  9. method.invoke(o, expressionResultType.cast(valueToSetObjectWith));
  10. return o;
  11. } else {
  12. throw new NoSuchMethodException(dataType.toGenericString() + "." + operator + "(" + operatorParameterClassName + ").");
  13. }
  14. }
  15. }

代码示例来源:origin: prestosql/presto

  1. private static Optional<Method> getAggregationStateSerializerFactory(Class<?> aggregationDefinition, Class<?> stateClass)
  2. {
  3. // Only include methods that match this state class
  4. List<Method> stateSerializerFactories = FunctionsParserHelper.findPublicStaticMethodsWithAnnotation(aggregationDefinition, AggregationStateSerializerFactory.class).stream()
  5. .filter(method -> ((AggregationStateSerializerFactory) method.getAnnotation(AggregationStateSerializerFactory.class)).value().equals(stateClass))
  6. .collect(toImmutableList());
  7. if (stateSerializerFactories.isEmpty()) {
  8. return Optional.empty();
  9. }
  10. checkArgument(stateSerializerFactories.size() == 1,
  11. String.format(
  12. "Expect at most 1 @AggregationStateSerializerFactory(%s.class) annotation, found %s in %s",
  13. stateClass.toGenericString(),
  14. stateSerializerFactories.size(),
  15. aggregationDefinition.toGenericString()));
  16. return Optional.of(getOnlyElement(stateSerializerFactories));
  17. }

代码示例来源:origin: neuhalje/bouncy-gpg

  1. /**
  2. * The default strategy to search for keys is to *just* search for the email address (the part
  3. * between &lt; and &gt;).
  4. *
  5. * Set this flag to search for any part in the user id.
  6. *
  7. * @param strategy instance to use
  8. *
  9. * @return next build step
  10. */
  11. public WithAlgorithmSuite withKeySelectionStrategy(final KeySelectionStrategy strategy) {
  12. requireNonNull(strategy, "strategy must not be null");
  13. Preconditions.checkState(
  14. selectUidByEMailOnly == null && dateOfTimestampVerification == null,
  15. "selectUidByAnyUidPart/setReferenceDateForKeyValidityTo cannot be used together"
  16. + " with 'withKeySelectionStrategy' ");
  17. this.keySelectionStrategy = strategy;
  18. LOGGER.trace("WithKeySelectionStrategy: override strategy to {}",
  19. strategy.getClass().toGenericString());
  20. return this;
  21. }

代码示例来源:origin: bonitasoft/bonita-engine

  1. public Object invokeJavaMethod(final String typeOfValueToSet, final Object valueToSetObjectWith, final Object objectToInvokeJavaMethodOn,
  2. final String operator, final String operatorParameterClassName) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException,
  3. IllegalArgumentException, InvocationTargetException {
  4. final Class<?> expressionResultType = getClassOrPrimitiveClass(typeOfValueToSet);
  5. final Class<?> dataType = Thread.currentThread().getContextClassLoader().loadClass(objectToInvokeJavaMethodOn.getClass().getName());
  6. final Method method = MethodUtils.getMatchingAccessibleMethod(dataType, operator, new Class[]{getClassOrPrimitiveClass(operatorParameterClassName)});
  7. if (method != null) {
  8. final Object o = dataType.cast(objectToInvokeJavaMethodOn);
  9. method.invoke(o, expressionResultType.cast(valueToSetObjectWith));
  10. return o;
  11. } else {
  12. throw new NoSuchMethodException(dataType.toGenericString() + "." + operator + "(" + operatorParameterClassName + ").");
  13. }
  14. }
  15. }

代码示例来源:origin: org.jrebirth.af/core

  1. /**
  2. * Gets the value.
  3. *
  4. * @param object the object
  5. * @param method the method
  6. * @param cls the cls
  7. *
  8. * @param <T> the generic type
  9. *
  10. * @return the value
  11. */
  12. @SuppressWarnings("unchecked")
  13. private <T> Optional<T> getValue(Object object, Supplier<Object> method, Class<T> cls) {
  14. T source = null;
  15. if (cls.isInstance(method.get())) {
  16. source = (T) method.get();
  17. } else {
  18. if (CoreParameters.DEVELOPER_MODE.get()) {
  19. throw new CoreRuntimeException("Cannot cast object " + method.get() + " to " + cls.toGenericString());
  20. }
  21. }
  22. return Optional.ofNullable(source);
  23. }

代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.api

  1. @Override
  2. public String getMessage()
  3. {
  4. String typeNames = typesString();
  5. String primary = primaryType == null ? "" : " primary: " + primaryType.toGenericString() + NL;
  6. String methodName = memberString();
  7. String message = super.getMessage() == null ? "" : " message: " + super.getMessage() + NL;
  8. String fragment = fragmentClass == null ? "" : " fragmentClass: " + fragmentClass.getName() + NL;
  9. String valueType = this.valueType == null ? "" : " valueType: " + this.valueType.getTypeName() + NL;
  10. String module = this.module == null ? "" : " layer: " + this.module.layer().name() + NL + " module: "
  11. + this.module.name() + NL;
  12. return message + module + primary + fragment + methodName + valueType + typeNames;
  13. }

代码示例来源:origin: apache/attic-polygene-java

  1. @Override
  2. public String getMessage()
  3. {
  4. String typeNames = typesString();
  5. String primary = primaryType == null ? "" : " primary: " + primaryType.toGenericString() + NL;
  6. String methodName = memberString();
  7. String message = super.getMessage() == null ? "" : " message: " + super.getMessage() + NL;
  8. String fragment = fragmentClass == null ? "" : " fragmentClass: " + fragmentClass.getName() + NL;
  9. String valueType = this.valueType == null ? "" : " valueType: " + this.valueType.getTypeName() + NL;
  10. String module = this.module == null ? "" : " layer: " + this.module.layer().name() + NL + " module: "
  11. + this.module.name() + NL;
  12. return message + module + primary + fragment + methodName + valueType + typeNames;
  13. }

代码示例来源:origin: eclipse/kapua

  1. /**
  2. * Check the exception that was caught. In case the exception was expected the type and message is shown in the cucumber logs.
  3. * Otherwise the exception is rethrown failing the test and dumping the stack trace to help resolving problems.
  4. */
  5. public void verifyException(Exception ex)
  6. throws Exception {
  7. boolean exceptionExpected = stepData.contains("ExceptionExpected") ? (boolean)stepData.get("ExceptionExpected") : false;
  8. String exceptionName = stepData.contains("ExceptionName") ? (String)stepData.get("ExceptionName") : "";
  9. String exceptionMessage = stepData.contains("ExceptionMessage") ? (String)stepData.get("ExceptionMessage") : "";
  10. if (!exceptionExpected ||
  11. (!exceptionName.isEmpty() && !ex.getClass().toGenericString().contains(exceptionName)) ||
  12. (!exceptionMessage.isEmpty() && !exceptionMessage.trim().contentEquals("*") && !ex.getMessage().contains(exceptionMessage))) {
  13. scenario.write("An unexpected exception was raised!");
  14. throw(ex);
  15. }
  16. scenario.write("Exception raised as expected: " + ex.getClass().getCanonicalName() + ", " + ex.getMessage());
  17. stepData.put("ExceptionCaught", true);
  18. stepData.put("Exception", ex);
  19. }
  20. }

代码示例来源:origin: waterguo/antsdb

  1. @Override
  2. public long eval(VdmContext ctx, Heap heap, Parameters params, long pRecord) {
  3. long addrVal = this.upstream.eval(ctx, heap, params, pRecord);
  4. Object val = FishObject.get(heap, addrVal);
  5. if (val == null) {
  6. }
  7. else if (val instanceof Float) {
  8. }
  9. else if (val instanceof Long) {
  10. val = ((Long)val).floatValue();
  11. }
  12. else if (val instanceof String) {
  13. val = Float.valueOf((String)val);
  14. }
  15. else if (val instanceof BigDecimal) {
  16. val = ((BigDecimal)val).floatValue();
  17. }
  18. else if (val instanceof Double) {
  19. val = ((Double)val).floatValue();
  20. }
  21. else {
  22. throw new CodingError(val.getClass().toGenericString());
  23. }
  24. return FishObject.allocSet(heap, val);
  25. }

代码示例来源:origin: apache/attic-polygene-java

  1. + method.toGenericString()
  2. + NL + "Declaring Class:"
  3. + method.getDeclaringClass().toGenericString()
  4. + NL + "Types:"
  5. + mixinsModel.mixinTypes()

代码示例来源:origin: waterguo/antsdb

  1. throw new CodingError(val.getClass().toGenericString());

相关文章

Class类方法