Package com.asakusafw.utils.java.model.syntax

Examples of com.asakusafw.utils.java.model.syntax.Type


    protected Type visitParameterizedType(
            ParameterizedType type,
            ModelFactory context) {
        java.lang.reflect.Type owner = type.getOwnerType();
        java.lang.reflect.Type rawType = type.getRawType();
        Type candidate;
        if (owner == null || owner instanceof Class<?>) {
            candidate = dispatch(rawType, context);
        } else {
            Type enclosing = dispatch(owner, context);
            assert rawType instanceof Class<?> : rawType;
            candidate = context.newQualifiedType(
                enclosing,
                context.newSimpleName(((Class<?>) rawType).getSimpleName()));
        }
View Full Code Here


                .toLocalVariableDeclaration(t(List.class, t(StageInput.class)), list));
            statements.add(new ExpressionBuilder(factory, Models.toNullLiteral(factory))
                .toLocalVariableDeclaration(t(Map.class, t(String.class), t(String.class)), attributes));

            for (CompiledSlot slot : slots) {
                Type mapperType = importer.toType(slot.mapperClass);
                for (SourceInfo info : slot.original.sources) {
                    statements.add(new ExpressionBuilder(factory, attributes)
                        .assignFrom(new TypeBuilder(factory, t(HashMap.class, t(String.class), t(String.class)))
                            .newObject()
                            .toExpression())
View Full Code Here

        private MethodDeclaration createClassLiteralMethod(
                String methodName,
                Name typeName) {
            assert methodName != null;
            Type type = importer.toType(typeName);
            return createValueMethod(methodName, t(Class.class, type), factory.newClassLiteral(type));
        }
View Full Code Here

                .newObject()
                .toLocalVariableDeclaration(t(List.class, t(StageOutput.class)), list));
            statements.add(new ExpressionBuilder(factory, Models.toNullLiteral(factory))
                .toLocalVariableDeclaration(t(Map.class, t(String.class), t(String.class)), attributes));

            Type formatType = t(BridgeOutputFormat.class);
            for (CompiledSlot slot : slots) {
                Slot origin = slot.original;
                Expression valueType = factory.newClassLiteral(importer.toType(origin.valueType));
                statements.add(new ExpressionBuilder(factory, attributes)
                    .assignFrom(new TypeBuilder(factory, t(HashMap.class, t(String.class), t(String.class)))
View Full Code Here

        }

        private Type t(java.lang.reflect.Type type, Type...typeArgs) {
            assert type != null;
            assert typeArgs != null;
            Type raw = importer.toType(type);
            if (typeArgs.length == 0) {
                return raw;
            }
            return factory.newParameterizedType(raw, Arrays.asList(typeArgs));
        }
View Full Code Here

        TypeMirror component = type.getComponentType();
        while (component.getKind() == TypeKind.ARRAY) {
            component = ((javax.lang.model.type.ArrayType) component).getComponentType();
            dimensions++;
        }
        Type result = convert0(component);
        if (result == null) {
            return null;
        }
        assert (result instanceof ArrayType) == false;
        for (int i = 0; i < dimensions; i++) {
View Full Code Here

        if (typeArguments.isEmpty()) {
            return raw;
        }
        List<Type> arguments = new ArrayList<Type>();
        for (TypeMirror mirror : typeArguments) {
            Type argument = convert0(mirror);
            if (argument == null) {
                return null;
            }
            arguments.add(argument);
        }
View Full Code Here

        TypeMirror upper = type.getExtendsBound();
        if (upper != null) {
            if (type.getSuperBound() != null) {
                return null;
            }
            Type bound = convert0(upper);
            if (bound == null) {
                return null;
            }
            return factory.newWildcard(WildcardBoundKind.UPPER_BOUNDED, bound);
        }
        TypeMirror lower = type.getSuperBound();
        if (lower != null) {
            Type bound = convert0(lower);
            if (bound == null) {
                return null;
            }
            return factory.newWildcard(WildcardBoundKind.LOWER_BOUNDED, bound);
        }
View Full Code Here

                context.resolve(String.class),
                Models.toLiteral(f, value));
    }

    private MethodDeclaration createGetFormatMethod(Name value) {
        Type type = f.newParameterizedType(
                context.resolve(Class.class),
                f.newWildcard(WildcardBoundKind.UPPER_BOUNDED, f.newParameterizedType(
                        context.resolve(DataFormat.class), f.newWildcard())));
        return createGetMethod("getFormat", type, f.newClassLiteral(context.resolve(value))); //$NON-NLS-1$
    }
View Full Code Here

    private MethodDeclaration createGetListOfStringMethod(String name, List<String> values) {
        List<Expression> arguments = Lists.create();
        for (String element : values) {
            arguments.add(Models.toLiteral(f, element));
        }
        Type type = f.newParameterizedType(context.resolve(List.class), context.resolve(String.class));
        Expression value = new TypeBuilder(f, context.resolve(Arrays.class))
            .method("asList", arguments) //$NON-NLS-1$
            .toExpression();
        return createGetMethod(name, type, value);
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.utils.java.model.syntax.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.