![JAR search and dependency download from the Maven repository](/logo.png)
net.jbock.compiler.ParameterModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbock Show documentation
Show all versions of jbock Show documentation
The jbock command line parser
package net.jbock.compiler;
import com.google.common.collect.ImmutableList;
import dagger.Module;
import dagger.Provides;
import dagger.Reusable;
import net.jbock.coerce.matching.matcher.ExactMatcher;
import net.jbock.coerce.matching.matcher.ListMatcher;
import net.jbock.coerce.matching.matcher.Matcher;
import net.jbock.coerce.matching.matcher.OptionalMatcher;
import net.jbock.compiler.parameter.Parameter;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import java.util.Optional;
@Module
public class ParameterModule {
private final TypeElement sourceElement;
private final Optional mapperClass;
private final String bundleKey;
ParameterModule(TypeElement sourceElement, Optional mapperClass, String bundleKey) {
this.sourceElement = sourceElement;
this.mapperClass = mapperClass;
this.bundleKey = bundleKey;
}
@Provides
@SourceElement
TypeElement sourceElement() {
return sourceElement;
}
@Provides
@MapperClass
Optional mapperClass() {
return mapperClass;
}
@Provides
@BundleKey
public String getBundleKey() {
return bundleKey;
}
@Reusable
@Provides
EnumName enumName(ExecutableElement sourceMethod, ImmutableList alreadyCreated) {
String methodName = sourceMethod.getSimpleName().toString();
EnumName result = EnumName.create(methodName);
for (Parameter param : alreadyCreated) {
if (param.paramName().enumConstant().equals(result.enumConstant())) {
return result.append(Integer.toString(alreadyCreated.size()));
}
}
return result;
}
@Reusable
@Provides
ImmutableList getMatchers(
OptionalMatcher optionalMatcher,
ListMatcher listMatcher,
ExactMatcher exactMatcher) {
return ImmutableList.of(optionalMatcher, listMatcher, exactMatcher);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy