List of usage examples for com.google.common.base CaseFormat LOWER_HYPHEN
CaseFormat LOWER_HYPHEN
To view the source code for com.google.common.base CaseFormat LOWER_HYPHEN.
Click Source Link
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.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:integration.BaseRestTestHelper.java
/** * Same as @{link #jsonResource} but guesses the file name from the caller's method name. Be careful when refactoring. * @return the bytes in that file//from ww w . ja v a 2 s.co m */ protected String jsonResourceForMethod() { final StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); final String testMethodName = stackTraceElements[2].getMethodName(); final String filename = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, testMethodName); return jsonResource(filename + ".json"); }
From source file:brooklyn.entity.container.docker.DockerContainerImpl.java
@Override public void init() { LOG.info("Starting Docker container id {}", getId()); super.init(); AtomicInteger counter = config().get(DOCKER_INFRASTRUCTURE) .getAttribute(DockerInfrastructure.DOCKER_CONTAINER_COUNTER); String dockerContainerName = config().get(DOCKER_CONTAINER_NAME); String dockerContainerNameFormat = config().get(DOCKER_CONTAINER_NAME_FORMAT); if (Strings.isBlank(dockerContainerName) && Strings.isNonBlank(dockerContainerNameFormat)) { dockerContainerName = format(dockerContainerNameFormat, getId(), counter.incrementAndGet()); }//ww w.j av a2 s.co m if (Strings.isNonBlank(dockerContainerName)) { dockerContainerName = CharMatcher.BREAKING_WHITESPACE.trimAndCollapseFrom(dockerContainerName, '-'); setDisplayName(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, dockerContainerName)); setAttribute(DOCKER_CONTAINER_NAME, dockerContainerName); } ConfigToAttributes.apply(this, DOCKER_INFRASTRUCTURE); ConfigToAttributes.apply(this, DOCKER_HOST); ConfigToAttributes.apply(this, ENTITY); }
From source file:org.mule.tools.module.loader.Devkit42Loader.java
protected final String extractName(final Object annotation, final Method method) { final String annotationName = extractAnnotationName(annotation); if (!"".equals(annotationName)) { return annotationName; }/* w w w . j a v a 2 s . co m*/ return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, method.getName()); }
From source file:com.bjond.utilities.MiscUtils.java
/** * <code>fromCamelCaseToLowerHyphen</code> method will convert * * CamelCase to camel-case (lower hyphen). Works only for ASCII equivalents which is * good enough for keywords and internal strings etcetera * * @param in a <code>String</code> value * @return a <code>String</code> value *//*w ww. j av a2 s . com*/ public static String fromCamelCaseToLowerHyphen(@NotNull(message = "in must not be null.") final String in) { return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, in); }
From source file:org.knight.examples.guava.strings.StringsExamples.java
private void caseFormat() { String s1 = "CamelNamingRule"; //return camel-naming-rule log("convert to LOWER_HYPHEN: " + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, s1)); String s2 = "HYPHEN-Naming-Rule"; //use Converter interface to convert hyphen style to underscore style //the source format does not conform to the assumed format //so the behavior of this method is undefined //this Converter.convert() actually calls CaseFormat.to() method in the last step log("convert to LOWER_UNDERSCORE: " + CaseFormat.LOWER_HYPHEN.converterTo(CaseFormat.LOWER_UNDERSCORE).convert(s2)); }
From source file:cfa.vo.interop.SAMPProxy.java
private static String objectName(Method method) { String name = method.getName().replaceFirst("^get|^set|^add", ""); name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name); return name;/*from ww w .j a v a 2 s .c o m*/ }
From source file:org.ballerinalang.composer.tools.ModelGenerator.java
public static JsonObject getContext() { // Set alias for the classes alias.put("ImportNode", "ImportPackageNode"); alias.put("ArrayLiteralExprNode", "ArrayLiteralNode"); alias.put("BinaryExprNode", "BinaryExpressionNode"); alias.put("BracedTupleExprNode", "BracedOrTupleExpression"); alias.put("TypeInitExprNode", "TypeInitNode"); alias.put("FieldBasedAccessExprNode", "FieldBasedAccessNode"); alias.put("IndexBasedAccessExprNode", "IndexBasedAccessNode"); alias.put("IntRangeExprNode", "IntRangeExpression"); alias.put("LambdaNode", "LambdaFunctionNode"); alias.put("SimpleVariableRefNode", "SimpleVariableReferenceNode"); alias.put("TernaryExprNode", "TernaryExpressionNode"); alias.put("AwaitExprNode", "AwaitExpressionNode"); alias.put("TypeCastExprNode", "TypeCastNode"); alias.put("TypeConversionExprNode", "TypeConversionNode"); alias.put("UnaryExprNode", "UnaryExpressionNode"); alias.put("RestArgsExprNode", "RestArgsNode"); alias.put("NamedArgsExprNode", "NamedArgNode"); alias.put("MatchExpressionPatternClauseNode", "MatchExpressionNode"); alias.put("MatchPatternClauseNode", "MatchStatementPatternNode"); alias.put("TryNode", "TryCatchFinallyNode"); alias.put("VariableDefNode", "VariableDefinitionNode"); alias.put("UnionTypeNodeNode", "UnionTypeNode"); alias.put("TupleTypeNodeNode", "TupleTypeNode"); alias.put("EndpointTypeNode", "UserDefinedTypeNode"); alias.put("StreamingQueryNode", "StreamingQueryStatementNode"); alias.put("WithinNode", "WithinClause"); alias.put("PatternClauseNode", "PatternClause"); alias.put("ElvisExprNode", "ElvisExpressionNode"); alias.put("CheckExprNode", "CheckedExpressionNode"); alias.put("RecordLiteralExprNode", "RecordLiteralNode"); alias.put("TypeDefinitionNode", "TypeDefinition"); alias.put("EnumeratorNode", ""); alias.put("RecordLiteralKeyValueNode", ""); alias.put("TableNode", ""); alias.put("XmlnsNode", ""); alias.put("IsAssignableExprNode", ""); alias.put("XmlQnameNode", ""); alias.put("XmlAttributeNode", ""); alias.put("XmlAttributeAccessExprNode", ""); alias.put("XmlQuotedStringNode", ""); alias.put("XmlElementLiteralNode", ""); alias.put("XmlTextLiteralNode", ""); alias.put("XmlCommentLiteralNode", ""); alias.put("XmlPiLiteralNode", ""); alias.put("XmlSequenceLiteralNode", ""); alias.put("TableQueryExpressionNode", ""); alias.put("NextNode", ""); alias.put("TransformNode", ""); alias.put("StreamNode", ""); alias.put("FiniteTypeNodeNode", ""); alias.put("BuiltInRefTypeNode", ""); alias.put("StreamingInputNode", ""); alias.put("JoinStreamingInputNode", ""); alias.put("TableQueryNode", ""); alias.put("SetAssignmentClauseNode", ""); alias.put("SetNode", ""); alias.put("QueryNode", ""); alias.put("StreamingQueryDeclarationNode", ""); List<Class<?>> list = ModelGenerator.find("org.ballerinalang.model.tree"); NodeKind[] nodeKinds = NodeKind.class.getEnumConstants(); JsonObject nodes = new JsonObject(); for (NodeKind node : nodeKinds) { String nodeKind = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, node.toString()); String nodeClassName = nodeKind + "Node"; try {/*w ww .j a va2s .c o m*/ String actualClassName = (alias.get(nodeClassName) != null) ? alias.get(nodeClassName) : nodeClassName; Class<?> clazz = list.stream() .filter(nodeClass -> nodeClass.getSimpleName().equals(actualClassName)).findFirst().get(); JsonObject nodeObj = new JsonObject(); nodeObj.addProperty("kind", nodeKind); nodeObj.addProperty("name", nodeClassName); nodeObj.addProperty("fileName", CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, nodeClassName)); JsonArray attr = new JsonArray(); JsonArray bools = new JsonArray(); JsonArray imports = new JsonArray(); List<String> parents = Arrays.asList(clazz.getInterfaces()).stream() .map(parent -> parent.getSimpleName()).collect(Collectors.toList()); // tag object with supper type if (parents.contains("StatementNode")) { nodeObj.addProperty("isStatement", true); JsonObject imp = new JsonObject(); imp.addProperty("returnType", "StatementNode"); imp.addProperty("returnTypeFile", "statement-node"); imports.add(imp); } else { nodeObj.addProperty("isStatement", false); } if (parents.contains("ExpressionNode")) { nodeObj.addProperty("isExpression", true); JsonObject imp = new JsonObject(); imp.addProperty("returnType", "ExpressionNode"); imp.addProperty("returnTypeFile", "expression-node"); imports.add(imp); } else { nodeObj.addProperty("isExpression", false); } if (!parents.contains("StatementNode") && !parents.contains("ExpressionNode")) { JsonObject imp = new JsonObject(); imp.addProperty("returnType", "Node"); imp.addProperty("returnTypeFile", "node"); imports.add(imp); } Method[] methods = clazz.getMethods(); for (Method m : methods) { String methodName = m.getName(); if ("getKind".equals(methodName) || "getWS".equals(methodName) || "getPosition".equals(methodName)) { continue; } if (methodName.startsWith("get")) { JsonObject attribute = new JsonObject(); JsonObject imp = new JsonObject(); attribute.addProperty("property", toJsonName(m.getName(), 3)); attribute.addProperty("methodSuffix", m.getName().substring(3)); attribute.addProperty("list", List.class.isAssignableFrom(m.getReturnType())); attribute.addProperty("isNode", Node.class.isAssignableFrom(m.getReturnType())); if (Node.class.isAssignableFrom(m.getReturnType())) { String returnClass = m.getReturnType().getSimpleName(); if (alias.containsValue(m.getReturnType().getSimpleName())) { returnClass = getKindForAliasClass(m.getReturnType().getSimpleName()); } imp.addProperty("returnType", returnClass); attribute.addProperty("returnType", returnClass); imp.addProperty("returnTypeFile", CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, returnClass)); if (!imports.contains(imp)) { imports.add(imp); } } attr.add(attribute); } if (methodName.startsWith("is")) { JsonObject attribute = new JsonObject(); JsonObject imp = new JsonObject(); attribute.addProperty("property", toJsonName(m.getName(), 2)); attribute.addProperty("methodSuffix", m.getName().substring(2)); attribute.addProperty("list", List.class.isAssignableFrom(m.getReturnType())); attribute.addProperty("isNode", Node.class.isAssignableFrom(m.getReturnType())); if (Node.class.isAssignableFrom(m.getReturnType())) { String returnClass = m.getReturnType().getSimpleName(); if (alias.containsValue(m.getReturnType().getSimpleName())) { returnClass = getKindForAliasClass(m.getReturnType().getSimpleName()); } imp.addProperty("returnType", returnClass); attribute.addProperty("returnType", returnClass); imp.addProperty("returnTypeFile", CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, returnClass)); if (!imports.contains(imp)) { imports.add(imp); } } bools.add(attribute); } } nodeObj.add("attributes", attr); nodeObj.add("bools", bools); nodeObj.add("imports", imports); nodes.add(nodeClassName, nodeObj); } catch (NoSuchElementException e) { out.println("alias.put(\"" + nodeClassName + "\", \"\");"); } } out.println(nodes); return nodes; }
From source file:com.axelor.common.Inflector.java
/** * Convert the give word to dasherized form. * //from www. ja va 2s. co m * <pre> * inflection.tableize("address_books"); // "address-book" * inflection.tableize("AddressBook"); // "address-book" * </pre> * * @param word * the string to convert * @return converted string */ public String dasherize(String word) { return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, underscore(word)); }