javax.enterprise.inject.spi.AnnotatedParameter.getPosition()方法的使用及代码示例

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

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

AnnotatedParameter.getPosition介绍

[英]Get the position of the parameter in the method or constructor argument list.
[中]获取参数在方法或构造函数参数列表中的位置。

代码示例

代码示例来源:origin: oracle/helidon

private String getFieldName(InjectionPoint ip) {
  Annotated annotated = ip.getAnnotated();
  if (annotated instanceof AnnotatedField) {
    AnnotatedField f = (AnnotatedField) annotated;
    return f.getJavaMember().getName();
  }
  if (annotated instanceof AnnotatedParameter) {
    AnnotatedParameter p = (AnnotatedParameter) annotated;
    Member member = ip.getMember();
    if (member instanceof Method) {
      return member.getName() + "_" + p.getPosition();
    }
    if (member instanceof Constructor) {
      return "new_" + p.getPosition();
    }
  }
  return ip.getMember().getName();
}

代码示例来源:origin: oracle/helidon

@SuppressWarnings("Duplicates")
private String getFieldName(InjectionPoint ip) {
  Annotated annotated = ip.getAnnotated();
  if (annotated instanceof AnnotatedField) {
    AnnotatedField<?> f = (AnnotatedField<?>) annotated;
    return f.getJavaMember().getName();
  }
  if (annotated instanceof AnnotatedParameter) {
    AnnotatedParameter<?> p = (AnnotatedParameter<?>) annotated;
    Member member = ip.getMember();
    if (member instanceof Method) {
      return member.getName() + "_" + p.getPosition();
    }
    if (member instanceof Constructor) {
      return "new_" + p.getPosition();
    }
  }
  return ip.getMember().getName();
}

代码示例来源:origin: javax.enterprise/cdi-api

/**
 * Get the underlying {@link Parameter}.
 *
 * @return the {@link Parameter}
 */
default Parameter getJavaParameter() {
  Member member = getDeclaringCallable().getJavaMember();
  if (!(member instanceof Executable)) {
    throw new IllegalStateException("Parameter does not belong to an executable: " + member);
  }
  Executable executable = (Executable) member;
  return executable.getParameters()[getPosition()];
}

代码示例来源:origin: com.sun.jersey/jersey-servlet

public AnnotatedParameterImpl(AnnotatedParameter<? super T> param, Set<Annotation> annotations, AnnotatedCallable<T> declaringCallable) {
  this(param.getBaseType(),
     param.getTypeClosure(),
     annotations,
     declaringCallable,
     param.getPosition());
}

代码示例来源:origin: weld/core

public static void validateAnnotatedParameter(AnnotatedParameter<?> parameter) {
  validateAnnotated(parameter);
  if (parameter.getPosition() < 0) {
    throw MetadataLogger.LOG.invalidParameterPosition(parameter.getPosition(), parameter);
  }
  checkNotNull(parameter.getDeclaringCallable(), "getDeclaringCallable()", parameter);
}

代码示例来源:origin: org.jboss.weld.se/weld-se

/**
 * Compares two annotated parameters and returns true if they are equal
 */
public static boolean compareAnnotatedParameters(AnnotatedParameter<?> p1, AnnotatedParameter<?> p2) {
  return compareAnnotatedCallable(p1.getDeclaringCallable(), p2.getDeclaringCallable()) && p1.getPosition() == p2.getPosition() && compareAnnotated(p1, p2);
}

代码示例来源:origin: com.sun.jersey/jersey-bundle

public AnnotatedParameterImpl(AnnotatedParameter<? super T> param, Set<Annotation> annotations, AnnotatedCallable<T> declaringCallable) {
  this(param.getBaseType(),
     param.getTypeClosure(),
     annotations,
     declaringCallable,
     param.getPosition());
}

代码示例来源:origin: weld/core

/**
 * Compares two annotated parameters and returns true if they are equal
 */
public static boolean compareAnnotatedParameters(AnnotatedParameter<?> p1, AnnotatedParameter<?> p2) {
  return compareAnnotatedCallable(p1.getDeclaringCallable(), p2.getDeclaringCallable()) && p1.getPosition() == p2.getPosition() && compareAnnotated(p1, p2);
}

代码示例来源:origin: weld/core

/**
 * Compares two annotated parameters and returns true if they are equal
 */
public static boolean compareAnnotatedParameters(AnnotatedParameter<?> p1, AnnotatedParameter<?> p2) {
  return compareAnnotatedCallable(p1.getDeclaringCallable(), p2.getDeclaringCallable()) && p1.getPosition() == p2.getPosition() && compareAnnotated(p1, p2);
}

代码示例来源:origin: weld/core

public static void validateAnnotatedParameter(AnnotatedParameter<?> parameter) {
  validateAnnotated(parameter);
  if (parameter.getPosition() < 0) {
    throw MetadataLogger.LOG.invalidParameterPosition(parameter.getPosition(), parameter);
  }
  checkNotNull(parameter.getDeclaringCallable(), "getDeclaringCallable()", parameter);
}

代码示例来源:origin: org.jboss.weld.se/weld-se

public static void validateAnnotatedParameter(AnnotatedParameter<?> parameter) {
  validateAnnotated(parameter);
  if (parameter.getPosition() < 0) {
    throw MetadataLogger.LOG.invalidParameterPosition(parameter.getPosition(), parameter);
  }
  checkNotNull(parameter.getDeclaringCallable(), "getDeclaringCallable()", parameter);
}

代码示例来源:origin: com.sun.jersey/jersey-servlet

public AnnotatedParameterImpl(AnnotatedParameter<? super T> param, AnnotatedCallable<T> declaringCallable) {
  this(param.getBaseType(),
     param.getTypeClosure(),
     param.getAnnotations(),
     declaringCallable,
     param.getPosition());
}

代码示例来源:origin: weld/core

private int initDelegateInjectionPointPosition() {
  for (ParameterInjectionPoint<?, T> parameter : getParameterInjectionPoints()) {
    if (parameter.isDelegate()) {
      return parameter.getAnnotated().getPosition();
    }
  }
  return -1;
}

代码示例来源:origin: weld/core

private int initDelegateInjectionPointPosition() {
  for (ParameterInjectionPoint<?, T> parameter : getParameterInjectionPoints()) {
    if (parameter.isDelegate()) {
      return parameter.getAnnotated().getPosition();
    }
  }
  return -1;
}

代码示例来源:origin: org.jboss.weld.se/weld-se

public UnbackedAnnotatedConstructor(Type baseType, Set<Type> typeClosure, Set<Annotation> annotations, UnbackedAnnotatedType<X> declaringType,
    List<AnnotatedParameter<X>> originalParameters, Constructor<X> constructor, SharedObjectCache cache) {
  super(baseType, typeClosure, cache.getSharedSet(annotations), declaringType);
  this.constructor = constructor;
  List<AnnotatedParameter<X>> parameters = new ArrayList<AnnotatedParameter<X>>(originalParameters.size());
  for (AnnotatedParameter<X> originalParameter : originalParameters) {
    parameters.add(new UnbackedAnnotatedParameter<X>(originalParameter.getBaseType(), originalParameter.getTypeClosure(), cache.getSharedSet(originalParameter.getAnnotations()),
        originalParameter.getPosition(), this));
  }
  this.parameters = immutableListView(parameters);
}

代码示例来源:origin: weld/core

public UnbackedAnnotatedMethod(Type baseType, Set<Type> typeClosure, Set<Annotation> annotations, UnbackedAnnotatedType<X> declaringType,
    List<AnnotatedParameter<X>> originalParameters, Method method, SharedObjectCache cache) {
  super(baseType, typeClosure, cache.getSharedSet(annotations), declaringType);
  this.method = method;
  List<AnnotatedParameter<X>> parameters = new ArrayList<AnnotatedParameter<X>>(originalParameters.size());
  for (AnnotatedParameter<X> originalParameter : originalParameters) {
    parameters.add(new UnbackedAnnotatedParameter<X>(originalParameter.getBaseType(), originalParameter.getTypeClosure(), cache.getSharedSet(originalParameter.getAnnotations()),
        originalParameter.getPosition(), this));
  }
  this.parameters = ImmutableList.copyOf(parameters);
}

代码示例来源:origin: weld/core

public UnbackedAnnotatedConstructor(Type baseType, Set<Type> typeClosure, Set<Annotation> annotations, UnbackedAnnotatedType<X> declaringType,
    List<AnnotatedParameter<X>> originalParameters, Constructor<X> constructor, SharedObjectCache cache) {
  super(baseType, typeClosure, cache.getSharedSet(annotations), declaringType);
  this.constructor = constructor;
  List<AnnotatedParameter<X>> parameters = new ArrayList<AnnotatedParameter<X>>(originalParameters.size());
  for (AnnotatedParameter<X> originalParameter : originalParameters) {
    parameters.add(new UnbackedAnnotatedParameter<X>(originalParameter.getBaseType(), originalParameter.getTypeClosure(), cache.getSharedSet(originalParameter.getAnnotations()),
        originalParameter.getPosition(), this));
  }
  this.parameters = ImmutableList.copyOf(parameters);
}

代码示例来源:origin: weld/core

public UnbackedAnnotatedMethod(Type baseType, Set<Type> typeClosure, Set<Annotation> annotations, UnbackedAnnotatedType<X> declaringType,
    List<AnnotatedParameter<X>> originalParameters, Method method, SharedObjectCache cache) {
  super(baseType, typeClosure, cache.getSharedSet(annotations), declaringType);
  this.method = method;
  List<AnnotatedParameter<X>> parameters = new ArrayList<AnnotatedParameter<X>>(originalParameters.size());
  for (AnnotatedParameter<X> originalParameter : originalParameters) {
    parameters.add(new UnbackedAnnotatedParameter<X>(originalParameter.getBaseType(), originalParameter.getTypeClosure(), cache.getSharedSet(originalParameter.getAnnotations()),
        originalParameter.getPosition(), this));
  }
  this.parameters = ImmutableList.copyOf(parameters);
}

代码示例来源:origin: weld/core

public UnbackedAnnotatedConstructor(Type baseType, Set<Type> typeClosure, Set<Annotation> annotations, UnbackedAnnotatedType<X> declaringType,
    List<AnnotatedParameter<X>> originalParameters, Constructor<X> constructor, SharedObjectCache cache) {
  super(baseType, typeClosure, cache.getSharedSet(annotations), declaringType);
  this.constructor = constructor;
  List<AnnotatedParameter<X>> parameters = new ArrayList<AnnotatedParameter<X>>(originalParameters.size());
  for (AnnotatedParameter<X> originalParameter : originalParameters) {
    parameters.add(new UnbackedAnnotatedParameter<X>(originalParameter.getBaseType(), originalParameter.getTypeClosure(), cache.getSharedSet(originalParameter.getAnnotations()),
        originalParameter.getPosition(), this));
  }
  this.parameters = ImmutableList.copyOf(parameters);
}

代码示例来源:origin: org.jboss.weld.se/weld-se

public UnbackedAnnotatedMethod(Type baseType, Set<Type> typeClosure, Set<Annotation> annotations, UnbackedAnnotatedType<X> declaringType,
    List<AnnotatedParameter<X>> originalParameters, Method method, SharedObjectCache cache) {
  super(baseType, typeClosure, cache.getSharedSet(annotations), declaringType);
  this.method = method;
  List<AnnotatedParameter<X>> parameters = new ArrayList<AnnotatedParameter<X>>(originalParameters.size());
  for (AnnotatedParameter<X> originalParameter : originalParameters) {
    parameters.add(new UnbackedAnnotatedParameter<X>(originalParameter.getBaseType(), originalParameter.getTypeClosure(), cache.getSharedSet(originalParameter.getAnnotations()),
        originalParameter.getPosition(), this));
  }
  this.parameters = immutableListView(parameters);
}

相关文章