Tabnine Logo
TypeUtils.modifiersToInt
Code IndexAdd Tabnine to your IDE (free)

How to use
modifiersToInt
method
in
io.sundr.codegen.utils.TypeUtils

Best Java code snippets using io.sundr.codegen.utils.TypeUtils.modifiersToInt (Showing top 20 results out of 315)

origin: sundrio/sundrio

public static int modifiersToInt(Modifier... modifiers) {
  return modifiersToInt(Arrays.asList(modifiers));
}
origin: sundrio/sundrio

  public Property apply(final VariableElement variableElement) {
    String name = variableElement.getSimpleName().toString();
    TypeRef type = MIRROR_TO_TYPEREF.apply(variableElement.asType());
    List<AnnotationRef> annotations = new ArrayList<AnnotationRef>();
    for (AnnotationMirror annotationMirror : variableElement.getAnnotationMirrors()) {
        annotations.add(ANNOTATION_REF.apply(annotationMirror));
    }
    return new PropertyBuilder()
        .withName(name)
        .withTypeRef(type)
        .withAnnotations(annotations)
        .withModifiers(TypeUtils.modifiersToInt(variableElement.getModifiers()))
        .build();
  }
};
origin: sundrio/sundrio

  public Method apply(ExecutableElement executableElement) {
    MethodBuilder methodBuilder = new MethodBuilder()
        .withModifiers(TypeUtils.modifiersToInt(executableElement.getModifiers()))
        .withName(executableElement.getSimpleName().toString())
        .withReturnType(MIRROR_TO_TYPEREF.apply(executableElement.getReturnType()));
    //Populate constructor parameters
    for (VariableElement variableElement : executableElement.getParameters()) {
      methodBuilder = methodBuilder.addToArguments(PROPERTY.apply(variableElement));
      List<ClassRef> exceptionRefs = new ArrayList<ClassRef>();
      for (TypeMirror thrownType : executableElement.getThrownTypes()) {
        if (thrownType instanceof ClassRef) {
          exceptionRefs.add((ClassRef) thrownType);
        }
      }
      methodBuilder = methodBuilder.withExceptions(exceptionRefs);
    }
    List<ClassRef> annotationRefs = new ArrayList<ClassRef>();
    for (AnnotationMirror annotationMirror : executableElement.getAnnotationMirrors()) {
      methodBuilder.withAnnotations(ANNOTATION_REF.apply(annotationMirror));
    }
    return methodBuilder.build();
  }
};
origin: sundrio/sundrio

  public TypeDef apply(TypeElement classElement) {
    List<ClassRef> extendsList = new ArrayList<ClassRef>();
    //Check SuperClass
    Kind kind = Kind.CLASS;
    if (classElement.getKind() == ElementKind.INTERFACE) {
      kind = Kind.INTERFACE;
    } else if (classElement.getKind() == ElementKind.CLASS) {
      kind = Kind.CLASS;
      extendsList.add(TypeDef.OBJECT_REF);
    } else if (classElement.getKind() == ElementKind.ANNOTATION_TYPE) {
      kind = Kind.ANNOTATION;
    }
    Set<Method> allMethods = new LinkedHashSet<Method>();
    for (ExecutableElement method : ElementFilter.methodsIn(classElement.getEnclosedElements())) {
    }
    return new TypeDefBuilder()
        .withKind(kind)
        .withModifiers(TypeUtils.modifiersToInt(classElement.getModifiers()))
        .withPackageName(getPackageName(classElement))
        .withName(getClassName(classElement))
        .withExtendsList(extendsList)
        .addAllToMethods(allMethods)
        .withOuterType(classElement.getEnclosingElement() instanceof TypeElement ? SHALLOW_TYPEDEF.apply((TypeElement) classElement.getEnclosingElement()) : null)
        .build();
  }
};
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 Method apply(Property property) {
  TypeRef returnType = property.hasAttribute(GENERIC_TYPE_REF) ? property.getAttribute(GENERIC_TYPE_REF) : T_REF;
  String methodName = "with" + property.getNameCapitalized();
  List<ClassRef> alsoImport = new ArrayList<ClassRef>();
  return new MethodBuilder()
      .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
      .withName(methodName)
      .withReturnType(returnType)
      .withArguments(property)
      .withVarArgPreferred(true)
      .withNewBlock()
      .withStatements(getStatements(property, alsoImport))
      .endBlock()
      .addToAttributes(Attributeable.ALSO_IMPORT, alsoImport)
      .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 Method apply(Property property) {
    String methodName = "set" + property.getNameCapitalized();
    return new MethodBuilder()
        .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
        .withName(methodName)
        .withReturnType(VOID)
        .withArguments()
        .withNewBlock()
        .addNewStringStatementStatement("this." + property.getName() + "=" + property.getName() + ";")
        .endBlock()
        .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

  public Method apply(final Property property) {
    String prefix = "has";
    String methodName = prefix + property.getNameCapitalized();
    List<Statement> statements = new ArrayList<Statement>();
    if (isPrimitive(property.getTypeRef())) {
      statements.add(new StringStatement("return true;"));
    } else if (isList(property.getTypeRef()) || isSet(property.getTypeRef())) {
      statements.add(new StringStatement("return " + property.getName() + " != null && !" + property.getName() + ".isEmpty();"));
    } else if (isOptional(property.getTypeRef())|| isOptionalInt(property.getTypeRef()) || isOptionalLong(property.getTypeRef()) || isOptionalDouble(property.getTypeRef())) {
      statements.add(new StringStatement("return " + property.getName() + " != null && " + property.getName() + ".isPresent();"));
    } else {
      statements.add(new StringStatement("return this." + property.getName() + " != null;"));
    }
    return new MethodBuilder()
        .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
        .withName(methodName)
        .withReturnType(BOOLEAN_REF)
        .withArguments()
        .withNewBlock()
        .withStatements(statements)
        .endBlock()
        .build();
  }
});
origin: sundrio/sundrio

  public Method apply(Property property) {
    TypeRef returnType = property.hasAttribute(GENERIC_TYPE_REF) ? property.getAttribute(GENERIC_TYPE_REF) : T_REF;
    if (!(property.getTypeRef() instanceof ClassRef)) {
      throw new IllegalStateException("Expected Map type and found:" + property.getTypeRef());
    }
    ClassRef mapType = (ClassRef) property.getTypeRef();
    TypeRef keyType = mapType.getArguments().get(0);
    TypeRef valueType = mapType.getArguments().get(1);
    Property keyProperty = new PropertyBuilder().withName("key").withTypeRef(keyType).build();
    Property valueProperty = new PropertyBuilder().withName("value").withTypeRef(valueType).build();
    String methodName = "addTo" + property.getNameCapitalized();
    return new MethodBuilder()
        .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
        .withName(methodName)
        .withReturnType(returnType)
        .withArguments(new Property[]{keyProperty, valueProperty})
        .withNewBlock()
        .addNewStringStatementStatement("if(this."+property.getName()+" == null && key != null && value != null) { this." + property.getName() + " = " + property.getAttribute(INIT_FUNCTION).apply(Collections.emptyList()) + "; }")
        .addNewStringStatementStatement("if(key != null && value != null) {this." + property.getName() + ".put(key, value);} return (" + returnType + ")this;")
        .endBlock()
        .build();
  }
});
origin: sundrio/sundrio

  public Method apply(Property property) {
    TypeRef returnType = property.hasAttribute(GENERIC_TYPE_REF) ? property.getAttribute(GENERIC_TYPE_REF) : T_REF;
    ClassRef mapType = (ClassRef) property.getTypeRef();
    TypeRef keyType = mapType.getArguments().get(0);
    Property keyProperty = new PropertyBuilder().withName("key").withTypeRef(keyType).build();
    String methodName = "removeFrom" + property.getNameCapitalized();
    return new MethodBuilder()
        .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
        .withName(methodName)
        .withReturnType(returnType)
        .withArguments(keyProperty)
        .withNewBlock()
        .addNewStringStatementStatement("if(this." + property.getName() + " == null) { return (" + returnType + ") this; }")
        .addNewStringStatementStatement("if(key != null && this."+property.getName()+" != null) {this." + property.getName() + ".remove(key);} return (" + returnType + ")this;")
        .endBlock()
        .build();
  }
});
origin: sundrio/sundrio

  public Method apply(Property property) {
    TypeRef returnType = property.hasAttribute(GENERIC_TYPE_REF) ? property.getAttribute(GENERIC_TYPE_REF) : T_REF;
    TypeRef mapType =  property.getTypeRef();
    Property mapProperty = new PropertyBuilder().withName("map").withTypeRef(mapType).build();
    String methodName = "addTo" + property.getNameCapitalized();
    return new MethodBuilder()
        .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
        .withName(methodName)
        .withReturnType(returnType)
        .withArguments(mapProperty)
        .withNewBlock()
        .addNewStringStatementStatement("if(this."+property.getName()+" == null && map != null) { this." + property.getName() + " = " + property.getAttribute(INIT_FUNCTION).apply(Collections.emptyList()) + "; }")
        .addNewStringStatementStatement("if(map != null) { this." + property.getName() + ".putAll(map);} return (" + returnType + ")this;")
        .endBlock()
        .build();
  }
});
origin: sundrio/sundrio

  public Method apply(Property property) {
    TypeDef originTypeDef = property.getAttribute(Constants.ORIGIN_TYPEDEF);
    String methodName = "end" + BuilderUtils.fullyQualifiedNameDiff(property.getTypeRef(), originTypeDef) + capitalizeFirst(IS_COLLECTION.apply(property.getTypeRef())
        ? Singularize.FUNCTION.apply(property.getNameCapitalized())
        : property.getNameCapitalized());
    return new MethodBuilder()
        .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
        .withReturnType(N_REF)
        .withName(methodName)
        .withNewBlock()
        .addNewStringStatementStatement("return and();")
        .endBlock()
        .build();
  }
});
origin: sundrio/sundrio

public Method apply(Property property) {
  String classPrefix = getClassPrefix(property);
  boolean isArray = TypeUtils.isArray(property.getTypeRef());
  boolean isList = TypeUtils.isList(property.getTypeRef());
  boolean isSet = TypeUtils.isSet(property.getTypeRef());
  String prefix = isArray || isList ? "setTo" : "with";
  String withMethodName = prefix + property.getNameCapitalized();
  return new MethodBuilder()
      .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
      .withReturnType(N_REF)
      .withName("and")
      .withNewBlock()
      .addNewStringStatementStatement("return (N) " + classPrefix + withMethodName + "(" +
          (isArray || isList ? "index, " : "")
          + "builder.build());")
      .endBlock()
      .build();
}
origin: sundrio/sundrio

public Method apply(Property property) {
  TypeRef returnType = property.hasAttribute(GENERIC_TYPE_REF) ? property.getAttribute(GENERIC_TYPE_REF) : T_REF;
  String methodName = "with" + property.getNameCapitalized();
  TypeRef unwraped = combine(UNWRAP_COLLECTION_OF, UNWRAP_ARRAY_OF).apply(property.getTypeRef());
  String addToMethodName = "addTo" + property.getNameCapitalized();
  TypeRef arrayType = ARRAY_OF.apply(unwraped);
  Property arrayProperty = new PropertyBuilder(property).withTypeRef(arrayType).build();
  return new MethodBuilder()
      .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
      .withName(methodName)
      .withReturnType(returnType)
      .withArguments(arrayProperty)
      .withVarArgPreferred(true)
      .withNewBlock()
      .addNewStringStatementStatement("if (this." + property.getName() + " != null) {this." + property.getName() + ".clear();}")
      .addNewStringStatementStatement("if (" + property.getName() + " != null) {for (" + unwraped.toString() + " item :" + property.getName() + "){ this." + addToMethodName + "(item);}} return (" + returnType + ") this;")
      .endBlock()
      .build();
}
origin: sundrio/sundrio

  public Method apply(Property property) {
    TypeRef returnType = property.hasAttribute(GENERIC_TYPE_REF) ? property.getAttribute(GENERIC_TYPE_REF) : T_REF;
    TypeRef mapType = property.getTypeRef();
    Property mapProperty = new PropertyBuilder().withName("map").withTypeRef(mapType).build();
    String methodName = "removeFrom" + property.getNameCapitalized();
    return new MethodBuilder()
        .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC))
        .withName(methodName)
        .withReturnType(returnType)
        .withArguments(mapProperty)
        .withNewBlock()
        .addNewStringStatementStatement("if(this." + property.getName() + " == null) { return (" + returnType + ") this; }")
        .addNewStringStatementStatement("if(map != null) { for(Object key : map.keySet()) {if (this."+property.getName()+" != null){this." + property.getName() + ".remove(key);}}} return (" + returnType + ")this;")
        .endBlock()
        .build();
  }
});
io.sundr.codegen.utilsTypeUtilsmodifiersToInt

Popular methods of TypeUtils

  • allProperties
  • isCollection
  • isOptional
  • typeGenericOf
    Sets one io.sundr.codegen.model.TypeDef as a generic of an other.
  • visitParents
  • fullyQualifiedNameDiff
  • getParameterDefinition
  • hasProperty
    Checks if property exists on the specified type.
  • isAbstract
    Checks a TypeRef is of an abstract type.
  • isArray
    Checks if a TypeRef is an array.
  • isBoolean
    Checks if a TypeRef is a Boolean or boolean.
  • isInstanceOf
    Checks if a TypeDef is an instance of an other TypeDef.
  • isBoolean,
  • isInstanceOf,
  • isList,
  • isMap,
  • isOptionalDouble,
  • isOptionalInt,
  • isOptionalLong,
  • isPrimitive,
  • isSet

Popular in Java

  • Start an intent from android
  • putExtra (Intent)
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (Timer)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • 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