Package com.sun.codemodel

Examples of com.sun.codemodel.JClass.narrow()


  @NotNull
  @Override
  public JClass generateFieldType( @NotNull FieldDeclarationInfo fieldInfo ) {
    JClass collectionType = codeGenerator.ref( fieldInfo.getCollectionParam().toString() );
    JClass list = codeGenerator.getModel().ref( List.class );
    return list.narrow( collectionType.wildcard() );
  }

  @Override
  public boolean canHandle( @NotNull FieldDeclarationInfo fieldInfo ) {
    return fieldInfo.isCollectionType();
View Full Code Here


    public JClass toType(Outline o, Aspect aspect) {
        JClass r = rawType.toType(o,aspect);

        for( NType arg : args )
            r = r.narrow(arg.toType(o,aspect).boxify());

        return r;
    }

    public boolean isAbstract() {
View Full Code Here

    {
      actionBuilderClassName = capitalize(resourceName) + "Do" + capitalize(actionName) + BUILDER;
    }
    JDefinedClass actionBuilderClass = facadeClass.getPackage()._class(JMod.PUBLIC, actionBuilderClassName);
    annotate(actionBuilderClass, null);
    actionBuilderClass._extends(vanillaActionBuilderClass.narrow(actionBuilderClass));
    JMethod actionBuilderConstructor = actionBuilderClass.constructor(JMod.PUBLIC);
    JVar uriParam = actionBuilderConstructor.param(_stringClass, "baseUriTemplate");
    JVar classParam = actionBuilderConstructor.param(getCodeModel().ref(Class.class).narrow(returnType), "returnClass");
    JVar resourceSpecParam = actionBuilderConstructor.param(_resourceSpecClass, "resourceSpec");
    JVar actionsRequestOptionsParam = actionBuilderConstructor.param(RestliRequestOptions.class, "requestOptions");
View Full Code Here

        try {
            JClass holder = context.getCodeModel().ref("javax.xml.ws.Holder");
            if (genericType instanceof JPrimitiveType) {
              genericType = ((JPrimitiveType) genericType).boxify();
            }
            holder = holder.narrow((JClass) genericType);
            return holder;
        } catch (Exception e) {
            throw new GenerationException("Could not find holder type.", e);
        }
    }
View Full Code Here

      JClass referencedCollection = ref( TypeUtils.getErasure( type ).toString() );
      if ( referencedCollectionParam == null ) {
        return referencedCollection;
      } else {
        return referencedCollection.narrow( referencedCollectionParam );
      }
    }

    return ref( TypeUtils.getErasure( type ).toString() );
  }
View Full Code Here

            ParameterizedType pt = (ParameterizedType) t;
            JClass raw = (JClass) getType(pt.getRawType());
           
            Type[] actualTypes = pt.getActualTypeArguments();
            for (Type actual : actualTypes) {
                raw = raw.narrow((JClass) getType(actual));
            }
           
            return raw;
        }
        throw new IllegalStateException();
View Full Code Here

  @NotNull
  @Override
  public JClass generateFieldType( @NotNull FieldDeclarationInfo fieldInfo ) {
    JClass collectionType = codeGenerator.ref( fieldInfo.getCollectionParam().toString() );
    JClass list = codeGenerator.getModel().ref( List.class );
    return list.narrow( collectionType.wildcard() );
  }

  @Override
  public boolean canHandle( @NotNull FieldDeclarationInfo fieldInfo ) {
    return fieldInfo.isCollectionType();
View Full Code Here

    private JExpression getDefaultList(JType fieldType, JsonNode node) {

        JClass listGenericType = ((JClass) fieldType).getTypeParameters().get(0);

        JClass listImplClass = fieldType.owner().ref(ArrayList.class);
        listImplClass = listImplClass.narrow(listGenericType);

        JInvocation newListImpl = JExpr._new(listImplClass);

        if (node instanceof ArrayNode && node.size() > 0) {
            JInvocation invokeAsList = fieldType.owner().ref(Arrays.class).staticInvoke("asList");
View Full Code Here

    private JExpression getDefaultSet(JType fieldType, JsonNode node) {

        JClass setGenericType = ((JClass) fieldType).getTypeParameters().get(0);

        JClass setImplClass = fieldType.owner().ref(LinkedHashSet.class);
        setImplClass = setImplClass.narrow(setGenericType);

        JInvocation newSetImpl = JExpr._new(setImplClass);

        if (node instanceof ArrayNode && node.size() > 0) {
            JInvocation invokeAsList = fieldType.owner().ref(Arrays.class).staticInvoke("asList");
View Full Code Here

        return jclass;
    }

    private JFieldVar addAdditionalPropertiesField(JDefinedClass jclass, JType propertyType) {
        JClass propertiesMapType = jclass.owner().ref(Map.class);
        propertiesMapType = propertiesMapType.narrow(jclass.owner().ref(String.class), propertyType.boxify());

        JClass propertiesMapImplType = jclass.owner().ref(HashMap.class);
        propertiesMapImplType = propertiesMapImplType.narrow(jclass.owner().ref(String.class), propertyType.boxify());

        JFieldVar field = jclass.field(JMod.PRIVATE, propertiesMapType, "additionalProperties");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.