private boolean isCompilable( IType type ) { IType doNotVerifyAnnotation = TypeSystem.getByFullNameIfValid( "gw.testharness.DoNotVerifyResource" ); return type instanceof IGosuClass && !type.getTypeInfo().hasAnnotation( doNotVerifyAnnotation ); }
/** This will unmarshal the element, provided it is exportable * * @param el the element to unmarshal * @param type the expected type * @return the value */ public static Object unmarshal(XmlElement el, IType type) { if (!type.getTypeInfo().hasAnnotation(ExportableMarshalInfo._exportAnnoType.get())) { throw new IllegalArgumentException(type.getRelativeName() + " is not exportable"); } return gw.internal.xml.config.XmlServices.unmarshal(type, el, new UnmarshalContext(null)); }
/** This will marshal the object, if exportable, into xml * * @param el the el to contain the object * @param obj the object */ public static void marshal(XmlElement el, Object obj) { if (obj == null) { throw new IllegalArgumentException("Object required"); } final IType type = TypeSystem.getTypeFromObject(obj); if (!type.getTypeInfo().hasAnnotation(ExportableMarshalInfo._exportAnnoType.get())) { throw new IllegalArgumentException(type.getRelativeName() + " is not exportable"); } gw.internal.xml.config.XmlServices.marshal(el, type, obj, new MarshalContext()); }
public static boolean violatesRepeatable( List<IGosuAnnotation> annotations, IGosuAnnotation anno ) { boolean bRepeatable = anno.getType().getTypeInfo().hasAnnotation( JavaTypes.REPEATABLE() ); if( !bRepeatable ) { for( IGosuAnnotation atn : annotations ) { if( atn.getType() == anno.getType() ) { return true; } } } return false; }
public static String checkWebServiceForErrors( IType type ) { if ( type == null ) { return "Null webservice type"; } ITypeInfo typeInfo = type.getTypeInfo(); if ( !( type instanceof IGosuClass ) ) { return "Type is not a Gosu class"; } if ( !( typeInfo.hasAnnotation( _wsiWebServiceAnnotationType.get() ) ) ) { return "Type does not have @WsiWebService annotation"; } if ( !type.isValid() ) { IGosuClass clazz = (IGosuClass) type; //noinspection ThrowableResultOfMethodCallIgnored return "Type is not valid." + ( clazz.getParseResultsException() == null ? "" : ( "\n\n" + GosuExceptionUtil.getStackTraceAsString( clazz.getParseResultsException() ) ) ); } return null; }
public void validate( IParsedElement pe ) { if ( pe instanceof IBeanMethodCallExpression) { // should always be true IBeanMethodCallExpression expr = (IBeanMethodCallExpression) pe; if ( expr.getArgs() != null ) { IExpression arg = expr.getArgs()[0]; if ( arg instanceof ITypeLiteralExpression) { ITypeLiteralExpression typeLiteral = (ITypeLiteralExpression) arg; IType type = typeLiteral.getType().getType(); if ( ! type.getTypeInfo().hasAnnotation( TypeSystem.getByFullName("gw.xml.ws.annotation.WsiWebService") ) ) { expr.addParseException( Res.MSG_ANY, "Type argument must have @WsiWebService annotation" ); } } } } } }
public IType getRepeatableContainer() { IType repeatable = JavaTypes.REPEATABLE(); if( getType().getTypeInfo().hasAnnotation( repeatable ) ) { IAnnotationInfo anno = getType().getTypeInfo().getAnnotation( repeatable ); Object type = anno.getFieldValue( "value" ); if( type instanceof String ) { type = TypeSystem.getByFullNameIfValid( (String)type ); } return (IType)type; } return null; } }
private static UsageModifier translateJavaElementTypeToUsageModifier( IParsedElement pe, UsageTarget targetType, IType annotationType, AnnotationUseSiteTarget target ) boolean bRepeatable = annotationType.getTypeInfo().hasAnnotation( JavaTypes.REPEATABLE() );
private void init(IJavaClassInfo cls, DefaultTypeLoader loader) { _classInfo = cls; _bArray = cls.isArray(); _bPrimitive = cls.isPrimitive(); _typeLoader = loader; _tiChecksum = TypeSystem.getSingleRefreshChecksum(); _strName = computeQualifiedName(); _functionalInterface = LocklessLazyVar.make( () -> { if( !isInterface() ) { return null; } if( (isGenericType() || isParameterizedType()) && getName().startsWith( "java." ) && !getTypeInfo().hasAnnotation( JavaTypes.FUNCTIONAL_INTERFACE() ) ) { // Avoid mistaking some Java interfaces for functional interfaces e.g., Comparable, Iterable, etc. return null; } return FunctionToInterfaceCoercer.getRepresentativeFunctionType( getTheRef() ); } ); }