List of usage examples for com.google.common.base CaseFormat LOWER_UNDERSCORE
CaseFormat LOWER_UNDERSCORE
To view the source code for com.google.common.base CaseFormat LOWER_UNDERSCORE.
Click Source Link
From source file:dao.versions.postgres.PostgresVersionHistoryDagFactory.java
/** * Truncate the DAG to only have a certain number of levels, removing everything before that. * * TODO: refactor to move specific logic into those classes. * * @param dag the DAG to truncate//from w w w . j a v a2s. c om * @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 = 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.versionSuccessorFactory.deleteFromDestination(id, dag.getItemId()); predicates.clear(); predicates.add(new DbDataContainer("rich_version_id", GroundType.LONG, id)); this.dbClient.delete(predicates, "rich_version_tag"); predicates.clear(); predicates.add(new DbDataContainer("id", GroundType.LONG, id)); this.dbClient.delete(predicates, "version"); deleted.add(id); List<Long> parents = dag.getParent(id); parents.forEach(parentId -> { if (!deleted.contains(parentId)) { deleteQueue.add(parentId); } }); predicates.clear(); } deleteQueue.remove(0); } }
From source file:com.puppycrawl.tools.checkstyle.checks.javadoc.ExpectedParseTreeGenerator.java
public String walk(ParseTree t, String parentObjectName) { final String className = t.getClass().getSimpleName(); String id = null;/* w ww . java 2 s . co m*/ if (t instanceof TerminalNode) { final TerminalNodeImpl terminal = (TerminalNodeImpl) t; final int type = terminal.symbol.getType(); String tokenType = ""; if (type == -1) { tokenType = "EOF"; } else { tokenType = JavadocUtils.getTokenName(type); } String text = terminal.getText(); if ("\n".equals(text)) { text = "\\n"; } else if ("\t".equals(text)) { text = "\\t"; } else { text = text.replace("\"", "\\\""); } final int number = getVariableCounter(tokenType); id = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, tokenType.toLowerCase()) + number; System.out.println(" CommonToken " + id + " = new CommonToken(JavadocTokenTypes." + tokenType + ", \"" + text + "\");"); } else { int number = getVariableCounter(className); id = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, className) + number++; System.out.println( " " + className + " " + id + " = new " + className + "(" + parentObjectName + ", 0);"); final int n = t.getChildCount(); for (int i = 0; i < n; i++) { final String childId = walk(t.getChild(i), id); System.out.println(" " + id + ".addChild(" + childId + ");"); } } return id; }
From source file:com.facebook.buck.rules.ParamInfo.java
private String determinePythonName(String javaName, @Nullable Hint hint) { if (hint != null) { return hint.name(); }/*from w w w .j a va2s. c om*/ return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, javaName); }
From source file:datamine.storage.idl.generator.java.InterfaceGenerator.java
public static String getInterfaceName(String tableName) { return new StringBuilder().append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, tableName)) .append("Interface").toString(); }
From source file:com.google.template.soy.jssrc.internal.JavaScriptValueFactoryImpl.java
private Expression referenceModuleExport(String moduleName, String export) { Expression module;/*from w ww . j a v a2 s.com*/ if (jsSrcOptions.shouldGenerateGoogModules()) { String alias = "$" + CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, moduleName.replace('.', '_')); module = GoogRequire.createWithAlias(moduleName, alias).reference(); } else { module = GoogRequire.create(moduleName).googModuleGet(); } return chainedDotAccess(module, export); }
From source file:com.google.api.codegen.transformer.java.JavaGapicSamplesTransformer.java
private StaticLangSampleClassView generateSampleClass(InterfaceContext context, StaticLangApiMethodView method, MethodSampleView methodSample, String callingForm, String valueSet) { SurfaceNamer namer = context.getNamer(); StaticLangSampleClassView.Builder sampleClass = StaticLangSampleClassView.newBuilder(); sampleClass.name(namer.getApiSampleClassName( CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, method.name()), callingForm, valueSet)) .libraryMethod(method.toBuilder().samples(Arrays.asList(methodSample)).build()); return sampleClass.build(); }
From source file:datamine.storage.idl.generator.java.InterfaceGenerator.java
public static String getDerivedInterfaceName(String tableName) { return new StringBuilder().append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, tableName)) .append("DerivedValueInterface").toString(); }
From source file:org.intellij.erlang.refactor.introduce.ErlangExtractFunctionHandler.java
private static void perform(final Editor editor, List<ErlangExpression> selection) { final ErlangExpression first = ContainerUtil.getFirstItem(selection); final ErlangFunction function = PsiTreeUtil.getParentOfType(first, ErlangFunction.class); final ErlangExpression last = selection.get(selection.size() - 1); assert first != null; assert function != null; assert last != null; Pair<List<ErlangNamedElement>, List<ErlangNamedElement>> analyze = analyze(selection); final Project project = first.getProject(); List<ErlangNamedElement> inParams = analyze.first; List<ErlangNamedElement> outParams = analyze.second; String shorten = ErlangRefactoringUtil.shorten(last, "extracted"); String name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, shorten); ErlangExtractFunctionDialog dialog = new ErlangExtractFunctionDialog(project, name, inParams); if (ApplicationManager.getApplication().isUnitTestMode() || dialog.showAndGet()) { final String functionName = dialog.getFunctionName(); final String bindings = bindings(outParams); final String bindingsEx = StringUtil.isEmpty(bindings) ? bindings : ",\n" + bindings; final String bindingsS = StringUtil.isEmpty(bindings) ? bindings : bindings + " = "; final String signature = generateSignature(functionName, inParams); final String functionText = signature + " ->\n" + StringUtil.join(selection, new Function<ErlangExpression, String>() { @Override/* www .ja v a2s.co m*/ public String fun(ErlangExpression erlangExpression) { return erlangExpression.getText(); } }, ",\n") + bindingsEx + "."; try { final PsiFile file = first.getContainingFile(); new WriteCommandAction(editor.getProject(), "Extract function", file) { @Override protected void run(Result result) throws Throwable { ErlangFunction newFunction = ErlangElementFactory.createFunctionFromText(project, functionText); PsiElement functionParent = function.getParent(); PsiElement added = functionParent.addAfter(newFunction, function); functionParent.addBefore(newLine(), added); functionParent.addAfter(newLine(), function); PsiElement parent = first.getParent(); parent.addBefore( ErlangElementFactory.createExpressionFromText(getProject(), bindingsS + signature), first); parent.deleteChildRange(first, last); } private PsiElement newLine() { return ErlangElementFactory.createLeafFromText(project, "\n"); } }.execute(); } catch (Throwable throwable) { LOGGER.warn(throwable); } } }
From source file:com.facebook.buck.rules.coercer.ParamInfo.java
public String getPythonName() { return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, getName()); }
From source file:org.dbunitng.beans.BeanMetaData.java
/** * ?/*from ww w . j a v a2 s. c o m*/ * * @param name * ?? * @param getter * Getter */ protected void addPropertyWithGetter(String name, Method getter) { String lowerName = name.toLowerCase(); BeanProperty property = propertyMap.get(lowerName); Class<?> type = getter.getReturnType(); if (property == null) { property = new BeanProperty(name, type, null, getter, null); propertyMap.put(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name), property); } else { property.setGetter(getter); } }