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

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

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

origin: sundrio/sundrio

/**
 * Checks if there is a default constructor available.
 *
 * @param item The clazz to check.
 * @return     True if default constructor is found, false otherwise.
 */
public static boolean hasDefaultConstructor(TypeDef item) {
  if (item == null) {
    return false;
  } else if (item.getConstructors().isEmpty()) {
    return true;
  } else {
    for (Method constructor : item.getConstructors()) {
      if (constructor.getArguments().size() == 0) {
        return true;
      }
    }
  }
  return false;
}
origin: sundrio/sundrio

public static Method findBuildableConstructor(TypeDef clazz) {
  //1st pass go for annotated method
  for (Method candidate : clazz.getConstructors()) {
    if (hasBuildableAnnotation(candidate)) {
      return candidate;
    }
  }
  //2nd pass go for the first non-empty constructor
  for (Method candidate : clazz.getConstructors()) {
    if (candidate.getArguments().size() != 0) {
      return candidate;
    }
  }
  if (!clazz.getConstructors().isEmpty()) {
    return clazz.getConstructors().iterator().next();
  } else {
    throw new IllegalStateException("Could not find buildable constructor in: ["+clazz.getFullyQualifiedName()+"].");
  }
}
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 static Set<Method> getInlineableConstructors(Property property) {
  Set<Method> result = new HashSet<Method>();
  TypeRef unwrapped = TypeAs.combine(TypeAs.UNWRAP_COLLECTION_OF, TypeAs.UNWRAP_ARRAY_OF, TypeAs.UNWRAP_OPTIONAL_OF).apply(property.getTypeRef());
  if (unwrapped instanceof ClassRef) {
    for (Method candidate : ((ClassRef)unwrapped).getDefinition().getConstructors()) {
      if (isInlineable(candidate)) {
        result.add(candidate);
      }
    }
  }
  //We try both types to make sure...
  TypeDef fromRepo = BuilderContextManager.getContext().getDefinitionRepository().getDefinition(unwrapped);
  if (fromRepo != null) {
    for (Method candidate : fromRepo.getConstructors()) {
      if (isInlineable(candidate)) {
        result.add(candidate);
      }
    }
  }
  return result;
}
origin: sundrio/sundrio

  public TypeDef apply(TypeDef... items) {
    if (items == null || items.length == 0) {
      throw new IllegalArgumentException("Items cannot be empty.");
    } else if (items.length == 1) {
      return items[0];
    } else if (items.length == 2) {
      TypeDef mergedType = TYPES.apply(new TypeDef[]{items[0], items[1]});
      TypeDefBuilder builder = new TypeDefBuilder(mergedType);
      for (Method constructor : items[1].getConstructors()) {
        builder = builder.addToConstructors(constructor);
      }
      for (Method method : items[1].getMethods()) {
        builder = builder.addToMethods(method);
      }
      for (Property property : items[1].getProperties()) {
        builder = builder.addToProperties(property);
      }
      return builder.build();
    } else {
      TypeDef[] rest = new TypeDef[items.length - 1];
      System.arraycopy(items, 1, rest, 0, rest.length);
      CLASSES.apply(new TypeDef[]{items[0], CLASSES.apply(rest)});
    }
    return null;
  }
};
origin: sundrio/sundrio

List<Method> methods = new ArrayList<Method>();
for (Method constructor : item.getConstructors()) {
  constructors.add(superConstructorOf(constructor, editableType));
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 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(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.modelTypeDefgetConstructors

Popular methods of TypeDef

  • getFullyQualifiedName
    Returns the fully qualified name of the type.
  • getName
  • getPackageName
  • equals
  • getAttributes
  • 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

  • Making http post requests using okhttp
  • setScale (BigDecimal)
  • findViewById (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Top 12 Jupyter Notebook extensions
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