This takes advantage of the fact maven 3.1.1 supports slf4j natively.
Also fixup some of the coding style issues still present.
Change-Id: I37724cc0a5c194fc333c577f39deaf550c341d34
Signed-off-by: Robert Varga <rovarga@cisco.com>
<!-- 3rd party dependencies needed by config-->
<dependency>
<!-- 3rd party dependencies needed by config-->
<dependency>
- <groupId>com.jcabi</groupId>
- <artifactId>jcabi-maven-slf4j</artifactId>
- <version>0.8</version>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>3.1.1</version>
+ <scope>provided</scope>
</dependency>
<dependency>
</dependency>
<dependency>
<artifactId>guava</artifactId>
</dependency>
<artifactId>guava</artifactId>
</dependency>
- <dependency>
- <groupId>com.jcabi</groupId>
- <artifactId>jcabi-maven-slf4j</artifactId>
- </dependency>
-
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<artifactId>commons-lang3</artifactId>
</dependency>
<artifactId>commons-lang3</artifactId>
</dependency>
- <dependency>
- <groupId>org.codehaus.gmaven.runtime</groupId>
- <artifactId>gmaven-runtime-2.0</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.sonatype.gossip</groupId>
- <artifactId>gossip</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-jmx-generator</artifactId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-jmx-generator</artifactId>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
</dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<dependency>
<groupId>org.slf4j</groupId>
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils;
-import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
import org.apache.maven.project.MavenProject;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang2sources.spi.CodeGenerator;
+import org.opendaylight.yangtools.yang2sources.spi.BasicCodeGenerator;
+import org.opendaylight.yangtools.yang2sources.spi.MavenProjectAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.slf4j.impl.StaticLoggerBinder;
/**
* This class interfaces with yang-maven-plugin. Gets parsed yang modules in
* {@link SchemaContext}, and parameters form the plugin configuration, and
* writes service interfaces and/or modules.
*/
/**
* This class interfaces with yang-maven-plugin. Gets parsed yang modules in
* {@link SchemaContext}, and parameters form the plugin configuration, and
* writes service interfaces and/or modules.
*/
-public class JMXGenerator implements CodeGenerator {
+public class JMXGenerator implements BasicCodeGenerator, MavenProjectAware {
+ private static final class NamespaceMapping {
+ private final String namespace, packageName;
+ public NamespaceMapping(final String namespace, final String packagename) {
+ this.namespace = namespace;
+ this.packageName = packagename;
+ }
+ }
+
+ @VisibleForTesting
static final String NAMESPACE_TO_PACKAGE_DIVIDER = "==";
static final String NAMESPACE_TO_PACKAGE_DIVIDER = "==";
static final String NAMESPACE_TO_PACKAGE_PREFIX = "namespaceToPackage";
static final String NAMESPACE_TO_PACKAGE_PREFIX = "namespaceToPackage";
static final String MODULE_FACTORY_FILE_BOOLEAN = "moduleFactoryFile";
static final String MODULE_FACTORY_FILE_BOOLEAN = "moduleFactoryFile";
+ private static final Logger LOG = LoggerFactory.getLogger(JMXGenerator.class);
+ private static final Pattern NAMESPACE_MAPPING_PATTERN = Pattern.compile("(.+)" + NAMESPACE_TO_PACKAGE_DIVIDER + "(.+)");
+
private PackageTranslator packageTranslator;
private final CodeWriter codeWriter;
private PackageTranslator packageTranslator;
private final CodeWriter codeWriter;
- private static final Logger LOG = LoggerFactory
- .getLogger(JMXGenerator.class);
private Map<String, String> namespaceToPackageMapping;
private File resourceBaseDir;
private File projectBaseDir;
private boolean generateModuleFactoryFile = true;
public JMXGenerator() {
private Map<String, String> namespaceToPackageMapping;
private File resourceBaseDir;
private File projectBaseDir;
private boolean generateModuleFactoryFile = true;
public JMXGenerator() {
- this.codeWriter = new CodeWriter();
+ this(new CodeWriter());
- public JMXGenerator(CodeWriter codeWriter) {
+ public JMXGenerator(final CodeWriter codeWriter) {
this.codeWriter = codeWriter;
}
@Override
this.codeWriter = codeWriter;
}
@Override
- public Collection<File> generateSources(SchemaContext context,
- File outputBaseDir, Set<Module> yangModulesInCurrentMavenModule) {
+ public Collection<File> generateSources(final SchemaContext context,
+ final File outputBaseDir, final Set<Module> yangModulesInCurrentMavenModule) {
Preconditions.checkArgument(context != null, "Null context received");
Preconditions.checkArgument(outputBaseDir != null,
Preconditions.checkArgument(context != null, "Null context received");
Preconditions.checkArgument(outputBaseDir != null,
return generatedFiles.getFiles();
}
return generatedFiles.getFiles();
}
- static File concatFolders(File projectBaseDir, String... folderNames) {
+ @VisibleForTesting
+ static File concatFolders(final File projectBaseDir, final String... folderNames) {
StringBuilder b = new StringBuilder();
for (String folder : folderNames) {
b.append(folder);
StringBuilder b = new StringBuilder();
for (String folder : folderNames) {
b.append(folder);
- public void setAdditionalConfig(Map<String, String> additionalCfg) {
- if (LOG != null) {
- LOG.debug(getClass().getCanonicalName(),
- ": Additional configuration received: ",
- additionalCfg.toString());
- }
+ public void setAdditionalConfig(final Map<String, String> additionalCfg) {
+ LOG.debug("{}: Additional configuration received: {}", getClass().getCanonicalName(), additionalCfg);
this.namespaceToPackageMapping = extractNamespaceMapping(additionalCfg);
this.generateModuleFactoryFile = extractModuleFactoryBoolean(additionalCfg);
}
private boolean extractModuleFactoryBoolean(
this.namespaceToPackageMapping = extractNamespaceMapping(additionalCfg);
this.generateModuleFactoryFile = extractModuleFactoryBoolean(additionalCfg);
}
private boolean extractModuleFactoryBoolean(
- Map<String, String> additionalCfg) {
+ final Map<String, String> additionalCfg) {
String bool = additionalCfg.get(MODULE_FACTORY_FILE_BOOLEAN);
if (bool == null) {
return true;
String bool = additionalCfg.get(MODULE_FACTORY_FILE_BOOLEAN);
if (bool == null) {
return true;
- @Override
- public void setLog(Log log) {
- StaticLoggerBinder.getSingleton().setMavenLog(log);
- }
-
private static Map<String, String> extractNamespaceMapping(
private static Map<String, String> extractNamespaceMapping(
- Map<String, String> additionalCfg) {
+ final Map<String, String> additionalCfg) {
Map<String, String> namespaceToPackage = Maps.newHashMap();
for (String key : additionalCfg.keySet()) {
if (key.startsWith(NAMESPACE_TO_PACKAGE_PREFIX)) {
Map<String, String> namespaceToPackage = Maps.newHashMap();
for (String key : additionalCfg.keySet()) {
if (key.startsWith(NAMESPACE_TO_PACKAGE_PREFIX)) {
return namespaceToPackage;
}
return namespaceToPackage;
}
- static Pattern namespaceMappingPattern = Pattern.compile("(.+)"
- + NAMESPACE_TO_PACKAGE_DIVIDER + "(.+)");
-
- private static NamespaceMapping extractNamespaceMapping(String mapping) {
- Matcher matcher = namespaceMappingPattern.matcher(mapping);
- Preconditions
- .checkArgument(matcher.matches(), String.format("Namespace to package mapping:%s is in invalid " +
- "format, requested format is: %s", mapping, namespaceMappingPattern));
+ private static NamespaceMapping extractNamespaceMapping(final String mapping) {
+ Matcher matcher = NAMESPACE_MAPPING_PATTERN.matcher(mapping);
+ Preconditions.checkArgument(matcher.matches(),
+ "Namespace to package mapping:%s is in invalid format, requested format is: %s",
+ mapping, NAMESPACE_MAPPING_PATTERN);
return new NamespaceMapping(matcher.group(1), matcher.group(2));
}
return new NamespaceMapping(matcher.group(1), matcher.group(2));
}
- private static class NamespaceMapping {
- public NamespaceMapping(String namespace, String packagename) {
- this.namespace = namespace;
- this.packageName = packagename;
- }
-
- private final String namespace, packageName;
- }
-
- public void setResourceBaseDir(File resourceDir) {
+ public void setResourceBaseDir(final File resourceDir) {
this.resourceBaseDir = resourceDir;
}
@Override
this.resourceBaseDir = resourceDir;
}
@Override
- public void setMavenProject(MavenProject project) {
+ public void setMavenProject(final MavenProject project) {
this.projectBaseDir = project.getBasedir();
this.projectBaseDir = project.getBasedir();
-
- if (LOG != null) {
- LOG.debug(getClass().getCanonicalName(), " project base dir: ",
- projectBaseDir);
- }
+ LOG.debug("{}: project base dir: {}", getClass().getCanonicalName(), projectBaseDir);
}
@VisibleForTesting
static class GeneratedFilesTracker {
private final Set<File> files = Sets.newHashSet();
}
@VisibleForTesting
static class GeneratedFilesTracker {
private final Set<File> files = Sets.newHashSet();
- void addFile(File file) {
+ void addFile(final File file) {
if (files.contains(file)) {
List<File> undeletedFiles = Lists.newArrayList();
for (File presentFile : files) {
if (files.contains(file)) {
List<File> undeletedFiles = Lists.newArrayList();
for (File presentFile : files) {
- void addFile(Collection<File> files) {
+ void addFile(final Collection<File> files) {
for (File file : files) {
addFile(file);
}
for (File file : files) {
addFile(file);
}
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.io.FileUtils;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.io.FileUtils;
-import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.compiler.IProblem;
import org.apache.maven.project.MavenProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.compiler.IProblem;
File targetDir = new File(generatorOutputPath, "target");
generatedResourcesDir = new File(targetDir, "generated-resources");
jmxGenerator.setResourceBaseDir(generatedResourcesDir);
File targetDir = new File(generatorOutputPath, "target");
generatedResourcesDir = new File(targetDir, "generated-resources");
jmxGenerator.setResourceBaseDir(generatedResourcesDir);
- Log mockedLog = mock(Log.class);
- doReturn(false).when(mockedLog).isDebugEnabled();
- doNothing().when(mockedLog).debug(any(CharSequence.class));
- doNothing().when(mockedLog).info(any(CharSequence.class));
- doNothing().when(mockedLog).error(any(CharSequence.class),
- any(Throwable.class));
- jmxGenerator.setLog(mockedLog);
MavenProject project = mock(MavenProject.class);
doReturn(generatorOutputPath).when(project).getBasedir();
jmxGenerator.setMavenProject(project);
MavenProject project = mock(MavenProject.class);
doReturn(generatorOutputPath).when(project).getBasedir();
jmxGenerator.setMavenProject(project);
verifyModuleFactoryFile(false);
}
verifyModuleFactoryFile(false);
}
- private void verifyModuleFactoryFile(boolean shouldBePresent) {
+ private void verifyModuleFactoryFile(final boolean shouldBePresent) {
File factoryFile = new File(generatedResourcesDir, "META-INF"
+ File.separator + "services" + File.separator
+ ModuleFactory.class.getName());
File factoryFile = new File(generatedResourcesDir, "META-INF"
+ File.separator + "services" + File.separator
+ ModuleFactory.class.getName());
+ if (!shouldBePresent) {
assertFalse("Factory file should not be generated",
factoryFile.exists());
assertFalse("Factory file should not be generated",
factoryFile.exists());
assertTrue("Factory file should be generated", factoryFile.exists());
assertTrue("Factory file should be generated", factoryFile.exists());
- public static List<String> toFileNames(Collection<File> files) {
+ public static List<String> toFileNames(final Collection<File> files) {
List<String> result = new ArrayList<>();
for (File f : files) {
result.add(f.getName());
List<String> result = new ArrayList<>();
for (File f : files) {
result.add(f.getName());
new Predicate<File>() {
@Override
new Predicate<File>() {
@Override
- public boolean apply(File input) {
+ public boolean apply(final File input) {
return input.getName().endsWith("xml");
}
});
return input.getName().endsWith("xml");
}
});
new Predicate<File>() {
@Override
new Predicate<File>() {
@Override
- public boolean apply(File input) {
+ public boolean apply(final File input) {
return input.getName().endsWith("java");
}
});
return input.getName().endsWith("java");
}
});
String name = file.getName();
MbeASTVisitor visitor = new MbeASTVisitor();
verifiers.put(name, visitor);
String name = file.getName();
MbeASTVisitor visitor = new MbeASTVisitor();
verifiers.put(name, visitor);
- if (name.equals("AbstractDynamicThreadPoolModule.java"))
+ if (name.equals("AbstractDynamicThreadPoolModule.java")) {
abstractDynamicThreadPoolModuleVisitor = visitor;
abstractDynamicThreadPoolModuleVisitor = visitor;
- if (name.equals("AsyncEventBusModuleMXBean.java"))
+ }
+ if (name.equals("AsyncEventBusModuleMXBean.java")) {
asyncEventBusModuleMXBeanVisitor = visitor;
asyncEventBusModuleMXBeanVisitor = visitor;
- if (name.equals("AbstractNamingThreadFactoryModuleFactory.java"))
+ }
+ if (name.equals("AbstractNamingThreadFactoryModuleFactory.java")) {
abstractNamingThreadFactoryModuleFactoryVisitor = visitor;
abstractNamingThreadFactoryModuleFactoryVisitor = visitor;
- if (name.equals("AsyncEventBusModule.java"))
+ }
+ if (name.equals("AsyncEventBusModule.java")) {
asyncEventBusModuleVisitor = visitor;
asyncEventBusModuleVisitor = visitor;
- if (name.equals("EventBusModuleFactory.java"))
+ }
+ if (name.equals("EventBusModuleFactory.java")) {
eventBusModuleFactoryVisitor = visitor;
eventBusModuleFactoryVisitor = visitor;
}
processGeneratedCode(javaFiles, verifiers);
}
processGeneratedCode(javaFiles, verifiers);
- private void verifyXmlFiles(Collection<File> xmlFiles) throws Exception {
+ private void verifyXmlFiles(final Collection<File> xmlFiles) throws Exception {
ErrorHandler errorHandler = new ErrorHandler() {
@Override
ErrorHandler errorHandler = new ErrorHandler() {
@Override
- public void warning(SAXParseException exception)
+ public void warning(final SAXParseException exception)
throws SAXException {
fail("Generated blueprint xml is not well formed "
+ exception.getMessage());
}
@Override
throws SAXException {
fail("Generated blueprint xml is not well formed "
+ exception.getMessage());
}
@Override
- public void fatalError(SAXParseException exception)
+ public void fatalError(final SAXParseException exception)
throws SAXException {
fail("Generated blueprint xml is not well formed "
+ exception.getMessage());
}
@Override
throws SAXException {
fail("Generated blueprint xml is not well formed "
+ exception.getMessage());
}
@Override
- public void error(SAXParseException exception) throws SAXException {
+ public void error(final SAXParseException exception) throws SAXException {
fail("Generated blueprint xml is not well formed "
+ exception.getMessage());
}
fail("Generated blueprint xml is not well formed "
+ exception.getMessage());
}
- private void assertEventBusModuleFactory(MbeASTVisitor visitor) {
+ private void assertEventBusModuleFactory(final MbeASTVisitor visitor) {
assertEquals(PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX
+ ".threads.java", visitor.packageName);
assertEquals("EventBusModuleFactory", visitor.type);
assertEquals(PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX
+ ".threads.java", visitor.packageName);
assertEquals("EventBusModuleFactory", visitor.type);
visitor.methodJavadoc.size());
}
visitor.methodJavadoc.size());
}
- private void assertAsyncEventBusModule(MbeASTVisitor visitor) {
+ private void assertAsyncEventBusModule(final MbeASTVisitor visitor) {
assertEquals(PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX
+ ".threads.java", visitor.packageName);
assertEquals("AsyncEventBusModule", visitor.type);
assertEquals(PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX
+ ".threads.java", visitor.packageName);
assertEquals("AsyncEventBusModule", visitor.type);
}
private void assertAbstractNamingThreadFactoryModuleFactory(
}
private void assertAbstractNamingThreadFactoryModuleFactory(
- MbeASTVisitor visitor) {
+ final MbeASTVisitor visitor) {
assertEquals(PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX
+ ".threads.java", visitor.packageName);
assertEquals("AbstractNamingThreadFactoryModuleFactory", visitor.type);
assertEquals(PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX
+ ".threads.java", visitor.packageName);
assertEquals("AbstractNamingThreadFactoryModuleFactory", visitor.type);
- private void assertFactoryMethods(Set<String> methods, int expectedSize) {
+ private void assertFactoryMethods(final Set<String> methods, final int expectedSize) {
List<ArgumentAssertion> args = Lists.newArrayList();
ArgumentAssertion oldInstanceArg = new ArgumentAssertion(DynamicMBeanWithInstance.class.getCanonicalName(), "old");
List<ArgumentAssertion> args = Lists.newArrayList();
ArgumentAssertion oldInstanceArg = new ArgumentAssertion(DynamicMBeanWithInstance.class.getCanonicalName(), "old");
- private void assertMethodPresent(Set<String> methods, MethodAssertion methodAssertion) {
+ private void assertMethodPresent(final Set<String> methods, final MethodAssertion methodAssertion) {
assertTrue(String.format("Generated methods did not contain %s, generated methods: %s",
methodAssertion.toString(), methods), methods.contains(methodAssertion.toString()));
}
assertTrue(String.format("Generated methods did not contain %s, generated methods: %s",
methodAssertion.toString(), methods), methods.contains(methodAssertion.toString()));
}
- private void assertAsyncEventBusModuleMXBean(MbeASTVisitor visitor) {
+ private void assertAsyncEventBusModuleMXBean(final MbeASTVisitor visitor) {
assertEquals(PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX
+ ".threads.java", visitor.packageName);
assertEquals("AsyncEventBusModuleMXBean", visitor.type);
assertEquals(PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX
+ ".threads.java", visitor.packageName);
assertEquals("AsyncEventBusModuleMXBean", visitor.type);
- private void assertAbstractDynamicThreadPoolModule(MbeASTVisitor visitor) {
+ private void assertAbstractDynamicThreadPoolModule(final MbeASTVisitor visitor) {
assertEquals(PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX
+ ".threads.java", visitor.packageName);
assertNotNull(visitor.javadoc);
assertEquals(PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX
+ ".threads.java", visitor.packageName);
assertNotNull(visitor.javadoc);
visitor.methodJavadoc.get("void setMaximumSize(java.lang.Long maximumSize)"));
}
visitor.methodJavadoc.get("void setMaximumSize(java.lang.Long maximumSize)"));
}
- private void assertDeclaredField(Set<String> fieldDeclarations,
- String declaration) {
+ private void assertDeclaredField(final Set<String> fieldDeclarations,
+ final String declaration) {
assertTrue("Missing field " + declaration + ", got: "
+ fieldDeclarations,
fieldDeclarations.contains(declaration + ";\n"));
assertTrue("Missing field " + declaration + ", got: "
+ fieldDeclarations,
fieldDeclarations.contains(declaration + ";\n"));
protected Map<String, String> methodDescriptions = Maps.newHashMap();
@Override
protected Map<String, String> methodDescriptions = Maps.newHashMap();
@Override
- public boolean visit(PackageDeclaration node) {
+ public boolean visit(final PackageDeclaration node) {
packageName = node.getName().toString();
return super.visit(node);
}
@Override
packageName = node.getName().toString();
return super.visit(node);
}
@Override
- public boolean visit(NormalAnnotation node) {
+ public boolean visit(final NormalAnnotation node) {
if (node.getTypeName().toString()
.equals(Description.class.getCanonicalName())) {
if (node.getParent() instanceof TypeDeclaration) {
if (node.getTypeName().toString()
.equals(Description.class.getCanonicalName())) {
if (node.getParent() instanceof TypeDeclaration) {
- public boolean visit(TypeDeclaration node) {
+ public boolean visit(final TypeDeclaration node) {
javadoc = node.getJavadoc() == null ? null : node.getJavadoc()
.toString();
type = node.getName().toString();
javadoc = node.getJavadoc() == null ? null : node.getJavadoc()
.toString();
type = node.getName().toString();
private final Map<String, String> methodJavadoc = Maps.newHashMap();
@Override
private final Map<String, String> methodJavadoc = Maps.newHashMap();
@Override
- public boolean visit(NormalAnnotation node) {
+ public boolean visit(final NormalAnnotation node) {
boolean result = super.visit(node);
if (node.getTypeName().toString()
.equals(RequireInterface.class.getCanonicalName())
boolean result = super.visit(node);
if (node.getTypeName().toString()
.equals(RequireInterface.class.getCanonicalName())
- public boolean visit(FieldDeclaration node) {
+ public boolean visit(final FieldDeclaration node) {
fieldDeclarations.add(node.toString());
return super.visit(node);
}
@Override
fieldDeclarations.add(node.toString());
return super.visit(node);
}
@Override
- public boolean visit(MethodDeclaration node) {
- if (node.isConstructor())
+ public boolean visit(final MethodDeclaration node) {
+ if (node.isConstructor()) {
constructors.add(node.toString());
constructors.add(node.toString());
String methodSignature = node.getReturnType2() + " " + node.getName() + "(";
boolean first = true;
for (Object o : node.parameters()) {
String methodSignature = node.getReturnType2() + " " + node.getName() + "(";
boolean first = true;
for (Object o : node.parameters()) {
- public boolean visit(TypeDeclaration node) {
+ public boolean visit(final TypeDeclaration node) {
boolean visit = super.visit(node);
List<?> superIfcs = node.superInterfaceTypes();
implmts = superIfcs != null && !superIfcs.isEmpty() ? superIfcs
boolean visit = super.visit(node);
List<?> superIfcs = node.superInterfaceTypes();
implmts = superIfcs != null && !superIfcs.isEmpty() ? superIfcs
- private void assertContains(String source, String... contained) {
+ private void assertContains(final String source, final String... contained) {
for (String string : contained) {
assertThat(source, containsString(string));
}
}
for (String string : contained) {
assertThat(source, containsString(string));
}
}
- private void processGeneratedCode(Collection<File> files,
- Map<String, ASTVisitor> verifiers) throws IOException {
+ private void processGeneratedCode(final Collection<File> files,
+ final Map<String, ASTVisitor> verifiers) throws IOException {
ASTParser parser = ASTParser.newParser(AST.JLS3);
Map<?, ?> options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_7, options);
ASTParser parser = ASTParser.newParser(AST.JLS3);
Map<?, ?> options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_7, options);
for (IProblem c : cu.getProblems()) {
// 1610613332 = Syntax error, annotations are only available if
// source level is 5.0
for (IProblem c : cu.getProblems()) {
// 1610613332 = Syntax error, annotations are only available if
// source level is 5.0
- if (c.getID() == 1610613332)
+ if (c.getID() == 1610613332) {
// 1610613332 = Syntax error, parameterized types are only
// available if source level is 5.0
// 1610613332 = Syntax error, parameterized types are only
// available if source level is 5.0
- if (c.getID() == 1610613329)
+ if (c.getID() == 1610613329) {
- if (c.getID() == 1610613328) // 'for each' statements are only available if source level is 5.0
+ }
+ if (c.getID() == 1610613328) {
fail("Error in generated source code " + file + ":"
+ c.getSourceLineNumber() + " id: " + c.getID() + " message:" + c.toString());
}
ASTVisitor visitor = verifiers.get(file.getName());
fail("Error in generated source code " + file + ":"
+ c.getSourceLineNumber() + " id: " + c.getID() + " message:" + c.toString());
}
ASTVisitor visitor = verifiers.get(file.getName());
fail("Unknown generated file " + file.getName());
fail("Unknown generated file " + file.getName());
- public static char[] readFileAsChars(File file) throws IOException {
+ public static char[] readFileAsChars(final File file) throws IOException {
List<String> readLines = Files
.readLines(file, Charset.forName("utf-8"));
char[] retVal = new char[0];
List<String> readLines = Files
.readLines(file, Charset.forName("utf-8"));
char[] retVal = new char[0];
private static class MethodAssertion extends ArgumentAssertion{
private static class MethodAssertion extends ArgumentAssertion{
- private List<ArgumentAssertion> arguments;
+ private final List<ArgumentAssertion> arguments;
- MethodAssertion(String type, String name, List<ArgumentAssertion> arguments) {
+ MethodAssertion(final String type, final String name, final List<ArgumentAssertion> arguments) {
super(type, name);
this.arguments = arguments;
}
super(type, name);
this.arguments = arguments;
}
- MethodAssertion(String type, String name) {
+ MethodAssertion(final String type, final String name) {
this(type, name, Collections.<ArgumentAssertion>emptyList());
}
this(type, name, Collections.<ArgumentAssertion>emptyList());
}
for (ArgumentAssertion argument : arguments) {
sb.append(argument.type).append(' ');
sb.append(argument.name);
for (ArgumentAssertion argument : arguments) {
sb.append(argument.type).append(' ');
sb.append(argument.name);
- if(++i != arguments.size())
+ if(++i != arguments.size()) {
}
sb.append(')');
return sb.toString();
}
sb.append(')');
return sb.toString();
protected final String type, name;
protected final String type, name;
- private ArgumentAssertion(String type, String name) {
+ private ArgumentAssertion(final String type, final String name) {
this.type = type;
this.name = name;
}
this.type = type;
this.name = name;
}