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:io.soliton.protobuf.json.Messages.java
private static JsonElement serializeField(Descriptors.FieldDescriptor field, Object value) { switch (field.getType()) { case DOUBLE:// ww w . j a v a 2 s. c om return new JsonPrimitive((Double) value); case FLOAT: return new JsonPrimitive((Float) value); case INT64: case UINT64: case FIXED64: case SINT64: case SFIXED64: return new JsonPrimitive((Long) value); case INT32: case UINT32: case FIXED32: case SINT32: case SFIXED32: return new JsonPrimitive((Integer) value); case BOOL: return new JsonPrimitive((Boolean) value); case STRING: return new JsonPrimitive((String) value); case GROUP: case MESSAGE: return toJson((Message) value); case BYTES: return new JsonPrimitive(BaseEncoding.base64().encode(((ByteString) value).toByteArray())); case ENUM: String protoEnumName = ((Descriptors.EnumValueDescriptor) value).getName(); return new JsonPrimitive(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, protoEnumName)); } return null; }
From source file:com.google.errorprone.bugpatterns.ConstantField.java
@Override public Description matchVariable(VariableTree tree, VisitorState state) { Symbol.VarSymbol sym = ASTHelpers.getSymbol(tree); if (sym == null || sym.getKind() != ElementKind.FIELD) { return Description.NO_MATCH; }/*from www . j a v a2 s.c om*/ String name = sym.getSimpleName().toString(); if (sym.isStatic() && sym.getModifiers().contains(Modifier.FINAL)) { return checkImmutable(tree, state, sym, name); } if (!name.equals(name.toUpperCase())) { return Description.NO_MATCH; } return buildDescription(tree) .addFix(SuggestedFixes.addModifiers(tree, state, Modifier.FINAL, Modifier.STATIC)) .addFix(SuggestedFixes.renameVariable(tree, CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name), state)) .build(); }
From source file:com.github.ko2ic.plugin.eclipse.taggen.common.domain.valueobject.NameRuleString.java
public String toUpperCamel() { String value = str;/* w ww . j a v a2 s . co m*/ if (Character.isUpperCase(str.charAt(0))) { if (str.contains("_")) { value = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, str); } } else { if (str.contains("_")) { value = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, str); } else { value = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, str); } } return value; }
From source file:com.github.jcustenborder.kafka.connect.utils.config.AnnotationHelper.java
public static String title(Package p) { Title annotation = p.getAnnotation(Title.class); return (null != annotation) ? annotation.value() : CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, p.getName()); }
From source file:io.soliton.protobuf.plugin.ProtoServiceHandler.java
public void handle(ServiceDescriptorProto service) throws IOException { ImmutableList.Builder<ServiceHandlerData.Method> methods = ImmutableList.builder(); for (MethodDescriptorProto method : service.getMethodList()) { ServiceHandlerData.Method methodData = new ServiceHandlerData.Method(method.getName(), CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, method.getName()), types.lookup(method.getInputType()).toString(), types.lookup(method.getOutputType()).toString()); methods.add(methodData);/*from ww w . jav a2s . c o m*/ } String fullName = Joiner.on('.').skipNulls().join(protoPackage, service.getName()); ServiceHandlerData.Service serviceData = new ServiceHandlerData.Service(service.getName(), fullName, methods.build()); ServiceHandlerData data = new ServiceHandlerData(javaPackage, multipleFiles, serviceData); String template = Resources.toString(Resources.getResource(this.getClass(), "service_class.mvel"), Charsets.UTF_8); String serviceFile = (String) TemplateRuntime.eval(template, ImmutableMap.<String, Object>of("handler", data)); CodeGeneratorResponse.Builder response = CodeGeneratorResponse.newBuilder(); CodeGeneratorResponse.File.Builder file = CodeGeneratorResponse.File.newBuilder(); file.setContent(serviceFile); file.setName(javaPackage.replace('.', '/') + '/' + service.getName() + ".java"); if (!multipleFiles) { file.setName(javaPackage.replace('.', '/') + '/' + outerClassName + ".java"); file.setInsertionPoint("outer_class_scope"); } response.addFile(file); response.build().writeTo(output); }
From source file:com.shenit.commons.utils.ShenStrings.java
/** * To camel format/* w w w . java2s .c o m*/ * @param str * @return */ public static String camel(String str) { if (str.indexOf(DELIMITER_UNDERSCORE) < 0) return str; return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, str(str)); }
From source file:com.facebook.buck.query.LabelsFunction.java
@Override public Set<QueryTarget> eval(QueryEnvironment env, ImmutableList<Argument> args, ListeningExecutorService executor) throws QueryException, InterruptedException { String label = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, args.get(0).getWord()); Set<QueryTarget> inputs = args.get(1).getExpression().eval(env, executor); Set<QueryTarget> result = new LinkedHashSet<>(); for (QueryTarget input : inputs) { result.addAll(env.getTargetsInAttribute(input, label)); }/* w w w .j av a 2s . co m*/ return result; }
From source file:com.android.build.gradle.internal.profile.RecordingBuildListener.java
@Override public void afterExecute(Task task, TaskState taskState) { // find the right ExecutionType. String taskImpl = task.getClass().getSimpleName(); if (taskImpl.endsWith("_Decorated")) { taskImpl = taskImpl.substring(0, taskImpl.length() - "_Decorated".length()); }/* w ww.java2 s. c o m*/ String potentialExecutionTypeName = "TASK_" + CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.UPPER_UNDERSCORE).convert(taskImpl); ExecutionType executionType; try { executionType = ExecutionType.valueOf(potentialExecutionTypeName); } catch (IllegalArgumentException ignored) { executionType = ExecutionType.GENERIC_TASK_EXECUTION; } List<Recorder.Property> properties = new ArrayList<Recorder.Property>(); properties.add(new Recorder.Property("project", task.getProject().getName())); properties.add(new Recorder.Property("task", task.getName())); if (task instanceof DefaultAndroidTask) { String variantName = ((DefaultAndroidTask) task).getVariantName(); if (variantName == null) { throw new IllegalStateException( "Task with type " + task.getClass().getName() + " does not include a variantName"); } if (!variantName.isEmpty()) { properties.add(new Recorder.Property("variant", variantName)); } } TaskRecord taskRecord = taskRecords.get(task.getName()); mRecorder.closeRecord(new ExecutionRecord(taskRecord.recordId, 0 /* parentId */, taskRecord.startTime, System.currentTimeMillis() - taskRecord.startTime, executionType, properties)); }
From source file:uk.submergedcode.SubmergedCore.serialization.AchievementSerializer.java
public AchievementSerializer() { ImmutableMap<String, Achievement> specialCases = ImmutableMap.<String, Achievement>builder() .put("achievement.buildWorkBench", Achievement.BUILD_WORKBENCH) .put("achievement.diamonds", Achievement.GET_DIAMONDS) .put("achievement.portal", Achievement.NETHER_PORTAL) .put("achievement.ghast", Achievement.GHAST_RETURN) .put("achievement.theEnd", Achievement.END_PORTAL).put("achievement.theEnd2", Achievement.THE_END) .put("achievement.blazeRod", Achievement.GET_BLAZE_ROD) .put("achievement.potion", Achievement.BREW_POTION).build(); ImmutableBiMap.Builder<String, Achievement> builder = ImmutableBiMap.<String, Achievement>builder(); for (Achievement achievement : Achievement.values()) { if (specialCases.values().contains(achievement)) { continue; }//from w ww .ja v a 2 s . co m builder.put("achievement." + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, achievement.name()), achievement); } builder.putAll(specialCases); achievements = builder.build(); }
From source file:com.cloudera.csd.descriptors.CsdLoggingType.java
@JsonValue public String toJson() { return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); }