Java Class.getSimpleName Examples

Java Class.getSimpleName - 30 examples found. These are the top rated real world Java examples of Class.getSimpleName extracted from open source projects. You can rate examples to help us improve the quality of examples.
 public static <T extends LanguageSourceSet> T create(
     Class<? extends LanguageSourceSet> publicType,
     Class<T> type,
     String name,
     String parentName,
     FileResolver fileResolver) {
   if (type.equals(BaseLanguageSourceSet.class)) {
     throw new ModelInstantiationException(
         "Cannot create instance of abstract class BaseLanguageSourceSet.");
   }
   nextSourceSetInfo.set(
       new SourceSetInfo(name, parentName, publicType.getSimpleName(), fileResolver));
   try {
     try {
       return DirectInstantiator.INSTANCE.newInstance(type);
     } catch (ObjectInstantiationException e) {
       throw new ModelInstantiationException(
           String.format(
               "Could not create LanguageSourceSet of type %s", publicType.getSimpleName()),
           e.getCause());
     }
   } finally {
     nextSourceSetInfo.set(null);
   }
 }
 @Test
 public void should_generate_assertion_for_classes_in_package_using_provided_class_loader()
     throws Exception {
   ClassLoader customClassLoader =
       new MyClassLoader(Thread.currentThread().getContextClassLoader());
   Set<Class<?>> classes =
       collectClasses(customClassLoader, "org.assertj.assertions.generator.data");
   for (Class<?> clazz : classes) {
     assertThat(clazz.isAnonymousClass())
         .as("check that " + clazz.getSimpleName() + " is not anonymous")
         .isFalse();
     assertThat(clazz.isLocalClass())
         .as("check that " + clazz.getSimpleName() + " is not local")
         .isFalse();
     assertThat(isPublic(clazz.getModifiers()))
         .as("check that " + clazz.getSimpleName() + " is public")
         .isTrue();
     logger.info("Generating assertions for {}", clazz.getName());
     final ClassDescription classDescription = converter.convertToClassDescription(clazz);
     File customAssertionFile = assertionGenerator.generateCustomAssertionFor(classDescription);
     logger.info(
         "Generated {} assertions file -> {}",
         clazz.getSimpleName(),
         customAssertionFile.getAbsolutePath());
   }
 }
Example #3
0
  /*
   * Important! must return id in callback.
   */
  @SuppressWarnings("unchecked")
  public <T extends Serializable> void Walk(Class<T> type, Callback<T, Integer> callback) {
    int limit = 365;
    int count = 0;
    int nStartId = -1;

    List<T> models = null;
    while (true) {
      StringBuilder sb = new StringBuilder();
      sb.append("select m from ").append(type.getSimpleName()).append(" m");
      sb.append(" where m.id > :id order by m.id asc");
      Query query = entityManager.createQuery(sb.toString());
      query.setMaxResults(limit); // safe option.
      query.setParameter("id", nStartId);
      models = query.getResultList();

      if (null != models && models.size() > 0) {
        for (T model : models) {
          nStartId = callback.execute(model);

          // progress reporter
          if (count++ % 10000 == 0) {
            if (logger.isInfoEnabled()) {
              logger.info(String.format("walk %s, %d", type.getSimpleName(), count));
            }
          }
        }
      } else {
        break;
      }
    }
    models = null;
  }
Example #4
0
 private static String aOrAn(Class aClass) {
   if (aClass == int.class || aClass == Integer.class) {
     return "an " + aClass.getSimpleName();
   } else {
     return "a " + aClass.getSimpleName();
   }
 }
Example #5
0
  public void moveToShape(Collection<ShapeInArea> des, Class<? extends MoveType> type)
      throws SOSActionException {

    if (!(me.me() instanceof Human)) {
      log().warn("can't use move in Center Agent " + me + "\n");
      return;
    }
    try {
      checkTraffic(); // TODO uncomment
      MoveType mt = moves.get(type.hashCode());
      if (mt != null) {
        Path path = mt.getPathToShape(des);
        log().debug("MOVE " + type.getSimpleName() + "\nTO : " + path + "\n");
        move(path);
      } else log().error(new Error("in move can not found type=" + type.getSimpleName()));

    } catch (SOSActionException e) {
      throw e;
    } catch (Exception er) {
      log().error(er);
      log().warn("using bfs for finding path");
      ArrayList<Area> goals = new ArrayList<Area>();

      for (ShapeInArea shapeInArea : des) {
        goals.add(shapeInArea.getArea(me.model()));
      }
      move(bfs.breadthFirstSearch((Area) me.location(), goals));
    }
    log().error("in move can not found type=" + type.getSimpleName());
    me.problemRest("in move can not found type=" + type.getSimpleName());
  }
 /**
  * Helper method to Perform Reflection to Get Static Field of Provided Type. Field is assumed
  * Private.
  *
  * @param fieldName
  * @param type
  * @return
  */
 public static <T> T getFieldFromReflection(
     String fieldName, Class<?> containingClass, Class<T> type) {
   try {
     Field desiredField = containingClass.getDeclaredField(fieldName);
     desiredField.setAccessible(true);
     return type.cast(desiredField.get(null));
   } catch (NoSuchFieldException e) {
     JASLog.log()
         .severe(
             "Obfuscation needs to be updated to access the %s %s. Please notify modmaker Immediately.",
             fieldName, type.getSimpleName());
     e.printStackTrace();
   } catch (IllegalArgumentException e) {
     JASLog.log()
         .severe(
             "Obfuscation needs to be updated to access the %s %s. Please notify modmaker Immediately.",
             fieldName, type.getSimpleName());
     e.printStackTrace();
   } catch (IllegalAccessException e) {
     JASLog.log()
         .severe(
             "Obfuscation needs to be updated to access the %s %s. Please notify modmaker Immediately.",
             fieldName, type.getSimpleName());
     e.printStackTrace();
   } catch (SecurityException e) {
     JASLog.log()
         .severe(
             "Obfuscation needs to be updated to access the %s %s. Please notify modmaker Immediately.",
             fieldName, type.getSimpleName());
     e.printStackTrace();
   }
   return null;
 }