private String entityName(String filename) { String name = Paths.getFileNameWithoutExtension(filename); return namingStrategy.entityName(name); }
protected String resolveDbType(Resource r) { String filename = r.getFilename(); if(null != filename){ String filenameWithoutExt = Paths.getFileNameWithoutExtension(filename); int lastIndexOfUnderscore = filenameWithoutExt.lastIndexOf('_'); if(lastIndexOfUnderscore > 0){ String dbType = filenameWithoutExt.substring(lastIndexOfUnderscore + 1); if(DbPlatforms.tryGet(dbType) != null){ return dbType; } } } return null; } }
filename = Paths.getFileNameWithoutExtension(filename);
private void addPropertySource(ConfigurableEnvironment env, Resource resource, PropertySourceLoader loader, String profile, boolean first) throws IOException { if (null != profile) { String filenameOnly = Paths.getFileNameWithoutExtension(resource.getFilename()); int index = filenameOnly.lastIndexOf('-'); if (index > 0) {
String filename = Paths.getFileNameWithoutExtension(Paths.getFileName(relativePath)); String entityName = Strings.substringBefore(relativePath, "/"); String localeName = Locales.extractFromFilename(filename);
public MetaModel read(Resource file) { String content = file.getContent().trim(); if (content.length() == 0) { return null; } String name = Strings.upperFirst(Paths.getFileNameWithoutExtension(file.getFilename())); JsonObject o = JSON.parse(file.getContent()).asJsonObject(); if(o.asMap().isEmpty()) { return null; } MetaModel model = JSON.convert(o.asMap(), MetaModel.class); if (!Strings.isEmpty(model.getClassName())) { Class<?> c = Classes.tryForName(model.getClassName()); if (null == c) { throw new IllegalStateException("Model class '" + model.getClassName() + "' not found!"); } MType type = MTypes.getMType(c); if (!type.isComplexType()) { throw new IllegalStateException("The model class '" + model.getClassName() + "' must be complex type!"); } MetaUtils.tryCopyModel(type.asComplexType(), model); } MApiModelBuilder am = nonValidateSwaggerReader.readModel(name, o.asMap(), new SwaggerTypeEx()); MetaUtils.tryCopyModel(am, model); validator.validate("Model(" + model.getName() + ")", model); return model; }
String fileNameWithoutExt = Paths.getFileNameWithoutExtension(file.getFilename()); try { Resource doc = file.createRelative(fileNameWithoutExt + ".md");
protected MetaParameterSet readParamSet(Resource resource) { OperationParser parser = new OperationParser(resource.getContent()).parseComment(); if(parser.isIgnore()) { return null; } String name = Strings.upperFirst(Paths.getFileNameWithoutExtension(resource.getFilename())); MetaParameterSet ps = new MetaParameterSet(); withSource(ps, resource); ps.setName(name); ps.setClassNames(parser.getMappingClassNames()); for(String className : ps.getClassNames()) { Class<?> cls = Classes.tryForName(className); if (null == cls) { throw new IllegalStateException("Invalid mapping class name '" + className + "'"); } } MetaOperation op = parser.getOperation(); if(null != op) { ps.setItems(op.getParameters()); } return ps; }
public void readResponseSet(MetaApi api, Resource resource) { String name = Strings.upperFirst(Paths.getFileNameWithoutExtension(resource.getFilename())); MetaResponseSet rs = new MetaResponseSet(); withSource(rs, resource); rs.setName(name); OperationParser parser = new OperationParser(resource.getContent()).parseComment(); if(parser.isIgnore()) { return; } MetaOperation op = parser.getOperation(); if(null != op) { rs.setItems(op.getResponses()); } api.addResponseSet(rs); }
public void read(MetaApi api, Resource resource) { String content = resource.getContent(); if(Strings.isEmpty(content)) { return; } String filenameWithoutExt = Paths.getFileNameWithoutExtension(resource.getFilename()); MetaOptionSet os = JSON.decode(content, MetaOptionSet.class); if(Strings.isEmpty(os.getName())) { os.setName(Strings.upperFirst(filenameWithoutExt)); } withSource(os, resource); validator.validate(os); MetaOptionSet exists = api.getOptionSet(os.getName()); if(exists != null) { if(!exists.isReadFromMetaInf()) { log.error("Option Set {} exist, skip file:{}",os.getName(),os.getSource()); return; }else { log.info("Override the exists option set '{}' by {}", os.getName(), os.getSource()); } } api.addOptionSet(os); }