本文整理匯總了Java中org.jboss.jandex.Type.Kind類的典型用法代碼示例。如果您正苦於以下問題:Java Kind類的具體用法?Java Kind怎麽用?Java Kind使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Kind類屬於org.jboss.jandex.Type包,在下文中一共展示了Kind類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validParameters
import org.jboss.jandex.Type.Kind; //導入依賴的package包/類
private boolean validParameters(final MethodInfo method, final StringBuilder sb) {
boolean ok = true;
final Map<Integer, List<AnnotationInstance>> map = Utils.createParameterAnnotationMap(method);
final List<Type> params = method.parameters();
for (int i = 0; i < params.size(); i++) {
final Type param = params.get(i);
if (param.kind() != Kind.PRIMITIVE) {
final List<AnnotationInstance> annotations = map.get(i);
if ((annotations == null) || !contains(annotations, notNullFqn, nullableFqn)) {
ok = false;
sb.append(method.declaringClass());
sb.append("\t");
sb.append(method);
sb.append("\t");
sb.append("Parameter #" + i + " (" + params.get(i).name() + ")\n");
}
}
}
return ok;
}
示例2: testFindBaseClass
import org.jboss.jandex.Type.Kind; //導入依賴的package包/類
@Test
public void testFindBaseClass() {
// PREPARE
final ClassInfo implClass = index.getClassByName(DotName.createSimple(MyClass.class.getName()));
final MethodInfo implMethod = implClass.method("methodMyBaseClass1",
Type.create(DotName.createSimple(Integer.class.getName()), Kind.CLASS));
// TEST
final List<MethodInfo> intfMethods = Utils.findOverrideMethods(index, implMethod);
// VERIFY
assertThat(intfMethods).hasSize(1);
assertThat(intfMethods.get(0).name()).isEqualTo("methodMyBaseClass1");
assertThat(intfMethods.get(0).declaringClass().name().toString()).isEqualTo(
MyBaseClass1.class.getName());
}
示例3: testFindInterface1
import org.jboss.jandex.Type.Kind; //導入依賴的package包/類
@Test
public void testFindInterface1() {
// PREPARE
final ClassInfo implClass = index.getClassByName(DotName.createSimple(MyClass.class.getName()));
final MethodInfo implMethod = implClass.method("methodMyInterface1",
Type.create(DotName.createSimple(Long.class.getName()), Kind.CLASS));
// TEST
final List<MethodInfo> intfMethods = Utils.findOverrideMethods(index, implMethod);
// VERIFY
assertThat(intfMethods).hasSize(1);
assertThat(intfMethods.get(0).name()).isEqualTo("methodMyInterface1");
assertThat(intfMethods.get(0).declaringClass().name().toString()).isEqualTo(
MyInterface1.class.getName());
}
示例4: testFindInterface2
import org.jboss.jandex.Type.Kind; //導入依賴的package包/類
@Test
public void testFindInterface2() {
// PREPARE
final ClassInfo implClass = index.getClassByName(DotName.createSimple(MyClass.class.getName()));
final MethodInfo implMethod = implClass.method("methodMyInterface2",
Type.create(DotName.createSimple(Boolean.class.getName()), Kind.CLASS));
// TEST
final List<MethodInfo> intfMethods = Utils.findOverrideMethods(index, implMethod);
// VERIFY
assertThat(intfMethods).hasSize(1);
assertThat(intfMethods.get(0).name()).isEqualTo("methodMyInterface2");
assertThat(intfMethods.get(0).declaringClass().name().toString()).isEqualTo(
MyInterface2.class.getName());
}
示例5: validateMethod
import org.jboss.jandex.Type.Kind; //導入依賴的package包/類
private void validateMethod(MethodInfo methodInfo,
Class callbackTypeClass,
Map<Class<?>, String> callbacksByClass,
boolean isListener) {
if ( methodInfo.returnType().kind() != Kind.VOID ) {
throw new PersistenceException( "Callback method " + methodInfo.name() + " must have a void return type in " );
}
if ( Modifier.isStatic( methodInfo.flags() ) || Modifier.isFinal( methodInfo.flags() ) ) {
throw new PersistenceException( "Callback method " + methodInfo.name() + " must not be static or final in " );
}
Type[] argTypes = methodInfo.args();
if ( isListener ) {
if ( argTypes.length != 1 ) {
throw new PersistenceException( "Callback method " + methodInfo.name() + " must have exactly one argument in " );
}
String argTypeName = argTypes[0].name().toString();
if ( !argTypeName.equals( Object.class.getName() ) && !argTypeName.equals( getName() ) ) {
throw new PersistenceException(
"The argument for callback method " + methodInfo.name() +
" must be defined as either Object or " + getEntityName() + " in "
);
}
}
else if ( argTypes.length != 0 ) {
throw new PersistenceException( "Callback method " + methodInfo.name() + " must have no arguments in " );
}
if ( callbacksByClass.containsKey( callbackTypeClass ) ) {
throw new PersistenceException(
"Only one method may be annotated as a " + callbackTypeClass.getSimpleName() +
" callback method in "
);
}
}
示例6: makeSignature
import org.jboss.jandex.Type.Kind; //導入依賴的package包/類
/**
* @param i
* @return
* @throws SerianalyzerException
*/
static String makeSignature ( MethodInfo i, boolean fix ) throws SerianalyzerException {
StringBuilder sb = new StringBuilder();
sb.append('(');
ClassInfo declaringImpl = i.declaringClass();
if ( fix && "<init>".equals(i.name()) && declaringImpl.nestingType() == NestingType.INNER ) { //$NON-NLS-1$
// there seems to be some sort of bug, missing the the outer instance parameter in the constructor
if ( !Modifier.isStatic(declaringImpl.flags()) ) {
org.jboss.jandex.Type enclosingClass = org.jboss.jandex.Type.create(declaringImpl.enclosingClass(), Kind.CLASS);
org.jboss.jandex.Type firstArg = i.parameters().size() > 0 ? i.parameters().get(0) : null;
if ( firstArg instanceof TypeVariable ) {
firstArg = firstArg.asTypeVariable().bounds().get(0);
}
if ( firstArg == null || !firstArg.equals(enclosingClass) ) {
sb.append(toString(enclosingClass));
}
}
}
for ( org.jboss.jandex.Type p : i.parameters() ) {
sb.append(toString(p));
}
sb.append(')');
sb.append(toString(i.returnType()));
return sb.toString();
}
示例7: validReturnType
import org.jboss.jandex.Type.Kind; //導入依賴的package包/類
private boolean validReturnType(final MethodInfo method, final StringBuilder sb) {
if ((method.returnType().kind() != Kind.VOID) && method.returnType().kind() != Kind.PRIMITIVE) {
final List<AnnotationInstance> list = Utils.createMethodAnnotationList(method);
if (!contains(list, notNullFqn, nullableFqn)) {
sb.append(method.declaringClass());
sb.append("\t");
sb.append(method);
sb.append("\t");
sb.append("Return type (" + method.returnType() + ")\n");
return false;
}
}
return true;
}
示例8: testFindInterfaceNone
import org.jboss.jandex.Type.Kind; //導入依賴的package包/類
@Test
public void testFindInterfaceNone() {
// PREPARE
final ClassInfo implClass = index.getClassByName(DotName.createSimple(MyClass.class.getName()));
final MethodInfo implMethod = implClass.method("methodX",
Type.create(DotName.createSimple(String.class.getName()), Kind.CLASS));
// TEST
final List<MethodInfo> intfMethods = Utils.findOverrideMethods(index, implMethod);
// VERIFY
assertThat(intfMethods).isEmpty();
}
示例9: testOkMethod4
import org.jboss.jandex.Type.Kind; //導入依賴的package包/類
@Test
public final void testOkMethod4() {
final AssertionResult result = testee.verify(CLASS_INFO.method("okMethod4",
Type.create(DotName.createSimple(int.class.getName()), Kind.PRIMITIVE)));
assertThat(result).isNotNull();
assertThat(result.getErrorMessage()).isEqualTo("");
}
示例10: testokMethod5
import org.jboss.jandex.Type.Kind; //導入依賴的package包/類
@Test
public final void testokMethod5() {
final AssertionResult result = testee.verify(CLASS_INFO.method("okMethod5",
Type.create(DotName.createSimple(Integer.class.getName()), Kind.CLASS)));
assertThat(result).isNotNull();
assertThat(result.getErrorMessage()).isEqualTo("");
}
示例11: type
import org.jboss.jandex.Type.Kind; //導入依賴的package包/類
private Type type(final Class<?> clasz) {
return Type.create(DotName.createSimple(clasz.getName()), Kind.CLASS);
}