本文整理匯總了Java中javax.enterprise.util.Nonbinding類的典型用法代碼示例。如果您正苦於以下問題:Java Nonbinding類的具體用法?Java Nonbinding怎麽用?Java Nonbinding使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Nonbinding類屬於javax.enterprise.util包,在下文中一共展示了Nonbinding類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createAnnotationId
import javax.enterprise.util.Nonbinding; //導入依賴的package包/類
/**
* Generates a unique signature for an {@link Annotation}.
*/
static String createAnnotationId(Annotation annotation) {
Method[] methods = doPrivileged(
(PrivilegedAction<Method[]>) () -> annotation.annotationType().getDeclaredMethods());
return Stream.of(methods)
.filter(method -> !method.isAnnotationPresent(Nonbinding.class))
.sorted(comparing(Method::getName))
.collect(() -> new StringJoiner(",", "@" + annotation.annotationType().getCanonicalName() + "(", ")"),
(joiner, method) -> {
try {
joiner.add(method.getName() + "=" + method.invoke(annotation).toString());
} catch (NullPointerException | IllegalArgumentException | IllegalAccessException | InvocationTargetException cause) {
throw new RuntimeException(
"Error while accessing member [" + method.getName() + "]"
+ " of annotation [" + annotation.annotationType().getName() + "]", cause);
}
},
StringJoiner::merge)
.toString();
}
示例2: matchBindingTypeMembers
import javax.enterprise.util.Nonbinding; //導入依賴的package包/類
public static boolean matchBindingTypeMembers(Annotation beanAnnotation, Map<String, Object> beanAnnotationAttributes, Map<String, Object> interceptorAttributes) {
for (Method method : beanAnnotation.annotationType().getDeclaredMethods()) {
if (method.isAnnotationPresent(Nonbinding.class)) {
beanAnnotationAttributes.remove(method.getName());
interceptorAttributes.remove(method.getName());
}
}
if (beanAnnotationAttributes.values().size() == interceptorAttributes.values().size()) {
for (String key : beanAnnotationAttributes.keySet()) {
if (!beanAnnotationAttributes.get(key).equals(interceptorAttributes.get(key)))
return false;
}
} else {
return false;
}
return true;
}
示例3: createAnnotationId
import javax.enterprise.util.Nonbinding; //導入依賴的package包/類
/**
* Generates a unique signature for an {@link Annotation}.
*/
static String createAnnotationId(Annotation annotation) {
Method[] methods = doPrivileged(
(PrivilegedAction<Method[]>) () -> annotation.annotationType().getDeclaredMethods());
return Stream.of(methods)
.filter(method -> !method.isAnnotationPresent(Nonbinding.class))
.sorted(comparing(Method::getName))
.collect(() -> new StringJoiner(",", "@" + annotation.annotationType().getCanonicalName() + "(", ")"),
(joiner, method) -> {
try {
joiner.add(method.getName() + "=" + method.invoke(annotation).toString());
} catch (NullPointerException | IllegalArgumentException | IllegalAccessException | InvocationTargetException cause) {
throw new RuntimeException(
"Error while accessing member [" + method.getName() + "]"
+ " of annotation [" + annotation.annotationType().getName() + "]", cause);
}
},
StringJoiner::merge)
.toString();
}
示例4: doesQualifierMatch
import javax.enterprise.util.Nonbinding; //導入依賴的package包/類
private boolean doesQualifierMatch(Annotation currentQualifier, Annotation qualifierConfiguredBean)
{
if (!currentQualifier.annotationType().equals(qualifierConfiguredBean.annotationType()))
{
return false;
}
Object currentValue;
Object valueOfQualifierConfiguredBean;
for (Method currentMethod : currentQualifier.annotationType().getDeclaredMethods())
{
if (currentMethod.isAnnotationPresent(Nonbinding.class))
{
continue;
}
try
{
currentMethod.setAccessible(true);
currentValue = currentMethod.invoke(currentQualifier);
valueOfQualifierConfiguredBean = currentMethod.invoke(qualifierConfiguredBean);
if (!currentValue.equals(valueOfQualifierConfiguredBean))
{
return false;
}
}
catch (Exception e)
{
throw new IllegalStateException("Can't compare " + currentQualifier.annotationType().getName() +
" with " + qualifierConfiguredBean.annotationType().getName(), e);
}
}
return true;
}
示例5: getQualifierHashCode
import javax.enterprise.util.Nonbinding; //導入依賴的package包/類
public static int getQualifierHashCode(Annotation annotation)
{
Class annotationClass = annotation.annotationType();
int hashCode = getTypeHashCode(annotationClass);
for (Method member : annotationClass.getDeclaredMethods())
{
if (member.isAnnotationPresent(Nonbinding.class))
{
continue;
}
final Object annotationMemberValue = ReflectionUtils.invokeMethod(annotation, member, Object.class, true);
final int arrayValue;
if (annotationMemberValue == null /*possible with literals*/)
{
arrayValue = 0;
}
else if (annotationMemberValue.getClass().isArray())
{
Class<?> annotationMemberType = annotationMemberValue.getClass().getComponentType();
if (annotationMemberType.isPrimitive())
{
if (Long.TYPE == annotationMemberType)
{
arrayValue = Arrays.hashCode((long[]) annotationMemberValue);
}
else if (Integer.TYPE == annotationMemberType)
{
arrayValue = Arrays.hashCode((int[]) annotationMemberValue);
}
else if (Short.TYPE == annotationMemberType)
{
arrayValue = Arrays.hashCode((short[]) annotationMemberValue);
}
else if (Double.TYPE == annotationMemberType)
{
arrayValue = Arrays.hashCode((double[]) annotationMemberValue);
}
else if (Float.TYPE == annotationMemberType)
{
arrayValue = Arrays.hashCode((float[]) annotationMemberValue);
}
else if (Boolean.TYPE == annotationMemberType)
{
arrayValue = Arrays.hashCode((boolean[]) annotationMemberValue);
}
else if (Byte.TYPE == annotationMemberType)
{
arrayValue = Arrays.hashCode((byte[]) annotationMemberValue);
}
else if (Character.TYPE == annotationMemberType)
{
arrayValue = Arrays.hashCode((char[]) annotationMemberValue);
}
else
{
arrayValue = 0;
}
}
else
{
arrayValue = Arrays.hashCode((Object[]) annotationMemberValue);
}
}
else
{
arrayValue = annotationMemberValue.hashCode();
}
hashCode = 29 * hashCode + arrayValue;
hashCode = 29 * hashCode + member.getName().hashCode();
}
return hashCode;
}