All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fhoster.livebase.CloudletSMSSenderAnnotationProcessor Maven / Gradle / Ivy

/**
 *   Copyright 2024 Fhoster srl
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package com.fhoster.livebase;

import java.lang.annotation.Annotation;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.Element;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Functions.Function0;
import org.eclipse.xtext.xbase.lib.IterableExtensions;

@SupportedAnnotationTypes("com.fhoster.livebase.CloudletSMSSender")
@SuppressWarnings("all")
public class CloudletSMSSenderAnnotationProcessor extends BlueprintAnnotationProcessor {
  public CloudletSMSSenderAnnotationProcessor(final UniqueIdGenerator generator) {
    super(generator);
  }
  
  @Override
  public void processAnnotatedClass(final Element e) {
    boolean _hasErrors = this.hasErrors(e);
    if (_hasErrors) {
      return;
    } else {
      this.generateBlueprintXML(e, "");
    }
  }
  
  private boolean hasErrors(final Element e) {
    final Function0 _function = () -> {
      return Boolean.valueOf(this.isClass(e));
    };
    CheckElse _check = this.check(e, _function);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("The @CloudletSMSSender annotation can only be used on classes, not interfaces  ");
    _check.orError(_builder.toString());
    final Function0 _function_1 = () -> {
      return Boolean.valueOf(this.isPublicClass(e));
    };
    CheckElse _check_1 = this.check(e, _function_1);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("The @CloudletSMSSender annotation can only be used on public classes.");
    _check_1.orError(_builder_1.toString());
    int _size = IterableExtensions.size(this.inectableConstructors(e));
    boolean _greaterThan = (_size > 0);
    if (_greaterThan) {
      final Function0 _function_2 = () -> {
        int _size_1 = IterableExtensions.size(this.inectableConstructors(e));
        return Boolean.valueOf((_size_1 == 1));
      };
      CheckElse _check_2 = this.check(e, _function_2);
      StringConcatenation _builder_2 = new StringConcatenation();
      _builder_2.append("Too many constructors found. A plugin must have at most one costructor or at most one public constructor");
      _check_2.orError(_builder_2.toString());
    }
    int _size_1 = this.interfaces(e).size();
    boolean _greaterThan_1 = (_size_1 > 1);
    if (_greaterThan_1) {
      this.error(e, "This class must implement one interface only. Refer to the Plugin docs for more information.");
      return true;
    }
    return false;
  }
  
  @Override
  public Class supportedAnnotation() {
    return CloudletSMSSender.class;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy