private static void addTypeWithoutCollection(String name) { TYPES_WITHOUT_COLLECTION.add(NameParser.parseUsingCase(name)); }
private static void addMemberSchemaTypeNameException(String type, String member, String exception) { Name typeName = NameParser.parseUsingSeparator(type, '-'); Name memberName = NameParser.parseUsingSeparator(member, '-'); Map<Name, String> typeExceptions = MEMBER_SCHEMA_TYPE_NAME_EXCEPTIONS.get(typeName); if (typeExceptions == null) { typeExceptions = new HashMap<>(); MEMBER_SCHEMA_TYPE_NAME_EXCEPTIONS.put(typeName, typeExceptions); } typeExceptions.put(memberName, exception); }
private static void addAsyncronous(String name) { ASYNCHRONOUS.add(NameParser.parseUsingCase(name)); }
private void analyzeName(JavaField javaField, Concept concept) { // Fields of classes are parsed using case, but enum values are also represented as fields and they need to be // parsed using underscore as the separator: String javaName = javaField.getName(); Name name; if (javaField.isEnumConstant()) { name = NameParser.parseUsingSeparator(javaName, '_'); } else { name = parseJavaName(javaName); } concept.setName(name); }
/** * Creates a model name from a Java name, doing any processing that is required, for example removing the prefixes * or suffixes that are used to avoid conflicts with Java reserved words. */ public static Name parseJavaName(String text) { // Remove the underscore prefixes and suffixes, as they only make sense to avoid conflicts with Java reserved // words and they aren't needed in the model: while (text.startsWith("_")) { text = text.substring(1); } while (text.endsWith("_")) { text = text.substring(0, text.length() - 1); } // Once the name is clean it can be parsed: return NameParser.parseUsingCase(text); } }
private void analyzeModule(JavaClass javaClass, Consumer<Module> moduleSetter) { String javaName = javaClass.getPackageName(); Name name = NameParser.parseUsingSeparator(javaName, '.'); Module module = model.getModule(name); if (module == null) { module = new Module(); module.setModel(model); module.setName(name); model.addModule(module); } moduleSetter.accept(module); }
Name identifiedTypeName = NameParser.parseUsingCase("Identified"); identifiedType = model.getType(identifiedTypeName); if (identifiedType == null) { ); Name apiTypeName = NameParser.parseUsingCase("Api"); apiType = model.getType(apiTypeName); if (apiType == null) {
Object value = entry.getValue(); AnnotationParameter parameter = new AnnotationParameter(); parameter.setName(NameParser.parseUsingCase(key));
file = file.substring(index + 1); Name name = NameParser.parseUsingCase(file); if (prefix != null && !prefix.isEmpty()) { List<String> words = name.getWords();
public Model() { // Create the anonymous module: Module anonymousModule = new Module(); anonymousModule.setModel(this); modules.add(anonymousModule); // Add the builtin types: booleanType = new PrimitiveType(); booleanType.setName(NameParser.parseUsingCase("Boolean")); booleanType.setModule(anonymousModule); addType(booleanType); stringType = new PrimitiveType(); stringType.setName(NameParser.parseUsingCase("String")); stringType.setModule(anonymousModule); addType(stringType); integerType = new PrimitiveType(); integerType.setName(NameParser.parseUsingCase("Integer")); integerType.setModule(anonymousModule); addType(integerType); dateType = new PrimitiveType(); dateType.setName(NameParser.parseUsingCase("Date")); dateType.setModule(anonymousModule); addType(dateType); decimalType = new PrimitiveType(); decimalType.setName(NameParser.parseUsingCase("Decimal")); decimalType.setModule(anonymousModule); addType(decimalType); }
private void generateBuildersFactory(Model model) { Name name = NameParser.parseUsingCase("Builders"); javaBuffer = new JavaClassBuffer(); JavaClassName factoryName = new JavaClassName(); factoryName.setPackageName(javaPackages.getBuildersPackageName()); factoryName.setSimpleName(javaNames.getJavaClassStyleName(name)); javaBuffer.setClassName(factoryName); generateBuildersFactorySource(model); try { javaBuffer.write(outDir); } catch (IOException exception) { throw new RuntimeException("Can't write file for builder factory \"" + factoryName + "\"", exception); } }
/** * Adds the {@code GracePeriod} type to the model. */ private void addGracePeriodType(Model model) { // Create the type: StructType gracePeriodType = new StructType(); gracePeriodType.setName(NameParser.parseUsingCase("GracePeriod")); // Add the "expiry" attribute: Attribute expiryAttribute = new Attribute(); expiryAttribute.setName(NameParser.parseUsingCase("Expiry")); expiryAttribute.setType(model.getIntegerType()); expiryAttribute.setDeclaringType(gracePeriodType); gracePeriodType.addAttribute(expiryAttribute); // Add the type to the model: gracePeriodType.setModule(model.getModule(null)); model.addType(gracePeriodType); }
/** * Adds the {@code Fault} type to the model. */ private void addFaultType(Model model) { // Create the type: StructType faultType = new StructType(); faultType.setName(NameParser.parseUsingCase("Fault")); // Add the "reason" attribute: Attribute reasonAttribute = new Attribute(); reasonAttribute.setName(NameParser.parseUsingCase("Reason")); reasonAttribute.setType(model.getStringType()); reasonAttribute.setDeclaringType(faultType); faultType.addAttribute(reasonAttribute); // Add the "detail" attribute: Attribute detailAttribute = new Attribute(); detailAttribute.setName(NameParser.parseUsingCase("Detail")); detailAttribute.setType(model.getStringType()); detailAttribute.setDeclaringType(faultType); faultType.addAttribute(detailAttribute); // Add the type to the model: faultType.setModule(model.getModule(null)); model.addType(faultType); }
actionType.setName(NameParser.parseUsingCase("Action")); actionType.setBase(model.getType(NameParser.parseUsingCase("Identified"))); statusAttribute.setName(NameParser.parseUsingCase("Status")); statusAttribute.setType(model.getStringType()); statusAttribute.setDeclaringType(actionType); faultAttribute.setName(NameParser.parseUsingCase("Fault")); faultAttribute.setType(model.getType(NameParser.parseUsingCase("Fault"))); faultAttribute.setDeclaringType(actionType); actionType.addAttribute(faultAttribute); gracePeriodAttribute.setName(NameParser.parseUsingCase("GracePeriod")); gracePeriodAttribute.setType(model.getType(NameParser.parseUsingCase("GracePeriod"))); gracePeriodAttribute.setDeclaringType(actionType); actionType.addAttribute(gracePeriodAttribute); jobAttribute.setName(NameParser.parseUsingCase("Job")); jobAttribute.setType(model.getType(NameParser.parseUsingCase("Job"))); jobAttribute.setDeclaringType(actionType); actionType.addAttribute(jobAttribute);
private void analyzeDocletTag(DocletTag docTag, Concept concept) { // Calculate the name: Name name = NameParser.parseUsingCase(docTag.getName()); // Create the annotation if it doesn't exist in the concept yet: Annotation annotation = concept.getAnnotation(name); if (annotation == null) { annotation = new Annotation(); annotation.setName(name); concept.addAnnotation(annotation); } // Create the "value" parameter if it doesn't exist yet: String value = docTag.getValue(); if (value != null) { value = value.trim(); if (!value.isEmpty()) { AnnotationParameter parameter = annotation.getParameter(VALUE); if (parameter == null) { parameter = new AnnotationParameter(); parameter.setName(VALUE); annotation.addParameter(parameter); } parameter.addValue(docTag.getValue()); } } }