List of usage examples for com.google.common.base CaseFormat UPPER_CAMEL
CaseFormat UPPER_CAMEL
To view the source code for com.google.common.base CaseFormat UPPER_CAMEL.
Click Source Link
From source file:dao.versions.neo4j.Neo4jVersionHistoryDagFactory.java
/** * Truncate the DAG to only have a certain number of levels, removing everything before that. * * @param dag the DAG to truncate//www . ja v a2 s . com * @param numLevels the number of levels to keep */ @Override public void truncate(VersionHistoryDag dag, int numLevels, Class<? extends Item> itemType) throws GroundException { int keptLevels = 1; List<Long> lastLevel = new ArrayList<>(); List<Long> previousLevel = dag.getLeaves(); while (keptLevels <= numLevels) { List<Long> currentLevel = new ArrayList<>(); previousLevel.forEach(id -> currentLevel.addAll(dag.getParent(id))); lastLevel = previousLevel; previousLevel = currentLevel; keptLevels++; } List<Long> deleteQueue = previousLevel; Set<Long> deleted = new HashSet<>(); for (long id : lastLevel) { this.addEdge(dag, dag.getItemId(), id, dag.getItemId()); } List<DbDataContainer> predicates = new ArrayList<>(); while (deleteQueue.size() > 0) { long id = deleteQueue.get(0); String[] splits = itemType.getName().split("\\."); String className = splits[splits.length - 1]; String tableNamePrefix = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, className); if (itemType.equals(Structure.class)) { predicates.add(new DbDataContainer("structure_version_id", GroundType.LONG, id)); this.dbClient.deleteNode(predicates, "structure_version_attribute"); predicates.clear(); } if (itemType.getName().toLowerCase().contains("graph")) { predicates.add(new DbDataContainer(tableNamePrefix + "_version_id", GroundType.LONG, id)); this.dbClient.deleteNode(predicates, tableNamePrefix + "_version_edge"); predicates.clear(); } predicates.add(new DbDataContainer("id", GroundType.LONG, id)); this.dbClient.deleteNode(predicates, className + "Version"); deleteQueue.remove(0); List<Long> parents = dag.getParent(id); predicates.clear(); predicates.add(new DbDataContainer("rich_version_id", GroundType.LONG, id)); this.dbClient.deleteNode(predicates, "RichVersionTag"); deleted.add(id); parents.forEach(parentId -> { if (!deleted.contains(parentId)) { deleteQueue.add(parentId); } }); } }
From source file:com.ning.billing.recurly.model.push.Notification.java
/** * Detect notification type based on the xml root name. * * @param payload//from w ww . ja v a 2 s . com * @return notification type or null if root name is not found or if there * is no type corresponding to the root name */ public static Type detect(final String payload) { final Matcher m = ROOT_NAME.matcher(payload); if (m.find() && m.groupCount() >= 1) { final String root = m.group(1); try { return Type.valueOf(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, root)); } catch (IllegalArgumentException e) { log.warn("Enable to detect notification type, no type for {}", root); return null; } } log.warn("Enable to detect notification type"); return null; }
From source file:com.github.jcustenborder.kafka.connect.utils.templates.model.Configurable.java
private String getLowerCamelHyphenSimpleName() { return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, this.cls.getSimpleName()); }
From source file:org.atteo.moonshine.ConfigurationReader.java
/** * Generate auto-config.xml./* ww w .j a v a 2 s.c o m*/ */ public void generateAutoConfiguration() throws IncorrectConfigurationException, IOException { Iterable<Class<? extends Service>> services = ClassFilter.only().topLevel() .withoutModifiers(Modifier.ABSTRACT).satisfying(TopLevelService.class::isAssignableFrom) .satisfying((Class<?> type) -> !containsRequiredFieldWithoutDefault(type)) .satisfying((Class<?> type) -> { ServiceConfiguration annotation = type.getAnnotation(ServiceConfiguration.class); return annotation == null || annotation.auto(); }).from(ClassIndex.getSubclasses(Service.class)); StringBuilder builder = new StringBuilder(); builder.append("<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + " xsi:noNamespaceSchemaLocation=\"" + SCHEMA_FILE_NAME + "\">\n"); for (Class<? extends Service> service : services) { ServiceConfiguration annotation = service.getAnnotation(ServiceConfiguration.class); String name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, service.getSimpleName()); XmlRootElement xmlRootElement = service.getAnnotation(XmlRootElement.class); if (xmlRootElement != null && !"##default".equals(xmlRootElement.name())) { name = xmlRootElement.name(); } builder.append("\t<").append(name); builder.append(" combine.self='").append(CombineSelf.OVERRIDABLE_BY_TAG.name()); if (annotation == null || annotation.autoConfiguration().isEmpty()) { builder.append("'/>\n"); } else { builder.append("'>\n"); builder.append(annotation.autoConfiguration()); builder.append("\n</").append(name).append(">\n"); } } builder.append("</config>\n"); Path autoConfigPath = fileAccessor.getWritableConfigFile(AUTO_CONFIG_FILE_NAME); try (Writer writer = Files.newBufferedWriter(autoConfigPath, Charsets.UTF_8)) { writer.write(builder.toString()); } }
From source file:com.github.jcustenborder.kafka.connect.utils.templates.model.Configurable.java
private String getLowerCamelUnderscoreSimpleName() { return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, this.cls.getSimpleName()); }
From source file:co.leugim.jade4ninja.template.JadeModelParamsBuilder.java
protected Map<String, Object> getRenderableResult() { Object object = result.getRenderable(); Map<String, Object> model; if (object == null) { model = Maps.newHashMap();//from w w w . ja va 2s .c om } else if (object instanceof Map) { @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) object; model = map; } else { model = Maps.newHashMap(); String realClassNameLowerCamelCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, object.getClass().getSimpleName()); model.put(realClassNameLowerCamelCase, object); } return model; }
From source file:org.syncany.plugins.transfer.TransferPluginUtil.java
private static String getPluginPackageName(Class<?> clazz) { Matcher matcher = PLUGIN_PACKAGE_NAME_PATTERN.matcher(clazz.getPackage().getName()); if (matcher.matches()) { String pluginPackageName = matcher.group(1); return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, pluginPackageName); }//www. j av a 2 s . com return null; }
From source file:org.jooby.assets.V8Context.java
private static String classname(final Callback callback) { String logname = callback.getClass().getSimpleName(); logname = logname.substring(0, logname.indexOf("$")); return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, logname); }
From source file:com.tactfactory.harmony.generator.BundleGenerator.java
/** * Generate command file for empty bundle. * @param bundleOwnerName Owner name/*from w w w. j a v a2 s . c om*/ * @param bundleName Bundle name * @param bundleNameSpace Bundle namespace */ private void generateCommand(final String bundleOwnerName, final String bundleName, final String bundleNameSpace) { final String tplPath = this.getAdapter().getCommandBundleTemplatePath() + "/TemplateCommand.java"; final String genPath = this.getAdapter().getCommandBundlePath(bundleOwnerName, bundleNameSpace, bundleName) + "/" + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, bundleName) + "Command.java"; this.makeSource(tplPath, genPath, false); }
From source file:dao.versions.cassandra.CassandraVersionHistoryDagFactory.java
/** * Truncate the DAG to only have a certain number of levels, removing everything before that. * * @param dag the DAG to truncate/*www . ja v a2s . com*/ * @param numLevels the number of levels to keep */ @Override public void truncate(VersionHistoryDag dag, int numLevels, Class<? extends Item> itemType) throws GroundException { int keptLevels = 1; List<Long> previousLevel = dag.getLeaves(); List<Long> lastLevel = new ArrayList<>(); while (keptLevels <= numLevels) { List<Long> currentLevel = new ArrayList<>(); previousLevel.forEach(id -> currentLevel.addAll(dag.getParent(id))); lastLevel = previousLevel; previousLevel = currentLevel; keptLevels++; } List<Long> deleteQueue = new ArrayList<>(new HashSet<>(previousLevel)); Set<Long> deleted = new HashSet<>(); List<DbDataContainer> predicates = new ArrayList<>(); for (long id : lastLevel) { this.versionSuccessorFactory.deleteFromDestination(id, dag.getItemId()); this.addEdge(dag, 0, id, dag.getItemId()); } while (deleteQueue.size() > 0) { long id = deleteQueue.get(0); if (id != 0) { String[] splits = itemType.getName().split("\\."); String tableNamePrefix = splits[splits.length - 1]; tableNamePrefix = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, tableNamePrefix); if (itemType.equals(Structure.class)) { predicates.add(new DbDataContainer("structure_version_id", GroundType.LONG, id)); this.dbClient.delete(predicates, "structure_version_attribute"); predicates.clear(); } if (itemType.getName().toLowerCase().contains("graph")) { predicates.add(new DbDataContainer(tableNamePrefix + "_version_id", GroundType.LONG, id)); this.dbClient.delete(predicates, tableNamePrefix + "_version_edge"); predicates.clear(); } predicates.add(new DbDataContainer("id", GroundType.LONG, id)); this.dbClient.delete(predicates, tableNamePrefix + "_version"); if (!itemType.equals(Structure.class)) { this.dbClient.delete(predicates, "rich_version"); } this.dbClient.delete(predicates, "version"); predicates.clear(); predicates.add(new DbDataContainer("rich_version_id", GroundType.LONG, id)); this.dbClient.delete(predicates, "rich_version_tag"); this.versionSuccessorFactory.deleteFromDestination(id, dag.getItemId()); deleted.add(id); List<Long> parents = dag.getParent(id); parents.forEach(parentId -> { if (!deleted.contains(parentId)) { deleteQueue.add(parentId); } }); predicates.clear(); } deleteQueue.remove(0); } }