List of usage examples for com.google.common.base CaseFormat LOWER_CAMEL
CaseFormat LOWER_CAMEL
To view the source code for com.google.common.base CaseFormat LOWER_CAMEL.
Click Source Link
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//w w w. j av a2 s . c o 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:com.google.api.codegen.transformer.php.PhpGapicSamplesTransformer.java
private List<ViewModel> generateSamples(GapicInterfaceContext context) { ImmutableList.Builder<ViewModel> viewModels = new ImmutableList.Builder<>(); SurfaceNamer namer = context.getNamer(); SampleFileRegistry generatedSamples = new SampleFileRegistry(); List<OptionalArrayMethodView> allmethods = methodGenerator.generateApiMethods(context); DynamicLangSampleView.Builder sampleClassBuilder = DynamicLangSampleView.newBuilder(); for (OptionalArrayMethodView method : allmethods) { String subPath = pathMapper.getSamplesOutputPath(context.getInterfaceModel().getFullName(), context.getProductConfig(), method.name()); for (MethodSampleView methodSample : method.samples()) { String callingForm = methodSample.callingForm().toLowerCamel(); String valueSet = methodSample.valueSet().id(); String className = namer.getApiSampleClassName( CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, method.name()), callingForm, valueSet);/* w w w . jav a 2s .co m*/ String sampleOutputPath = subPath + File.separator + namer.getApiSampleFileName(className); String autoloadPath = "__DIR__ . '" + Strings.repeat("/..", (int) sampleOutputPath.chars().filter(c -> c == File.separatorChar).count()) + "/vendor/autoload.php'"; generatedSamples.addFile(sampleOutputPath, method.name(), callingForm, valueSet, methodSample.regionTag()); viewModels.add(sampleClassBuilder.templateFileName(STANDALONE_SAMPLE_TEMPLATE_FILENAME) .fileHeader(fileHeaderTransformer.generateFileHeader(context)).outputPath(sampleOutputPath) .className(className) .libraryMethod(method.toBuilder().samples(Collections.singletonList(methodSample)).build()) .gapicPackageName(namer.getGapicPackageName(packageConfig.packageName())) .extraInfo(PhpSampleExtraInfo.newBuilder().autoloadPath(autoloadPath) .hasDefaultServiceScopes(context.getInterfaceConfig().hasDefaultServiceScopes()) .hasDefaultServiceAddress(context.getInterfaceConfig().hasDefaultServiceAddress()) .build()) .build()); } } return viewModels.build(); }
From source file:org.dbunitng.beans.BeanMetaData.java
/** * ?//w w w.j a v a 2 s. c o m * * @param name * ?? * @param setter * Setter */ protected void addPropertyWithSetter(String name, Method setter) { String lowerName = name.toLowerCase(); BeanProperty property = propertyMap.get(lowerName); Class<?> type = setter.getParameterTypes()[0]; if (property == null) { property = new BeanProperty(name, type, null, null, setter); propertyMap.put(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name), property); } else { property.setSetter(setter); } }
From source file:com.google.api.tools.framework.aspects.documentation.model.DocumentationUtil.java
/** * Given a string, searches for unqualified references to message fields and to method names and * converts them from RPC-style to REST-style. Field names are converted from lower_underscore to * lowerCamel. Method names are converted from VerbCollection-style to collection.verb style. * No work is done for qualified references; in such a case, an explicit markdown link with the * proper display text should be used in the proto comment (e.g., * [foo_bar][Path.To.Message.foo_bar], which will be converted to * [fooBar][Path.To.Message.foo_bar] by rpcToRest). *//*from w w w .j a v a 2 s. c om*/ public static String rpcToRest(SymbolTable symbolTable, String description) { StringBuffer sb = new StringBuffer(); Matcher m = WORD.matcher(description); while (m.find()) { // Convert field names if (symbolTable.containsFieldName(m.group(0))) { m.appendReplacement(sb, CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, m.group(0))); // Convert method names } else if (symbolTable.lookupMethodSimpleName(m.group(0)) != null) { RestMethod restMethod = RestMethod .getPrimaryRestMethod(symbolTable.lookupMethodSimpleName(m.group(0)).get(0)); if (restMethod == null) { m.appendReplacement(sb, m.group(0)); } else { m.appendReplacement(sb, restMethod.getSimpleRestCollectionName() + "." + restMethod.getRestMethodName()); } } else { m.appendReplacement(sb, m.group(0)); } } m.appendTail(sb); return sb.toString(); }
From source file:com.google.template.soy.parsepasses.contextautoesc.EscapingMode.java
EscapingMode(boolean escapesQuotes, @Nullable ContentKind contentKind, boolean internalOnly) { this.directiveName = "|" + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); this.isHtmlEmbeddable = escapesQuotes; this.contentKind = contentKind; this.isInternalOnly = internalOnly; }
From source file:fr.zcraft.zlib.components.rawtext.RawText.java
static public String getI18nKey(Achievement achievement) { String key = ACHIEVEMENTS_NAMES.get(achievement); if (key == null) { key = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, achievement.name()); ACHIEVEMENTS_NAMES.put(achievement, key); }//from w ww . j a va 2 s. c o m return key; }
From source file:io.soliton.protobuf.json.Messages.java
private static Object parseField(Descriptors.FieldDescriptor field, JsonElement value, Message.Builder enclosingBuilder) throws Exception { switch (field.getType()) { case DOUBLE:/*from w w w . ja va 2s. c o m*/ if (!value.isJsonPrimitive()) { // fail; } return value.getAsDouble(); case FLOAT: if (!value.isJsonPrimitive()) { // fail; } return value.getAsFloat(); case INT64: case UINT64: case FIXED64: case SINT64: case SFIXED64: if (!value.isJsonPrimitive()) { // fail } return value.getAsLong(); case INT32: case UINT32: case FIXED32: case SINT32: case SFIXED32: if (!value.isJsonPrimitive()) { // fail } return value.getAsInt(); case BOOL: if (!value.isJsonPrimitive()) { // fail } return value.getAsBoolean(); case STRING: if (!value.isJsonPrimitive()) { // fail } return value.getAsString(); case GROUP: case MESSAGE: if (!value.isJsonObject()) { // fail } return fromJson(enclosingBuilder.newBuilderForField(field), value.getAsJsonObject()); case BYTES: if (!value.isJsonPrimitive()) { // fail } return ByteString.copyFrom(BaseEncoding.base64().decode(value.getAsString())); case ENUM: if (!value.isJsonPrimitive()) { // fail } String protoEnumValue = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, value.getAsString()); return field.getEnumType().findValueByName(protoEnumValue); } return null; }
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 a2s . c om return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, method.getName()); }
From source file:com.contentful.generator.Generator.java
JavaFile generateModel(String pkg, CMAContentType contentType, String className) throws Exception { TypeSpec.Builder builder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC) .superclass(ClassName.get("com.contentful.vault", "Resource")) .addAnnotation(annotateModel(contentType)); for (CMAField field : contentType.getFields()) { if (field.isDisabled() || field.isOmitted()) { continue; }//www. jav a 2 s.co m String fieldName = normalize(field.getId(), CaseFormat.LOWER_CAMEL); FieldSpec fieldSpec = createFieldSpec(field, pkg, fieldName, contentType.getResourceId()); builder.addField(fieldSpec).addMethod(fieldGetter(fieldSpec)); } return JavaFile.builder(pkg, builder.build()).skipJavaLangImports(true).build(); }
From source file:ratpack.server.internal.DefaultServerConfigBuilder.java
@Override public ServerConfig.Builder env(String prefix) { Map<String, String> filteredEnvVars = serverEnvironment.getenv().entrySet().stream() .filter(entry -> entry.getKey().startsWith(prefix)) .collect(Collectors.toMap(entry -> CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entry.getKey().replace(prefix, "")), Map.Entry::getValue)); return props(filteredEnvVars); }