Tabnine Logo
TypeDef.toReference
Code IndexAdd Tabnine to your IDE (free)

How to use
toReference
method
in
io.sundr.codegen.model.TypeDef

Best Java code snippets using io.sundr.codegen.model.TypeDef.toReference (Showing top 20 results out of 315)

origin: sundrio/sundrio

public TypeRef apply(TypeRef item) {
  return Collections.LIST.toReference(item);
  //TODO: Need a home for: .withDefaultImplementation(Constants.ARRAY_LIST)
}
origin: sundrio/sundrio

/**
 * Creates a {@link ClassRef} for the current definition with the specified arguments.
 *
 * @param arguments The arguments to be passed to the reference.
 */
public ClassRef toReference(Collection<TypeRef> arguments) {
  return toReference(arguments);
}
origin: sundrio/sundrio

  public ClassRef transition(TypeDef from, ClassRef to) {
    return from.toReference(to);
  }
};
origin: sundrio/sundrio

public TypeRef apply(TypeRef item) {
  return Collections.ARRAY_LIST.toReference(item);
}
origin: sundrio/sundrio

private String usingConstructor(List<String> item) {
  int size = item != null ? item.size() : 0;
  checkConstructorArguments(size);
  if (size == 0) {
    return "new " + typeDef.toReference(parameters) + "()";
  }
  return "new " + typeDef.toReference(parameters) + "(" + item.stream().collect(Collectors.joining(", ")) + ")";
}
origin: sundrio/sundrio

  public ClassRef apply(TypeDef item) {
    List<TypeRef> parameters = new ArrayList<TypeRef>();
    for (TypeParamDef param : item.getParameters()) {
      parameters.add(param.toReference());
    }
    parameters.add(Q);
    return SHALLOW_FLUENT.apply(item).toReference(parameters);
  }
};
origin: sundrio/sundrio

  && (extendsList.size() != 1 || !extendsList.contains(OBJECT.toReference()))) {
sb.append(SPACE).append(EXTENDS).append(SPACE);
sb.append(StringUtils.join(extendsList, COMA));
origin: sundrio/sundrio

  public TypeDef apply(TypeDef item) {
    TypeDef builder = SHALLOW_BUILDER.apply(item);
    TypeDef fluent = FLUENT_IMPL.apply(item);
    List<TypeRef> parameters = new ArrayList<TypeRef>();
    for (TypeParamDef param : item.getParameters()) {
      parameters.add(param.toReference());
    }
    parameters.add(builder.toInternalReference());
    return new TypeDefBuilder(item)
        .withKind(Kind.CLASS)
        .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
        .withName(item.getName() + "Builder")
        .withParameters(item.getParameters())
        .withInnerTypes()
        .withExtendsList(fluent.toReference(parameters))
        .withImplementsList(BuilderContextManager.getContext().getVisitableBuilderInterface().toReference(item.toInternalReference(), builder.toInternalReference()))
        .build();
  }
};
origin: sundrio/sundrio

  @Override
  public Method apply(Property property) {
    Method method = WITH_NEW_LIKE_NESTED.apply(property);
    if (!(property.getTypeRef() instanceof ClassRef)) {
      throw new IllegalStateException("Expected Nestable / Buildable type and found:" + property.getTypeRef());
    }
    ClassRef baseType = (ClassRef) TypeAs.UNWRAP_COLLECTION_OF.apply(property.getTypeRef());
    TypeRef returnType = property.hasAttribute(GENERIC_TYPE_REF) ? property.getAttribute(GENERIC_TYPE_REF) : T_REF;
    TypeDef nestedTypeImpl = PropertyAs.NESTED_CLASS_TYPE.apply(property);
    List<TypeRef> typeArguments = new ArrayList<TypeRef>();
    for (TypeRef ignore : baseType.getArguments()) {
      typeArguments.add(Q);
    }
    typeArguments.add(returnType);
    ClassRef rewrapedImpl = nestedTypeImpl.toReference(typeArguments);
    return new MethodBuilder(method)
        .addToArguments(0, INDEX)
        .withName(method.getName().replaceFirst("add", "set"))
        .editBlock()
        .withStatements(new StringStatement("return new " + rewrapedImpl.getName() + "(index, item);"))
        .endBlock()
        .build();
  }
};
origin: sundrio/sundrio

  private static Method superConstructorOf(Method constructor, TypeDef constructorType) {
    List<AnnotationRef> annotations = new ArrayList<AnnotationRef>();
    for (AnnotationRef candidate : constructor.getAnnotations()) {
      if (!candidate.getClassRef().equals(BUILDABLE_ANNOTATION.getClassRef())) {
        annotations.add(candidate);
      }
    }

    return new MethodBuilder(constructor)
        .withAnnotations(annotations)
        .withReturnType(constructorType.toReference())
        .withNewBlock()
        .addNewStringStatementStatement("super(" + StringUtils.join(constructor.getArguments(), new Function<Property, String>() {
          public String apply(Property item) {
            return item.getName();
          }
        }, ", ") + ");")
        .endBlock()
        .build();
  }
}
origin: sundrio/sundrio

  public ClassRef apply(TypeRef item) {
    TypeRef baseType = TypeAs.combine(UNWRAP_COLLECTION_OF, UNWRAP_ARRAY_OF).apply(item);
    if (baseType instanceof ClassRef) {
      baseType = new ClassRefBuilder((ClassRef)baseType).withArguments().build();
    }
    WildcardRef wildcardRef = new WildcardRefBuilder().addToBounds(baseType).build();
    return BuilderContextManager.getContext().getVisitableBuilderInterface().toReference(wildcardRef, Q);
  }
};
origin: sundrio/sundrio

String builderClass = builder.toReference().getName();
statements.add(new StringStatement("if (" + argumentName + "!=null){ this." + fieldName + "= new " + builderClass + "(" + argumentName + "); _visitables.add(this." + fieldName + ");} return (" + returnType + ") this;"));
return statements;
  TypeRef dunwraped = combine(UNWRAP_COLLECTION_OF, UNWRAP_ARRAY_OF, UNWRAP_OPTIONAL_OF).apply(descendant.getTypeRef());
  TypeDef builder = BUILDER.apply(((ClassRef) dunwraped).getDefinition());
  String builderClass = builder.toReference().getName();
  statements.add(new StringStatement("if (" + argumentName + " instanceof " + dunwraped + "){ this." + fieldName + "= new " + builderClass + "((" + dunwraped + ")" + argumentName + "); _visitables.add(this." + fieldName + ");}"));
origin: sundrio/sundrio

List<TypeRef> pivotParameters = new ArrayList<TypeRef>(superClassParameters);
pivotParameters.add(N.toReference());
superClassParameters.add(nested.toReference(pivotParameters));
    .withOuterType(outerInterface)
    .withImplementsList()
    .withExtendsList(BuilderContextManager.getContext().getNestedInterface().toReference(N.toReference()), superClassFluent)
    .build();
origin: sundrio/sundrio

pivotParameters.add(N.toReference());
ClassRef nestedInterfaceRef = nestedInterfaceType.toReference(pivotParameters);
superClassParameters.add(nestedInterfaceRef);
    .withParameters(parameters)
    .withExtendsList(superClassFluent)
    .withImplementsList(nestedInterfaceRef, BuilderContextManager.getContext().getNestedInterface().toReference(N.toReference()))
    .build();
origin: sundrio/sundrio

  public TypeDef apply(TypeDef item) {
    BuilderContext ctx = BuilderContextManager.getContext();
    TypeDef fluent = SHALLOW_FLUENT.apply(item);
    List<TypeParamDef> parameters = new ArrayList<TypeParamDef>(item.getParameters());
    List<TypeRef> superClassParameters = new ArrayList<TypeRef>();
    TypeParamDef nextParameter = getNextGeneric(item, parameters);
    ClassRef builableSuperClassRef = findBuildableSuperClassRef(item);
    TypeDef buildableSuperClass = findBuildableSuperClass(item);
    if (builableSuperClassRef != null) {
      superClassParameters.addAll(builableSuperClassRef.getArguments());
    }
    TypeParamDef parameterFluent = new TypeParamDefBuilder(nextParameter).addToBounds(fluent.toInternalReference()).build();
    parameters.add(parameterFluent);
    superClassParameters.add(parameterFluent.toReference());
    TypeDef superClass = buildableSuperClass != null
        ? SHALLOW_FLUENT.apply(buildableSuperClass)
        : ctx.getFluentInterface();
    return new TypeDefBuilder(item)
        .withKind(Kind.INTERFACE)
        .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
        .withName(item.getName() + "Fluent")
        .withPackageName(item.getPackageName())
        .withParameters(parameters)
        .withExtendsList(superClass.toReference(superClassParameters))
        .withImplementsList()
        .withInnerTypes()
        .build();
  }
};
origin: sundrio/sundrio

public TypeDef apply(TypeDef item) {
  BuilderContext ctx = BuilderContextManager.getContext();
  TypeDef fluent = SHALLOW_FLUENT.apply(item);
  List<TypeParamDef> parameters = new ArrayList<TypeParamDef>(item.getParameters());
  List<TypeRef> superClassParameters = new ArrayList<TypeRef>();
  TypeParamDef nextParameter = getNextGeneric(item, parameters);
  ClassRef builableSuperClassRef = findBuildableSuperClassRef(item);
  if (builableSuperClassRef != null) {
    superClassParameters.addAll(builableSuperClassRef.getArguments());
  }
  TypeParamDef parameterFluent = new TypeParamDefBuilder(nextParameter).addToBounds(fluent.toInternalReference()).build();
  parameters.add(parameterFluent);
  superClassParameters.add(parameterFluent.toReference());
  TypeDef buildableSuperClass = findBuildableSuperClass(item);
  TypeDef superClass = buildableSuperClass != null
      ? FLUENT_IMPL.apply(buildableSuperClass)
      : ctx.getBaseFluentClass();
  return new TypeDefBuilder(item)
      .withKind(Kind.CLASS)
      .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
      .withName(item.getName() + "FluentImpl")
      .withPackageName(item.getPackageName())
      .withParameters(parameters)
      .withExtendsList(superClass.toReference(superClassParameters))
      .withImplementsList(SHALLOW_FLUENT.apply(item).toInternalReference())
      .withInnerTypes()
      .build();
}
origin: sundrio/sundrio

  public TypeDef apply(TypeDef item) {
    List<TypeParamDef> parameters = new ArrayList<TypeParamDef>();
    for (TypeParamDef generic : item.getParameters()) {
      parameters.add(generic);
    }
    return new TypeDefBuilder(item)
        .withKind(Kind.CLASS)
        .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
        .withName("Editable" + item.getName())
        .withParameters(parameters)
        .withExtendsList(item.toInternalReference())
        .withImplementsList(BuilderContextManager.getContext().getEditableInterface().toReference(SHALLOW_BUILDER.apply(item).toInternalReference()))
        .withInnerTypes()
        .withProperties()
        .withMethods()
        .withConstructors()
        .build();
  }
};
origin: sundrio/sundrio

ClassRef builderType = TypeAs.SHALLOW_BUILDER.apply(unwrappedClassRef.getDefinition()).toReference();
ClassRef rewraped = nestedType.toReference(typeArguments);
origin: sundrio/sundrio

ClassRef rewraped = nestedType.toReference(typeArguments);
ClassRef rewrapedImpl = nestedTypeImpl.toReference(typeArguments);
origin: sundrio/sundrio

ClassRef rewraped = nestedType.toReference(typeArguments);
ClassRef rewrapedImpl = nestedTypeImpl.toReference(typeArguments);
io.sundr.codegen.modelTypeDeftoReference

Javadoc

Creates a ClassRef for the current definition with the specified arguments.

Popular methods of TypeDef

  • getFullyQualifiedName
    Returns the fully qualified name of the type.
  • getName
  • getPackageName
  • equals
  • getAttributes
  • getConstructors
  • getExtendsList
  • getMethods
  • getParameters
  • getProperties
  • toInternalReference
    Creates a ClassRef for internal use inside the scope of the type (methods, properties etc). It uses
  • getAnnotations
  • toInternalReference,
  • getAnnotations,
  • getAttribute,
  • getImplementsList,
  • getKind,
  • hasAttribute,
  • isAbstract,
  • isAssignableFrom,
  • toUnboundedReference

Popular in Java

  • Reading from database using SQL prepared statement
  • onRequestPermissionsResult (Fragment)
  • setContentView (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • String (java.lang)
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now