Skip to content
Gábor Szárnyas edited this page Aug 16, 2016 · 5 revisions

Active annotations

Problem

Active annotations (e.g. @Data) do not work:

Data cannot be resolved to an annotation type

Solution

http://www.eclipse.org/community/eclipse_newsletter/2013/march/article1.php

"The test will make use of the compiler, so we need to add a dependency to it. If you have choosen the Maven way add the following dependency to you pom.xml file.

<dependency>
  <groupId>org.eclipse.xtend</groupId>
  <artifactId>org.eclipse.xtend.standalone</artifactId>
  <version>2.4.0</version>
  <scope>test</scope>
</dependency>

Note that we only need this dependency for testing, which is why we set the scope element to 'test'. Further more we need some test framework, we use Junit in this example.

If you choose to go with an OSGi bundle, add a require-bundle dependency in your Manifest.MF for the bundle org.eclipse.xtend.standalone."

If-then-else method

def <Source> ite(Source s, Function1<Source, Boolean> pred, String s1, String s2){
	if (pred.apply(s)) {
		return s1
	} else {
		return s2
	}
}

Links

Clone this wiki locally