/**
   * @param program
   * @param name
   * @return true - if the program has a class name already
   */
  public static boolean classNameAlreadyExists(Program program, final String name) {
    assert program != null && name != null;

    final ClassSearcher checkClassVisitor = new ClassSearcher(name);
    program.accept(checkClassVisitor);

    return checkClassVisitor.classNameAlreadyExists();
  }
Esempio n. 2
0
 @SuppressWarnings({"rawtypes", "unchecked"})
 @Override
 public boolean start() {
   try {
     List<Class> modelClasses = ClassSearcher.findClasses(Model.class);
     TableBind tb = null;
     for (Class modelClass : modelClasses) {
       tb = (TableBind) modelClass.getAnnotation(TableBind.class);
       if (tb == null) {
         this.addMapping(tableName(modelClass), modelClass);
       } else {
         if (StringKit.notBlank(tb.name())) {
           if (StringKit.notBlank(tb.pk())) {
             this.addMapping(tb.name(), tb.pk(), modelClass);
           } else {
             this.addMapping(tb.name(), modelClass);
           }
         }
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
     //			throw new RuntimeException(e);
   }
   return super.start();
 }