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

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

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

origin: sundrio/sundrio

private String usingStaticFactoryMethod(List<String> item) {
  int size = item != null ? item.size() : 0;
  checkFactoryMethodArguments(size);
    if (size == 0) {
    return typeDef.getName() + "." + staticFactoryMethod + "()";
  }
  return typeDef.getName() + "." + staticFactoryMethod + "(" + item.stream().collect(Collectors.joining(", ")) + ")";
}
origin: sundrio/sundrio

/**
 * Converts a reference from the source type, to the target type by using the builder.
 * @param ref               The ref.
 * @param source            The source type of the reference..
 * @param target            The target type.
 * @param targetBuilder     The target type builder.
 * @return
 */
private static String convertReference(String ref, TypeDef source, TypeDef target, TypeDef targetBuilder) {
  StringBuilder sb = new StringBuilder();
  sb.append("new ").append(targetBuilder.getName()).append("(").append(convertReference(ref,source,target)).append(")");
  return sb.toString();
}
origin: sundrio/sundrio

/**
 * Returns the fully qualified name of the type.
 */
public String getFullyQualifiedName() {
  StringBuilder sb = new StringBuilder();
  if (packageName != null && !packageName.isEmpty()) {
    sb.append(getPackageName()).append(".");
  }
  if (outerType != null) {
    sb.append(outerType.getName()).append(".");
  }
  sb.append(getName());
  return sb.toString();
}
origin: sundrio/sundrio

private String getClassPrefix(Property property) {
  TypeDef memberOf = property.getAttribute(OUTER_CLASS);
  if (memberOf != null) {
    return memberOf.getName() + ".this.";
  } else return "";
}
origin: sundrio/sundrio

/**
 * Create a mapping from class name to {@link ClassRef}.
 */
private Map<String, ClassRef> getReferenceMap() {
  Map<String, ClassRef> mapping = new HashMap<String, ClassRef>();
  List<ClassRef> refs = getReferences();
  //It's best to have predictable order, so that we can generate uniform code.
  Collections.sort(refs, new Comparator<ClassRef>() {
    @Override
    public int compare(ClassRef o1, ClassRef o2) {
      return o1.getFullyQualifiedName().compareTo(o2.getFullyQualifiedName());
    }
  });
  for (ClassRef ref : refs) {
    String key = ref.getDefinition().getName();
    if (!mapping.containsKey(key)) {
      mapping.put(key, ref);
    }
  }
  return mapping;
}
origin: sundrio/sundrio

public boolean isAssignableFrom(TypeRef o) {
  if (this == o) {
    return true;
  } else if (o == null) {
    return false;
  } else if (o instanceof ClassRef) {
    if (!((ClassRef) o).getDefinition().getPackageName().equals(JAVA_LANG)) {
      return false;
    }
    if (!((ClassRef) o).getDefinition().getName().toUpperCase().startsWith(name.toUpperCase())) {
      return false;
    }
    return true;
  }
  if (o == null || getClass() != o.getClass()) return false;
  PrimitiveRef that = (PrimitiveRef) o;
  if (dimensions != that.dimensions) return false;
  return name != null ? name.equals(that.name) : that.name == null;
}
origin: sundrio/sundrio

private Map<String, String> getReferenceMapInternal() {
  Map<String, String> mapping = new HashMap<String, String>();
  List<ClassRef> refs = new ArrayList<ClassRef>();
  for (TypeDef typeDef : getDefinitions()) {
    refs.add(typeDef.toInternalReference());
  }
  //It's best to have predictable order, so that we can generate uniform code.
  Collections.sort(refs, new Comparator<ClassRef>() {
    @Override
    public int compare(ClassRef o1, ClassRef o2) {
      return o1.getFullyQualifiedName().compareTo(o2.getFullyQualifiedName());
    }
  });
  for (ClassRef classRef : refs) {
    String key = classRef.getDefinition().getName();
    if (!mapping.containsKey(key)) {
      mapping.put(key, classRef.getDefinition().getFullyQualifiedName());
    }
  }
  mapping.putAll(custom);
  return mapping;
}
origin: sundrio/sundrio

public Set<String> getImports() {
  final Set<String> imports = new LinkedHashSet<String>();
  for (ClassRef ref : getReferenceMap().values()) {
    TypeDef definition = ref.getDefinition();
    if (definition.getPackageName() == null ||
        definition.getPackageName().isEmpty() ||
        definition.getPackageName().equals(packageName) ||
        definition.getName().equals(name)) {
      continue;
    } else {
      imports.add(ref.getDefinition().getFullyQualifiedName());
    }
  }
  return imports;
}
origin: sundrio/sundrio

  /**
   * Checks that a factory method with the required number of arguments is found.
   * @param arguments
   */
  private void checkFactoryMethodArguments(int arguments) {
    for (Method m : typeDef.getMethods()) {
      int a = m.getArguments() != null ? m.getArguments().size() : 0;
      if (m.getName().equals(staticFactoryMethod) && a == arguments && m.isStatic()) {
        return;
      }
    }
    throw new IllegalArgumentException("No static method found on " + typeDef.getName() + " with name " + staticFactoryMethod + " and " + arguments + " arguments.");
  }
}
origin: sundrio/sundrio

/**
 * Checks that a constructor with the required number of arguments is found.
 * @param arguments
 */
private void checkConstructorArguments(int arguments) {
  if (arguments == 0 && (typeDef.getConstructors() == null || typeDef.getConstructors().isEmpty())) {
    return;
  }
  for (Method m : typeDef.getConstructors()) {
    int a = m.getArguments() != null ? m.getArguments().size() : 0;
    if (a == arguments) {
      return;
    }
  }
  throw new IllegalArgumentException("No constructor found for " + typeDef.getName() + " with " + arguments + " arguments.");
}
origin: sundrio/sundrio

public String getName() {
  if (requiresFullyQualifiedName()) {
    return getDefinition().getFullyQualifiedName();
  }
  return getDefinition().getName();
}
origin: sundrio/sundrio

public boolean isAssignableFrom(TypeRef other) {
  if (this == other) {
    return true;
  } else if (other == null) {
    return false;
  } else if (other instanceof PrimitiveRef) {
    if (getDefinition() == null) {
      return false;
    }
    if (getDefinition() != null && !JAVA_LANG.equals(getDefinition().getPackageName())) {
      return false;
    }
    if (!getDefinition().getName().toUpperCase().startsWith(((PrimitiveRef) other).getName().toUpperCase())) {
      return false;
    }
    return true;
  }
  if (!(other instanceof ClassRef)) {
    return false;
  }
  if (this == other || this.equals(other)) {
    return true;
  }
  return definition.isAssignableFrom(((ClassRef) other).getDefinition());
}
origin: sundrio/sundrio

  public TypeDef apply(TypeDef item) {
    List<TypeParamDef> parameters = new ArrayList<TypeParamDef>(item.getParameters());
    parameters.add(getNextGeneric(item));
    return new TypeDefBuilder(item)
        .withKind(Kind.INTERFACE)
        .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
        .withName(item.getName() + "Fluent")
        .withParameters(parameters)
        .withInnerTypes()
        .build();
  }
};
origin: sundrio/sundrio

  public TypeDef apply(TypeDef item) {
    return new TypeDefBuilder(item)
        .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
        .withName(item.getName() + "Builder")
        .withInnerTypes()
        .build();
  }
};
origin: sundrio/sundrio

public TypeDef getInlineableInterface(Inline inline) {
  return new TypeDefBuilder(inlineableBase)
      .withKind(Kind.INTERFACE)
      .withPackageName(builderPackage)
      .withName(inline.prefix() + (!inline.name().isEmpty() ? inline.name() : INLINEABLE.getName()) + inline.suffix())
      .withParameters(INLINEABLE.getParameters())
      .addNewMethod()
      .withReturnType(TypeUtils.newTypeParamRef("T"))
      .withName(inline.value())
      .and()
      .build();
}
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

  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

public TypeDefFluentImpl(TypeDef instance){
    this.withKind(instance.getKind()); 
    this.withPackageName(instance.getPackageName()); 
    this.withName(instance.getName()); 
    this.withComments(instance.getComments()); 
    this.withAnnotations(instance.getAnnotations()); 
    this.withExtendsList(instance.getExtendsList()); 
    this.withImplementsList(instance.getImplementsList()); 
    this.withParameters(instance.getParameters()); 
    this.withProperties(instance.getProperties()); 
    this.withConstructors(instance.getConstructors()); 
    this.withMethods(instance.getMethods()); 
    this.withOuterType(instance.getOuterType()); 
    this.withInnerTypes(instance.getInnerTypes()); 
    this.withModifiers(instance.getModifiers()); 
    this.withAttributes(instance.getAttributes()); 
}
origin: sundrio/sundrio

public TypeDefBuilder(TypeDef instance,Boolean validationEnabled){
    this.fluent = this; 
    this.withKind(instance.getKind()); 
    this.withPackageName(instance.getPackageName()); 
    this.withName(instance.getName()); 
    this.withComments(instance.getComments()); 
    this.withAnnotations(instance.getAnnotations()); 
    this.withExtendsList(instance.getExtendsList()); 
    this.withImplementsList(instance.getImplementsList()); 
    this.withParameters(instance.getParameters()); 
    this.withProperties(instance.getProperties()); 
    this.withConstructors(instance.getConstructors()); 
    this.withMethods(instance.getMethods()); 
    this.withOuterType(instance.getOuterType()); 
    this.withInnerTypes(instance.getInnerTypes()); 
    this.withModifiers(instance.getModifiers()); 
    this.withAttributes(instance.getAttributes()); 
    this.validationEnabled = validationEnabled; 
}
origin: sundrio/sundrio

public TypeDefBuilder(TypeDefFluent<?> fluent,TypeDef instance,Boolean validationEnabled){
    this.fluent = fluent; 
    fluent.withKind(instance.getKind()); 
    fluent.withPackageName(instance.getPackageName()); 
    fluent.withName(instance.getName()); 
    fluent.withComments(instance.getComments()); 
    fluent.withAnnotations(instance.getAnnotations()); 
    fluent.withExtendsList(instance.getExtendsList()); 
    fluent.withImplementsList(instance.getImplementsList()); 
    fluent.withParameters(instance.getParameters()); 
    fluent.withProperties(instance.getProperties()); 
    fluent.withConstructors(instance.getConstructors()); 
    fluent.withMethods(instance.getMethods()); 
    fluent.withOuterType(instance.getOuterType()); 
    fluent.withInnerTypes(instance.getInnerTypes()); 
    fluent.withModifiers(instance.getModifiers()); 
    fluent.withAttributes(instance.getAttributes()); 
    this.validationEnabled = validationEnabled; 
}
public TypeDefBuilder(TypeDef instance){
io.sundr.codegen.modelTypeDefgetName

Popular methods of TypeDef

  • getFullyQualifiedName
    Returns the fully qualified name of the type.
  • 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
  • toReference
  • getAnnotations
  • toReference,
  • getAnnotations,
  • getAttribute,
  • getImplementsList,
  • getKind,
  • hasAttribute,
  • isAbstract,
  • isAssignableFrom,
  • toUnboundedReference

Popular in Java

  • Reactive rest calls using spring rest template
  • onCreateOptionsMenu (Activity)
  • getSystemService (Context)
  • getContentResolver (Context)
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JFrame (javax.swing)
  • Top plugins for Android Studio
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