AbstractBeanMatchersAutomatedExtension.java

  1. /**
  2.  * Powerunit - A JDK1.8 test framework
  3.  * Copyright (C) 2014 Mathieu Boretti.
  4.  *
  5.  * This file is part of Powerunit
  6.  *
  7.  * Powerunit is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation, either version 3 of the License, or
  10.  * (at your option) any later version.
  11.  *
  12.  * Powerunit is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with Powerunit. If not, see <http://www.gnu.org/licenses/>.
  19.  */
  20. package ch.powerunit.extensions.matchers.provideprocessor.extension.beanmatchers;

  21. import java.util.Collection;
  22. import java.util.Collections;
  23. import java.util.function.Supplier;

  24. import ch.powerunit.extensions.matchers.provideprocessor.ProvidesMatchersAnnotatedElementData;
  25. import ch.powerunit.extensions.matchers.provideprocessor.RoundMirror;
  26. import ch.powerunit.extensions.matchers.provideprocessor.dsl.DSLMethod;
  27. import ch.powerunit.extensions.matchers.provideprocessor.extension.AutomatedExtension;
  28. import ch.powerunit.extensions.matchers.provideprocessor.fields.AbstractFieldDescription;
  29. import ch.powerunit.extensions.matchers.provideprocessor.fields.FieldDSLMethod;

  30. /**
  31.  * @author borettim
  32.  *
  33.  */
  34. public abstract class AbstractBeanMatchersAutomatedExtension extends AutomatedExtension {

  35.     public AbstractBeanMatchersAutomatedExtension(RoundMirror roundMirror) {
  36.         super(roundMirror, "com.google.code.beanmatchers.BeanMatchers");
  37.     }

  38.     protected abstract Collection<FieldDSLMethod> acceptBeanMatchers(AbstractFieldDescription field);

  39.     /*
  40.      * (non-Javadoc)
  41.      *
  42.      * @see ch.powerunit.extensions.matchers.provideprocessor.extension.
  43.      * AutomatedExtension#accept(ch.powerunit.extensions.matchers.
  44.      * provideprocessor.fields.FieldDescriptionMetaData)
  45.      */
  46.     @Override
  47.     public final Collection<FieldDSLMethod> accept(AbstractFieldDescription field) {
  48.         if (!field.getFieldType().matches("^java.lang.Class.*$")) {
  49.             return Collections.emptyList();
  50.         }
  51.         return acceptBeanMatchers(field);
  52.     }

  53.     /*
  54.      * (non-Javadoc)
  55.      *
  56.      * @see ch.powerunit.extensions.matchers.provideprocessor.extension.
  57.      * AutomatedExtension#accept(ch.powerunit.extensions.matchers.
  58.      * provideprocessor.ProvidesMatchersAnnotatedElementData)
  59.      */
  60.     @Override
  61.     public final Collection<Supplier<DSLMethod>> accept(ProvidesMatchersAnnotatedElementData clazz) {
  62.         return Collections.emptyList();
  63.     }

  64. }