本文整理了Java中com.google.inject.internal.Annotations.isScopeAnnotation()
方法的一些代码示例,展示了Annotations.isScopeAnnotation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotations.isScopeAnnotation()
方法的具体详情如下:
包路径:com.google.inject.internal.Annotations
类名称:Annotations
方法名:isScopeAnnotation
暂无
代码示例来源:origin: com.google.inject/guice
/** Returns the scoping annotation, or null if there isn't one. */
public static Class<? extends Annotation> findScopeAnnotation(
Errors errors, Annotation[] annotations) {
Class<? extends Annotation> found = null;
for (Annotation annotation : annotations) {
Class<? extends Annotation> annotationType = annotation.annotationType();
if (isScopeAnnotation(annotationType)) {
if (found != null) {
errors.duplicateScopeAnnotations(found, annotationType);
} else {
found = annotationType;
}
}
}
return found;
}
代码示例来源:origin: com.google.inject/guice
@Override
public Boolean visit(ScopeBinding command) {
Scope scope = checkNotNull(command.getScope(), "scope");
Class<? extends Annotation> annotationType =
checkNotNull(command.getAnnotationType(), "annotation type");
if (!Annotations.isScopeAnnotation(annotationType)) {
errors.missingScopeAnnotation(annotationType);
// Go ahead and bind anyway so we don't get collateral errors.
}
if (!Annotations.isRetainedAtRuntime(annotationType)) {
errors.missingRuntimeRetention(annotationType);
// Go ahead and bind anyway so we don't get collateral errors.
}
ScopeBinding existing = injector.state.getScopeBinding(annotationType);
if (existing != null) {
if (!scope.equals(existing.getScope())) {
errors.duplicateScopes(existing, annotationType, scope);
}
} else {
injector.state.putScopeBinding(annotationType, command);
}
return true;
}
}
代码示例来源:origin: com.google/inject
/** Returns the scoping annotation, or null if there isn't one. */
public static Class<? extends Annotation> findScopeAnnotation(Errors errors, Annotation[] annotations) {
Class<? extends Annotation> found = null;
for (Annotation annotation : annotations) {
Class<? extends Annotation> annotationType = annotation.annotationType();
if (isScopeAnnotation(annotationType)) {
if (found != null) {
errors.duplicateScopeAnnotations(found, annotationType);
} else {
found = annotationType;
}
}
}
return found;
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.inject
/** Returns the scoping annotation, or null if there isn't one. */
public static Class<? extends Annotation> findScopeAnnotation(Errors errors, Annotation[] annotations) {
Class<? extends Annotation> found = null;
for (Annotation annotation : annotations) {
Class<? extends Annotation> annotationType = annotation.annotationType();
if (isScopeAnnotation(annotationType)) {
if (found != null) {
errors.duplicateScopeAnnotations(found, annotationType);
} else {
found = annotationType;
}
}
}
return found;
}
代码示例来源:origin: Nextdoor/bender
/** Returns the scoping annotation, or null if there isn't one. */
public static Class<? extends Annotation> findScopeAnnotation(Errors errors, Annotation[] annotations) {
Class<? extends Annotation> found = null;
for (Annotation annotation : annotations) {
Class<? extends Annotation> annotationType = annotation.annotationType();
if (isScopeAnnotation(annotationType)) {
if (found != null) {
errors.duplicateScopeAnnotations(found, annotationType);
} else {
found = annotationType;
}
}
}
return found;
}
代码示例来源:origin: org.sonatype.sisu/sisu-guice
/** Returns the scoping annotation, or null if there isn't one. */
public static Class<? extends Annotation> findScopeAnnotation(
Errors errors, Annotation[] annotations) {
Class<? extends Annotation> found = null;
for (Annotation annotation : annotations) {
Class<? extends Annotation> annotationType = annotation.annotationType();
if (isScopeAnnotation(annotationType)) {
if (found != null) {
errors.duplicateScopeAnnotations(found, annotationType);
} else {
found = annotationType;
}
}
}
return found;
}
代码示例来源:origin: com.jwebmp.inject/guice
/** Returns the scoping annotation, or null if there isn't one. */
public static Class<? extends Annotation> findScopeAnnotation(
Errors errors, Annotation[] annotations) {
Class<? extends Annotation> found = null;
for (Annotation annotation : annotations) {
Class<? extends Annotation> annotationType = annotation.annotationType();
if (isScopeAnnotation(annotationType)) {
if (found != null) {
errors.duplicateScopeAnnotations(found, annotationType);
} else {
found = annotationType;
}
}
}
return found;
}
代码示例来源:origin: org.xbib/guice
/**
* Returns the scoping annotation, or null if there isn't one.
*/
public static Class<? extends Annotation> findScopeAnnotation(Errors errors, Annotation[] annotations) {
Class<? extends Annotation> found = null;
for (Annotation annotation : annotations) {
Class<? extends Annotation> annotationType = annotation.annotationType();
if (isScopeAnnotation(annotationType)) {
if (found != null) {
errors.duplicateScopeAnnotations(found, annotationType);
} else {
found = annotationType;
}
}
}
return found;
}
代码示例来源:origin: ru.vyarus/guice-ext-annotations
@SuppressWarnings("PMD.UnusedPrivateMethod")
private static void applyScopeAnnotation(final ClassPool classPool, final AnnotationsAttribute annotations,
final AnnotatedElement source,
final Class<? extends java.lang.annotation.Annotation> scope)
throws Exception {
if (scope != null) {
Preconditions.checkState(Annotations.isScopeAnnotation(scope),
"Provided annotation %s is not scope annotation", scope.getSimpleName());
for (java.lang.annotation.Annotation ann : source.getAnnotations()) {
Preconditions.checkArgument(!(ann instanceof ScopeAnnotation),
"Duplicate scope definition: scope is specified as %s and also defined "
+ "in @ScopeAnnotation.", scope.getSimpleName());
}
annotations.addAnnotation(new Annotation(annotations.getConstPool(), classPool.get(scope.getName())));
}
}
代码示例来源:origin: ru.vyarus/guice-ext-annotations
private static Annotation processAnnotation(final ClassPool classPool, final ConstPool constPool,
final java.lang.annotation.Annotation ann) throws Exception {
Annotation res = null;
// if we copy these annotation guice will go to infinite loop
if (!(ann instanceof ProvidedBy || ann instanceof ImplementedBy)) {
Preconditions.checkState(!Annotations.isScopeAnnotation(ann.annotationType()),
"Don't use scope annotations directly - use @ScopeAnnotation(TargetScope) wrapper, "
+ "because guice doesn't allow scope annotations on abstract types");
if (ann instanceof ScopeAnnotation) {
res = new Annotation(constPool,
classPool.get(((ScopeAnnotation) ann).value().getName()));
} else {
res = JavassistUtils.copyAnnotation(classPool, constPool, ann);
}
}
return res;
}
代码示例来源:origin: org.sonatype.sisu/sisu-guice
@Override
public Boolean visit(ScopeBinding command) {
Scope scope = checkNotNull(command.getScope(), "scope");
Class<? extends Annotation> annotationType =
checkNotNull(command.getAnnotationType(), "annotation type");
if (!Annotations.isScopeAnnotation(annotationType)) {
errors.missingScopeAnnotation(annotationType);
// Go ahead and bind anyway so we don't get collateral errors.
}
if (!Annotations.isRetainedAtRuntime(annotationType)) {
errors.missingRuntimeRetention(annotationType);
// Go ahead and bind anyway so we don't get collateral errors.
}
ScopeBinding existing = injector.state.getScopeBinding(annotationType);
if (existing != null) {
if (!scope.equals(existing.getScope())) {
errors.duplicateScopes(existing, annotationType, scope);
}
} else {
injector.state.putScopeBinding(annotationType, command);
}
return true;
}
}
代码示例来源:origin: org.xbib/guice
@Override
public Boolean visit(ScopeBinding command) {
Scope scope = checkNotNull(command.getScope(), "scope");
Class<? extends Annotation> annotationType = checkNotNull(command.getAnnotationType(), "annotation type");
if (!Annotations.isScopeAnnotation(annotationType)) {
errors.missingScopeAnnotation(annotationType);
// Go ahead and bind anyway so we don't get collateral errors.
}
if (!Annotations.isRetainedAtRuntime(annotationType)) {
errors.missingRuntimeRetention(annotationType);
// Go ahead and bind anyway so we don't get collateral errors.
}
ScopeBinding existing = injector.state.getScopeBinding(annotationType);
if (existing != null) {
if (!scope.equals(existing.getScope())) {
errors.duplicateScopes(existing, annotationType, scope);
}
} else {
injector.state.putScopeBinding(annotationType, command);
}
return true;
}
}
代码示例来源:origin: com.jwebmp.inject/guice
@Override
public Boolean visit(ScopeBinding command) {
Scope scope = checkNotNull(command.getScope(), "scope");
Class<? extends Annotation> annotationType =
checkNotNull(command.getAnnotationType(), "annotation type");
if (!Annotations.isScopeAnnotation(annotationType)) {
errors.missingScopeAnnotation(annotationType);
// Go ahead and bind anyway so we don't get collateral errors.
}
if (!Annotations.isRetainedAtRuntime(annotationType)) {
errors.missingRuntimeRetention(annotationType);
// Go ahead and bind anyway so we don't get collateral errors.
}
ScopeBinding existing = injector.state.getScopeBinding(annotationType);
if (existing != null) {
if (!scope.equals(existing.getScope())) {
errors.duplicateScopes(existing, annotationType, scope);
}
} else {
injector.state.putScopeBinding(annotationType, command);
}
return true;
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.inject
@Override public Boolean visit(ScopeBinding command) {
Scope scope = command.getScope();
Class<? extends Annotation> annotationType = command.getAnnotationType();
if (!Annotations.isScopeAnnotation(annotationType)) {
errors.withSource(annotationType).missingScopeAnnotation();
// Go ahead and bind anyway so we don't get collateral errors.
}
if (!Annotations.isRetainedAtRuntime(annotationType)) {
errors.withSource(annotationType)
.missingRuntimeRetention(command.getSource());
// Go ahead and bind anyway so we don't get collateral errors.
}
Scope existing = injector.state.getScope(checkNotNull(annotationType, "annotation type"));
if (existing != null) {
errors.duplicateScopes(existing, annotationType, scope);
} else {
injector.state.putAnnotation(annotationType, checkNotNull(scope, "scope"));
}
return true;
}
}
代码示例来源:origin: Nextdoor/bender
@Override public Boolean visit(ScopeBinding command) {
Scope scope = command.getScope();
Class<? extends Annotation> annotationType = command.getAnnotationType();
if (!Annotations.isScopeAnnotation(annotationType)) {
errors.withSource(annotationType).missingScopeAnnotation();
// Go ahead and bind anyway so we don't get collateral errors.
}
if (!Annotations.isRetainedAtRuntime(annotationType)) {
errors.withSource(annotationType)
.missingRuntimeRetention(command.getSource());
// Go ahead and bind anyway so we don't get collateral errors.
}
Scope existing = injector.state.getScope(checkNotNull(annotationType, "annotation type"));
if (existing != null) {
errors.duplicateScopes(existing, annotationType, scope);
} else {
injector.state.putAnnotation(annotationType, checkNotNull(scope, "scope"));
}
return true;
}
}
代码示例来源:origin: com.google/inject
@Override public Boolean visit(ScopeBinding command) {
Scope scope = command.getScope();
Class<? extends Annotation> annotationType = command.getAnnotationType();
if (!Annotations.isScopeAnnotation(annotationType)) {
errors.withSource(annotationType).missingScopeAnnotation();
// Go ahead and bind anyway so we don't get collateral errors.
}
if (!Annotations.isRetainedAtRuntime(annotationType)) {
errors.withSource(annotationType)
.missingRuntimeRetention(command.getSource());
// Go ahead and bind anyway so we don't get collateral errors.
}
Scope existing = injector.state.getScope(checkNotNull(annotationType, "annotation type"));
if (existing != null) {
errors.duplicateScopes(existing, annotationType, scope);
} else {
injector.state.putAnnotation(annotationType, checkNotNull(scope, "scope"));
}
return true;
}
}
内容来源于网络,如有侵权,请联系作者删除!