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:com.tactfactory.harmony.platform.android.AndroidProjectAdapter.java
@Override public List<IUpdater> getMenuFiles() { List<IUpdater> result = new ArrayList<IUpdater>(); String cappedProjectName = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, this.adapter.getApplicationMetadata().getName()); String templatePath = this.adapter.getTemplateMenuBasePath(); String filePath = this.adapter.getMenuBasePath(); // create MenuWrapper result.add(new SourceFile(templatePath + "MenuWrapperBase.java", filePath + "MenuWrapperBase.java", true)); // Package infos result.add(new SourceFile(templatePath + "package-info.java", filePath + "package-info.java", false)); templatePath = this.adapter.getTemplateMenuPath(); filePath = this.adapter.getMenuPath(); // create ProjectMenu result.add(new SourceFile(templatePath + "TemplateMenu.java", String.format("%s%sMenu.java", filePath, cappedProjectName), false)); result.add(new SourceFile(templatePath + "package-info.java", filePath + "package-info.java", false)); return result; }
From source file:com.tactfactory.harmony.platform.android.AndroidProjectAdapter.java
@Override public List<IUpdater> getMenuBaseFiles() { List<IUpdater> result = new ArrayList<IUpdater>(); String cappedProjectName = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, this.adapter.getApplicationMetadata().getName()); String templatePath = this.adapter.getTemplateMenuBasePath(); String filePath = this.adapter.getMenuBasePath(); // create ProjectMenuBase result.add(new SourceFile(templatePath + "TemplateMenuBase.java", String.format("%s%sMenuBase.java", filePath, cappedProjectName), true)); return result; }
From source file:dagger2.internal.codegen.ComponentGenerator.java
private FrameworkField frameworkFieldForResolvedBindings(ResolvedBindings resolvedBindings) { BindingKey bindingKey = resolvedBindings.bindingKey(); switch (bindingKey.kind()) { case CONTRIBUTION: ImmutableSet<? extends ContributionBinding> contributionBindings = resolvedBindings .contributionBindings(); BindingType bindingsType = ProvisionBinding.bindingTypeFor(contributionBindings); switch (bindingsType) { case SET: case MAP: return FrameworkField.createWithTypeFromKey(frameworkClassForResolvedBindings(resolvedBindings), bindingKey, KeyVariableNamer.INSTANCE.apply(bindingKey.key())); case UNIQUE: ContributionBinding binding = Iterables.getOnlyElement(contributionBindings); return FrameworkField.createWithTypeFromKey(frameworkClassForResolvedBindings(resolvedBindings), bindingKey, binding.bindingElement().accept(new ElementKindVisitor6<String, Void>() { @Override public String visitExecutableAsConstructor(ExecutableElement e, Void p) { return e.getEnclosingElement().accept(this, null); }//from www .j a va 2s.c o m @Override public String visitExecutableAsMethod(ExecutableElement e, Void p) { return e.getSimpleName().toString(); } @Override public String visitType(TypeElement e, Void p) { return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, e.getSimpleName().toString()); } }, null)); default: throw new AssertionError(); } case MEMBERS_INJECTION: return FrameworkField.createWithTypeFromKey(MembersInjector.class, bindingKey, CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, Iterables.getOnlyElement(resolvedBindings.bindings()).bindingElement().getSimpleName() .toString())); default: throw new AssertionError(); } }
From source file:dagger2.internal.codegen.ComponentGenerator.java
private Snippet initializeFactoryForProvisionBinding(ProvisionBinding binding, ClassName componentName, ImmutableMap<ExecutableElement, TypeElement> dependencyMethodIndex, Map<TypeElement, MemberSelect> contributionFields, ImmutableMap<BindingKey, MemberSelect> memberSelectSnippets) { switch (binding.bindingKind()) { case COMPONENT: MemberSelect componentContributionSelect = contributionFields .get(MoreTypes.asTypeElement(binding.key().type())); return Snippet.format("%s.<%s>create(%s)", ClassName.fromClass(InstanceFactory.class), TypeNames.forTypeMirror(binding.key().type()), componentContributionSelect != null ? componentContributionSelect.getSnippetFor(componentName) : "this"); case COMPONENT_PROVISION: TypeElement bindingTypeElement = dependencyMethodIndex.get(binding.bindingElement()); String sourceFieldName = CaseFormat.UPPER_CAMEL.to(LOWER_CAMEL, bindingTypeElement.getSimpleName().toString()); if (binding.nullableType().isPresent() || nullableValidationType.equals(Diagnostic.Kind.WARNING)) { Snippet nullableSnippet = binding.nullableType().isPresent() ? Snippet.format("@%s ", TypeNames.forTypeMirror(binding.nullableType().get())) : Snippet.format(""); return Snippet.format( Joiner.on('\n').join("new %s<%2$s>() {", " private final %6$s %7$s = %3$s;", " %5$s@Override public %2$s get() {", " return %7$s.%4$s();", " }", "}"), ClassName.fromClass(Factory.class), TypeNames.forTypeMirror(binding.key().type()), contributionFields.get(bindingTypeElement).getSnippetFor(componentName), binding.bindingElement().getSimpleName().toString(), nullableSnippet, TypeNames.forTypeMirror(bindingTypeElement.asType()), sourceFieldName); } else {/* w w w.jav a 2 s . c o m*/ // TODO(sameb): This throws a very vague NPE right now. The stack trace doesn't // help to figure out what the method or return type is. If we include a string // of the return type or method name in the error message, that can defeat obfuscation. // We can easily include the raw type (no generics) + annotation type (no values), // using .class & String.format -- but that wouldn't be the whole story. // What should we do? StringLiteral failMsg = StringLiteral .forValue(CANNOT_RETURN_NULL_FROM_NON_NULLABLE_COMPONENT_METHOD); return Snippet.format( Joiner.on('\n').join("new %s<%2$s>() {", " private final %6$s %7$s = %3$s;", " @Override public %2$s get() {", " %2$s provided = %7$s.%4$s();", " if (provided == null) {", " throw new NullPointerException(%5$s);", " }", " return provided;", " }", "}"), ClassName.fromClass(Factory.class), TypeNames.forTypeMirror(binding.key().type()), contributionFields.get(bindingTypeElement).getSnippetFor(componentName), binding.bindingElement().getSimpleName().toString(), failMsg, TypeNames.forTypeMirror(bindingTypeElement.asType()), sourceFieldName); } case INJECTION: case PROVISION: List<Snippet> parameters = Lists.newArrayListWithCapacity(binding.dependencies().size() + 1); if (binding.bindingKind().equals(PROVISION) && !binding.bindingElement().getModifiers().contains(STATIC)) { parameters.add(contributionFields.get(binding.contributedBy().get()).getSnippetFor(componentName)); } parameters.addAll( getDependencyParameters(componentName, binding.implicitDependencies(), memberSelectSnippets)); Snippet factorySnippet = Snippet.format("%s.create(%s)", factoryNameForProvisionBinding(binding), Snippet.makeParametersSnippet(parameters)); return binding.scope().isPresent() ? Snippet.format("%s.create(%s)", ClassName.fromClass(ScopedProvider.class), factorySnippet) : factorySnippet; default: throw new AssertionError(); } }
From source file:dagger2.internal.codegen.ComponentGenerator.java
private Snippet initializeFactoryForProductionBinding(ProductionBinding binding, BindingGraph bindingGraph, ClassName componentName, ImmutableMap<ExecutableElement, TypeElement> dependencyMethodIndex, Map<TypeElement, MemberSelect> contributionFields, ImmutableMap<BindingKey, MemberSelect> memberSelectSnippets) { switch (binding.bindingKind()) { case COMPONENT_PRODUCTION: TypeElement bindingTypeElement = dependencyMethodIndex.get(binding.bindingElement()); String sourceFieldName = CaseFormat.UPPER_CAMEL.to(LOWER_CAMEL, bindingTypeElement.getSimpleName().toString()); return Snippet.format( Joiner.on('\n').join("new %s<%2$s>() {", " private final %6$s %7$s = %4$s;", " @Override public %3$s<%2$s> get() {", " return %7$s.%5$s();", " }", "}"), ClassName.fromClass(Producer.class), TypeNames.forTypeMirror(binding.key().type()), ClassName.fromClass(ListenableFuture.class), contributionFields.get(bindingTypeElement).getSnippetFor(componentName), binding.bindingElement().getSimpleName().toString(), TypeNames.forTypeMirror(bindingTypeElement.asType()), sourceFieldName); case IMMEDIATE: case FUTURE_PRODUCTION: List<Snippet> parameters = Lists.newArrayListWithCapacity(binding.dependencies().size() + 2); parameters.add(contributionFields.get(binding.bindingTypeElement()).getSnippetFor(componentName)); parameters.add(contributionFields.get(bindingGraph.componentDescriptor().executorDependency().get()) .getSnippetFor(componentName)); parameters.addAll(getProducerDependencyParameters(bindingGraph, componentName, binding.dependencies(), memberSelectSnippets));/* w w w .ja va2s . c o m*/ return Snippet.format("new %s(%s)", factoryNameForProductionBinding(binding), Snippet.makeParametersSnippet(parameters)); default: throw new AssertionError(); } }
From source file:pt.ist.fenixedu.integration.api.FenixAPIv1.java
private FenixCourseEvaluation.GenericTest getGenericTestJSON(Evaluation evaluation) { String type = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, evaluation.getClass().getSimpleName()); return new FenixCourseEvaluation.GenericTest(evaluation.getPresentationName(), type); }