Package org.radargun.config

Examples of org.radargun.config.DefinitionElement


   protected static abstract class Base {
      protected final Map<String, Class<?>> classes = new HashMap<String, Class<?>>();

      protected Base(Class<?>[] classes) {
         for (Class<?> clazz : classes) {
            DefinitionElement de = clazz.getAnnotation(DefinitionElement.class);
            if (de == null) {
               throw new IllegalArgumentException(clazz.getName() + " missing @DefinitionElement");
            }
            if (this.classes.containsKey(de.name())) {
               throw new IllegalArgumentException("Trying to register " + clazz.getName() + " as '" + de.name()
                     + "' but this is already used by " + this.classes.get(de.name()));
            }
            this.classes.put(de.name(), clazz);
         }
      }
View Full Code Here


      }

      protected <T> Base(Class<T> implementedClass) {
         for (File file : Directories.LIB_DIR.listFiles(new Utils.JarFilenameFilter())) {
            for (Class<? extends T> clazz : AnnotatedHelper.getClassesFromJar(file.getPath(), implementedClass, DefinitionElement.class)) {
               DefinitionElement de = clazz.getAnnotation(DefinitionElement.class);
               if (this.classes.containsKey(de.name())) {
                  throw new IllegalArgumentException("Trying to register " + clazz.getName() + " as '" + de.name()
                        + "' but this is already used by " + this.classes.get(de.name()));
               }
               classes.put(de.name(), clazz);
            }
         }
      }
View Full Code Here

            ctor.setAccessible(true);
            item = ctor.newInstance();
         } catch (Exception e) {
            throw new IllegalArgumentException("Cannot instantiate " + clazz.getName(), e);
         }
         DefinitionElement de = clazz.getAnnotation(DefinitionElement.class);
         if (definition instanceof ComplexDefinition) {
            if (de.resolveType() == DefinitionElement.ResolveType.PASS_BY_MAP) {
               PropertyHelper.setPropertiesFromDefinitions(item, ((ComplexDefinition) definition).getAttributeMap(), false, true);
            } else if (de.resolveType() == DefinitionElement.ResolveType.PASS_BY_DEFINITION) {
               PropertyHelper.setPropertiesFromDefinitions(item, Collections.singletonMap("", definition), false, true);
            } else throw new IllegalStateException(de.resolveType().toString());
         } else if (definition instanceof SimpleDefinition) {
            PropertyHelper.setProperties(item, Collections.singletonMap("", ((SimpleDefinition) definition).value), false, true);
         }
         return item;
      }
View Full Code Here

      }

      @Override
      public String convertToString(Object value) {
         if (value == null) return "null";
         DefinitionElement de = value.getClass().getAnnotation(DefinitionElement.class);
         if (de == null) throw new IllegalArgumentException("Object does not have DefinitionElement attached: " + value);
         return String.format("%s -> %s", de.name(), value);
      }
View Full Code Here

         for (Object item : list) {
            if (!first) {
               sb.append(", ");
            }
            first = false;
            DefinitionElement de = item.getClass().getAnnotation(DefinitionElement.class);
            if (de != null) {
               sb.append(de.name()).append(" = ");
            }
            sb.append(String.valueOf(item));
         }
         return sb.append(" ]").toString();
      }
View Full Code Here

   private static abstract class Condition {
      public abstract void apply(Queryable.QueryBuilder builder);

      public String toString() {
         DefinitionElement de = getClass().getAnnotation(DefinitionElement.class);
         StringBuilder sb = new StringBuilder();
         if (de == null) sb.append(getClass().getSimpleName());
         else sb.append(de.name());
         return sb.append(PropertyHelper.toString(this)).toString();
      }
View Full Code Here

TOP

Related Classes of org.radargun.config.DefinitionElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.