Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright [2013] [www.rapidpm.org / Sven Ruppert (sven.ruppert@rapidpm.org)]
   *
   *    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 org.rapidpm.data.table.converter.fromtable.checks;
 
 import java.util.List;
 import java.util.Map;
 
Sven Ruppert User: svenruppert Date: 12/6/10 Time: 1:14 PM This is part of the PrometaJava project please contact chef@sven-ruppert.de
 
 public class CheckRegistry {
     private static final Logger logger = Logger.getLogger(CheckRegistry.class);
 
     private static final List<StringpkgNameList = new ArrayList<>();
     private static final Map<ClassList<Class<? extends Check>>> checkRequiredMap = new HashMap<>();
     private static final Map<ClassList<Class<? extends Check>>> checkOptionalMap = new HashMap<>();
 
 
     //JIRA MOD-19 Registry generisch implementieren. 1to1 Registry und 1toN Registry
     static {
         .add("org.rapidpm.data.table.converter.fromtable.checks");   //JIRA MOD-20 pkgNameList refactoring gestallten
         final PackageClassLoader packageClassLoader = new PackageClassLoader();
         for (final String packageName : ) {
 
             final List<Classclasses = packageClassLoader.getClasses(packageName);
             for (final Class aClass : classes) {
                 final Annotation annotationReq = aClass.getAnnotation(RequiredRule.class);
                 if (annotationReq != null) {
                     final RequiredRule responsibleFor = (RequiredRuleannotationReq;
                     final Class classResponsibleFor = responsibleFor.value();
                     if (.containsKey(classResponsibleFor)) {
                         final List<Class<? extends Check>> classList = .get(classResponsibleFor);
                         classList.add(aClass);
                         .put(classResponsibleForclassList);
                     } else {
                         final List<Class<? extends Check>> classList = new ArrayList<>();
                         classList.add(aClass);
                         .put(classResponsibleForclassList);
                     }
                 } else {
                     if (.isDebugEnabled()) {
                         .debug("Class ohne Req-Annotation " + aClass.getSimpleName());
                     }
                 }
 
                 final Annotation annotationOpt = aClass.getAnnotation(OptionalRule.class);
                 if (annotationReq != null) {
                     final OptionalRule responsibleFor = (OptionalRuleannotationReq;
                     final Class classResponsibleFor = responsibleFor.value();
                     if (.containsKey(classResponsibleFor)) {
                         final List<Class<? extends Check>> classList = .get(classResponsibleFor);
                         classList.add(aClass);
                         .put(classResponsibleForclassList);
                     } else {
                         final List<Class<? extends Check>> classList = new ArrayList<>();
                         classList.add(aClass);
                         .put(classResponsibleForclassList);
                     }
                 } else {
                     if (.isDebugEnabled()) {
                         .debug("Class ohne Opt-Annotation " + aClass.getSimpleName());
                     }
                 }
             }
         }
 
 
     }
 
     public static List<CheckgetRequiredChecksFor(final Class clazz) {
         final List<Checkresult = new ArrayList<>();
         if (clazz != null) {
             final boolean b = .containsKey(clazz);
            if (b) {
                try {
                    final List<Class<? extends Check>> classList = .get(clazz);
                    for (final Class<? extends CheckaClass : classList) {
                        final Check check = aClass.newInstance();
                        result.add(check);
                    }
                } catch (InstantiationException | IllegalAccessException e) {
                    .error(e);
                }
            } else {
                .error("Kein Checks für diese Klasse registriert.." + clazz.getSimpleName());
            }
        } else {
            if (.isDebugEnabled()) {
                .debug("keine Checks registriert f " + clazz.getName());
            }
        }
        return result;
    }
    public static List<CheckgetOptionalChecksFor(final Class clazz) {
        final List<Checkresult = new ArrayList<>();
        if (clazz != null) {
            final boolean b = .containsKey(clazz);
            if (b) {
                try {
                    final List<Class<? extends Check>> classList = .get(clazz);
                    for (final Class<? extends CheckaClass : classList) {
                        final Check check = aClass.newInstance();
                        result.add(check);
                    }
                } catch (InstantiationException | IllegalAccessException e) {
                    .error(e);
                }
            } else {
                .error("Kein Checks für diese Klasse registriert.." + clazz.getSimpleName());
            }
        } else {
            if (.isDebugEnabled()) {
                .debug("keine Checks registriert f " + clazz.getName());
            }
        }
        return result;
    }
New to GrepCode? Check out our FAQ X