org.eclipse.xtend.lib.annotations.FinalFieldsConstructor Java Examples

The following examples show how to use org.eclipse.xtend.lib.annotations.FinalFieldsConstructor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FinalFieldsConstructorProcessor.java    From xtext-lib with Eclipse Public License 2.0 6 votes vote down vote up
public void addFinalFieldsConstructor(final MutableClassDeclaration it) {
  boolean _isEmpty = this.getFinalFieldsConstructorArgumentTypes(it).isEmpty();
  if (_isEmpty) {
    final AnnotationReference anno = it.findAnnotation(this.context.findTypeGlobally(FinalFieldsConstructor.class));
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("There are no final fields, this annotation has no effect");
    this.context.addWarning(anno, _builder.toString());
    return;
  }
  boolean _hasFinalFieldsConstructor = this.hasFinalFieldsConstructor(it);
  if (_hasFinalFieldsConstructor) {
    this.context.addError(it, this.getConstructorAlreadyExistsMessage(it));
    return;
  }
  final Procedure1<MutableConstructorDeclaration> _function = (MutableConstructorDeclaration it_1) -> {
    this.context.setPrimarySourceElement(it_1, this.context.getPrimarySourceElement(it_1.getDeclaringType()));
    this.makeFinalFieldsConstructor(it_1);
  };
  it.addConstructor(_function);
}
 
Example #2
Source File: SARLValidator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies if the given annotation is a forbidden active annotation.
 *
 * @param annotation the annotation.
 * @return {@code true} if the annotation is forbidden.
 */
@SuppressWarnings("static-method")
protected boolean isForbiddenActiveAnnotation(XAnnotation annotation) {
	final String name = annotation.getAnnotationType().getQualifiedName();
	return Strings.equal(EqualsHashCode.class.getName(), name)
			|| Strings.equal(FinalFieldsConstructor.class.getName(), name);
}