@Test public void testParseModifiers() { Assert.assertEquals(0, Settings.parseModifiers("", Modifier.fieldModifiers())); Assert.assertEquals(Modifier.STATIC, Settings.parseModifiers("static", Modifier.fieldModifiers())); Assert.assertEquals(Modifier.STATIC | Modifier.TRANSIENT, Settings.parseModifiers("static | transient", Modifier.fieldModifiers())); }
public static int parseModifiers(String modifiers, int allowedModifiers) { return Stream.of(modifiers.split("\\|")) .map(String::trim) .filter(s -> !s.isEmpty()) .map(s -> { try { return javax.lang.model.element.Modifier.valueOf(s.toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new RuntimeException("Invalid modifier: " + s); } }) .mapToInt(modifier -> { final int mod = Settings.modifierToBitMask(modifier); if ((mod & allowedModifiers) == 0) { throw new RuntimeException("Modifier not allowed: " + modifier); } return mod; }) .reduce(0, (a, b) -> a | b); }
Settings { public static int parseModifiers(String modifiers, int allowedModifiers) { return Stream.of(modifiers.split("\\|")) .map(String::trim) .filter(s -> !s.isEmpty()) .map(s -> { try { return javax.lang.model.element.Modifier.valueOf(s.toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new RuntimeException("Invalid modifier: " + s); } }) .mapToInt(modifier -> { final int mod = Settings.modifierToBitMask(modifier); if ((mod & allowedModifiers) == 0) { throw new RuntimeException("Modifier not allowed: " + modifier); } return mod; }) .reduce(0, (a, b) -> a | b); } }
Settings { public static int parseModifiers(String modifiers, int allowedModifiers) { return Stream.of(modifiers.split("\\|")) .map(String::trim) .filter(s -> !s.isEmpty()) .map(s -> { try { return javax.lang.model.element.Modifier.valueOf(s.toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new RuntimeException("Invalid modifier: " + s); } }) .mapToInt(modifier -> { final int mod = Settings.modifierToBitMask(modifier); if ((mod & allowedModifiers) == 0) { throw new RuntimeException("Modifier not allowed: " + modifier); } return mod; }) .reduce(0, (a, b) -> a | b); }  }
Settings { public static int parseModifiers(String modifiers, int allowedModifiers) { return Stream.of(modifiers.split("\\|")) .map(String::trim) .filter(s -> !s.isEmpty()) .map(s -> { try { return javax.lang.model.element.Modifier.valueOf(s.toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new RuntimeException("Invalid modifier: " + s); } }) .mapToInt(modifier -> { final int mod = Settings.modifierToBitMask(modifier); if ((mod & allowedModifiers) == 0) { throw new RuntimeException("Modifier not allowed: " + modifier); } return mod; }) .reduce(0, (a, b) -> a | b); }  static URLClassLoader createClassLoader(String name, URL[] urls, ClassLoader parent); void setStringQuotes(StringQuotes quotes); void setIndentString(String indentString); void setJackson2Configuration(ClassLoader classLoader, Jackson2Configuration configuration); void loadCustomTypeProcessor(ClassLoader classLoader, String customTypeProcessor); void loadExtensions(ClassLoader classLoader, List<String> extensions, List<Settings.ConfiguredExtension> extensionsWithConfiguration); void loadNonConstEnumAnnotations(ClassLoader classLoader, List<String> stringAnnotations); void loadIncludePropertyAnnotations(ClassLoader classLoader, List<String> includePropertyAnnotations); void loadExcludePropertyAnnotations(ClassLoader classLoader, List<String> excludePropertyAnnotations); void loadOptionalAnnotations(ClassLoader classLoader, List<String> optionalAnnotations); void loadRequiredAnnotations(ClassLoader classLoader, List<String> requiredAnnotations); void loadNullableAnnotations(ClassLoader classLoader, List<String> nullableAnnotations); void loadJackson2Modules(ClassLoader classLoader, List<String> jackson2Modules); static Map<String, String> convertToMap(List<String> mappings); void validate(); NullabilityDefinition getNullabilityDefinition(); TypeParser getTypeParser(); List<CustomTypeMapping> getValidatedCustomTypeMappings(); List<CustomTypeAlias> getValidatedCustomTypeAliases(); List<CustomTypeAlias> validateCustomTypeAliases(Map<String, String> customTypeAliases); String getExtension(); void validateFileName(File outputFile); String getDefaultNpmVersion(); LoadedModuleDependencies getModuleDependencies(); LoadedDataLibraries getLoadedDataLibraries(); Predicate<String> getExcludeFilter(); void setExcludeFilter(List<String> excludedClasses, List<String> excludedClassPatterns); static Predicate<String> createExcludeFilter(List<String> excludedClasses, List<String> excludedClassPatterns); Predicate<String> getMapClassesAsClassesFilter(); @Deprecated void setJaxrsNamespacingAnnotation(ClassLoader classLoader, String jaxrsNamespacingAnnotation); void setRestNamespacingAnnotation(ClassLoader classLoader, String restNamespacingAnnotation); void setRestOptionsType(String restOptionsType); List<RestApplicationParser.Factory> getRestApplicationParserFactories(); boolean isGenerateJaxrs(); boolean isGenerateSpring(); boolean isGenerateRest(); boolean areDefaultStringEnumsOverriddenByExtension(); static int parseModifiers(String modifiers, int allowedModifiers); }
Settings { public static int parseModifiers(String modifiers, int allowedModifiers) { return Stream.of(modifiers.split("\\|")) .map(String::trim) .filter(s -> !s.isEmpty()) .map(s -> { try { return javax.lang.model.element.Modifier.valueOf(s.toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new RuntimeException("Invalid modifier: " + s); } }) .mapToInt(modifier -> { final int mod = Settings.modifierToBitMask(modifier); if ((mod & allowedModifiers) == 0) { throw new RuntimeException("Modifier not allowed: " + modifier); } return mod; }) .reduce(0, (a, b) -> a | b); }  static URLClassLoader createClassLoader(String name, URL[] urls, ClassLoader parent); void setStringQuotes(StringQuotes quotes); void setIndentString(String indentString); void setJackson2Configuration(ClassLoader classLoader, Jackson2Configuration configuration); void loadCustomTypeProcessor(ClassLoader classLoader, String customTypeProcessor); void loadExtensions(ClassLoader classLoader, List<String> extensions, List<Settings.ConfiguredExtension> extensionsWithConfiguration); void loadNonConstEnumAnnotations(ClassLoader classLoader, List<String> stringAnnotations); void loadIncludePropertyAnnotations(ClassLoader classLoader, List<String> includePropertyAnnotations); void loadExcludePropertyAnnotations(ClassLoader classLoader, List<String> excludePropertyAnnotations); void loadOptionalAnnotations(ClassLoader classLoader, List<String> optionalAnnotations); void loadRequiredAnnotations(ClassLoader classLoader, List<String> requiredAnnotations); void loadNullableAnnotations(ClassLoader classLoader, List<String> nullableAnnotations); void loadJackson2Modules(ClassLoader classLoader, List<String> jackson2Modules); static Map<String, String> convertToMap(List<String> mappings); void validate(); NullabilityDefinition getNullabilityDefinition(); TypeParser getTypeParser(); List<CustomTypeMapping> getValidatedCustomTypeMappings(); List<CustomTypeAlias> getValidatedCustomTypeAliases(); List<CustomTypeAlias> validateCustomTypeAliases(Map<String, String> customTypeAliases); String getExtension(); void validateFileName(File outputFile); String getDefaultNpmVersion(); LoadedModuleDependencies getModuleDependencies(); LoadedDataLibraries getLoadedDataLibraries(); Predicate<String> getExcludeFilter(); void setExcludeFilter(List<String> excludedClasses, List<String> excludedClassPatterns); static Predicate<String> createExcludeFilter(List<String> excludedClasses, List<String> excludedClassPatterns); Predicate<String> getMapClassesAsClassesFilter(); @Deprecated void setJaxrsNamespacingAnnotation(ClassLoader classLoader, String jaxrsNamespacingAnnotation); void setRestNamespacingAnnotation(ClassLoader classLoader, String restNamespacingAnnotation); void setRestOptionsType(String restOptionsType); List<RestApplicationParser.Factory> getRestApplicationParserFactories(); boolean isGenerateJaxrs(); boolean isGenerateSpring(); boolean isGenerateRest(); boolean areDefaultStringEnumsOverriddenByExtension(); static int parseModifiers(String modifiers, int allowedModifiers); public String newline; public String quotes; public String indentString; public TypeScriptFileType outputFileType; public TypeScriptOutputKind outputKind; public String module; public String namespace; public boolean mapPackagesToNamespaces; public String umdNamespace; public List<ModuleDependency> moduleDependencies; public JsonLibrary jsonLibrary; public Jackson2ConfigurationResolved jackson2Configuration; public GsonConfiguration gsonConfiguration; public JsonbConfiguration jsonbConfiguration; public List<String> additionalDataLibraries; @Deprecated public boolean declarePropertiesAsOptional; public OptionalProperties optionalProperties; public OptionalPropertiesDeclaration optionalPropertiesDeclaration; public NullabilityDefinition nullabilityDefinition; public boolean declarePropertiesAsReadOnly; public String removeTypeNamePrefix; public String removeTypeNameSuffix; public String addTypeNamePrefix; public String addTypeNameSuffix; public Map<String, String> customTypeNaming; public String customTypeNamingFunction; public CustomTypeNamingFunction customTypeNamingFunctionImpl; public List<String> referencedFiles; public List<String> importDeclarations; public Map<String, String> customTypeMappings; public Map<String, String> customTypeAliases; public DateMapping mapDate; public EnumMapping mapEnum; public boolean nonConstEnums; public List<Class<? extends Annotation>> nonConstEnumAnnotations; public ClassMapping mapClasses; public List<String> mapClassesAsClassesPatterns; public boolean generateConstructors; public boolean disableTaggedUnions; public boolean ignoreSwaggerAnnotations; public boolean generateJaxrsApplicationInterface; public boolean generateJaxrsApplicationClient; public boolean generateSpringApplicationInterface; public boolean generateSpringApplicationClient; public boolean scanSpringApplication; @Deprecated public RestNamespacing jaxrsNamespacing; @Deprecated public Class<? extends Annotation> jaxrsNamespacingAnnotation; @Deprecated public String jaxrsNamespacingAnnotationElement; public RestNamespacing restNamespacing; public Class<? extends Annotation> restNamespacingAnnotation; public String restNamespacingAnnotationElement; public String restResponseType; public String restOptionsType; public boolean restOptionsTypeIsGeneric; public TypeProcessor customTypeProcessor; public boolean sortDeclarations; public boolean sortTypeDeclarations; public boolean noFileComment; public boolean noTslintDisable; public boolean noEslintDisable; public boolean tsNoCheck; public List<File> javadocXmlFiles; public List<EmitterExtension> extensions; public List<Class<? extends Annotation>> includePropertyAnnotations; public List<Class<? extends Annotation>> excludePropertyAnnotations; public List<Class<? extends Annotation>> optionalAnnotations; public List<Class<? extends Annotation>> requiredAnnotations; public List<Class<? extends Annotation>> nullableAnnotations; public boolean generateInfoJson; public boolean generateNpmPackageJson; public String npmName; public String npmVersion; public Map<String, String> npmPackageDependencies; public String typescriptVersion; public String npmBuildScript; @Deprecated public boolean displaySerializerWarning; @Deprecated public boolean debug; @Deprecated public boolean disableJackson2ModuleDiscovery; public boolean jackson2ModuleDiscovery; public List<Class<? extends Module>> jackson2Modules; public ClassLoader classLoader; }