Example usage for java.lang Class getSimpleName

List of usage examples for java.lang Class getSimpleName

Introduction

In this page you can find the example usage for java.lang Class getSimpleName.

Prototype

public String getSimpleName() 

Source Link

Document

Returns the simple name of the underlying class as given in the source code.

Usage

From source file:com.joliciel.talismane.posTagger.filters.PosTagFilterServiceImpl.java

@Override
public PosTagSequenceFilter getPosTagSequenceFilter(String descriptor) {
    PosTagSequenceFilter filter = null;//from   ww w  .  java  2s . com
    List<Class<? extends PosTagSequenceFilter>> classes = new ArrayList<Class<? extends PosTagSequenceFilter>>();
    classes.add(RemoveNullEmptyTokensFilter.class);

    for (Class<? extends PosTagSequenceFilter> clazz : classes) {
        if (descriptor.equals(clazz.getSimpleName())) {
            try {
                filter = clazz.newInstance();
            } catch (InstantiationException e) {
                LogUtils.logError(LOG, e);
                throw new RuntimeException(e);
            } catch (IllegalAccessException e) {
                LogUtils.logError(LOG, e);
                throw new RuntimeException(e);
            }
        }
    }

    if (filter == null) {
        throw new TalismaneException("Unknown PosTagSequenceFilter: " + descriptor);
    }

    return filter;
}

From source file:app.web.AbstractCrudController.java

@RequestMapping(value = { "/create", "/edit" }, method = RequestMethod.POST)
public String sendForm(@Valid final T form, BindingResult bindingResult) {
    if (bindingResult.hasErrors()) {
        Class<T> clazz = getTypeClass();
        return clazz.getSimpleName().toLowerCase() + "/form"; // stay on the same view so we can display the validation errors
    }/* ww  w  .j  av a  2  s.  co m*/
    if (form.isPersistent()) {
        new TransactionTemplate(transactionManager).execute(new TransactionCallbackWithoutResult() {
            protected void doInTransactionWithoutResult(TransactionStatus transactionStatus) {
                form.update();
            }
        });
    } else {
        form.save(); // no need for a transaction?
    }
    // FIXME: find out why the item must be called "form"
    return "redirect:.";
}

From source file:de.openknowledge.cdi.monitoring.ComponentStatus.java

public ComponentStatus(Class aClazz, String aStatusMessage, Throwable t) {
    this(aClazz.getSimpleName(), aStatusMessage, t);
}

From source file:cherry.foundation.sql.SqlLoaderImpl.java

@Override
public Map<String, String> load(Class<?> klass) throws IOException {
    String name = klass.getSimpleName() + extension;
    try (InputStream in = klass.getResourceAsStream(name)) {
        return load(in);
    }// w  w w. j a  va2 s .co  m
}

From source file:springfox.documentation.spring.web.scanners.ApiListingReader.java

@Override
public void apply(ApiListingContext apiListingContext) {
    Class<?> controllerClass = apiListingContext.getResourceGroup().getControllerClass();
    String description = splitCamelCase(controllerClass.getSimpleName(), " ");

    apiListingContext.apiListingBuilder().description(description);
}

From source file:springfox.documentation.spring.web.SpringGroupingStrategy.java

private Set<ResourceGroup> groups(HandlerMethod handlerMethod) {
    Class<?> controllerClazz = handlerMethod.getBeanType();
    String controllerAsGroup = splitCamelCase(controllerClazz.getSimpleName(), "-").toLowerCase();
    return newHashSet(new ResourceGroup(controllerAsGroup, controllerClazz));
}

From source file:cn.org.awcp.core.mybatis.mapper.EntityHelper.java

/**
 * ?//from   ww w.j av  a 2s  .c  om
 * 
 * @param entityClass
 */
public static synchronized void initEntityNameMap(Class<?> entityClass) {
    if (entityTableMap.get(entityClass) != null) {
        return;
    }
    // ??
    EntityTable entityTable = null;
    if (entityClass.isAnnotationPresent(Table.class)) {
        Table table = entityClass.getAnnotation(Table.class);
        if (!table.name().equals("")) {
            entityTable = new EntityTable();
            entityTable.setTable(table);
        }
    }
    if (entityTable == null) {
        entityTable = new EntityTable();
        entityTable.name = camelhumpToUnderline(entityClass.getSimpleName()).toUpperCase();
    }
    entityTableMap.put(entityClass, entityTable);
    // 
    List<Field> fieldList = getAllField(entityClass, null);
    List<EntityColumn> columnList = new ArrayList<EntityColumn>();
    List<EntityColumn> pkColumnList = new ArrayList<EntityColumn>();
    List<EntityColumn> obColumnList = new ArrayList<EntityColumn>();

    for (Field field : fieldList) {
        // 
        if (field.isAnnotationPresent(Transient.class)) {
            continue;
        }
        EntityColumn entityColumn = new EntityColumn();
        if (field.isAnnotationPresent(Id.class)) {
            entityColumn.setId(true);
        }
        if (field.isAnnotationPresent(OrderBy.class)) {
            OrderBy orderBy = field.getAnnotation(OrderBy.class);
            if (StringUtils.isNotBlank(orderBy.value()) && orderBy.value().equalsIgnoreCase("desc")) {
                entityColumn.setOrderBy(OrderByEnum.DESC);
            } else {
                entityColumn.setOrderBy(OrderByEnum.ASC);
            }
        }
        String columnName = null;
        if (field.isAnnotationPresent(Column.class)) {
            Column column = field.getAnnotation(Column.class);
            columnName = column.name();
        }
        if (columnName == null || columnName.equals("")) {
            columnName = camelhumpToUnderline(field.getName());
        }
        entityColumn.setProperty(field.getName());
        entityColumn.setColumn(columnName.toUpperCase());
        entityColumn.setJavaType(field.getType());
        //  - Oracle?MySqlUUID
        if (field.isAnnotationPresent(SequenceGenerator.class)) {
            SequenceGenerator sequenceGenerator = field.getAnnotation(SequenceGenerator.class);
            if (sequenceGenerator.sequenceName().equals("")) {
                throw new RuntimeException(entityClass + "" + field.getName()
                        + "@SequenceGeneratorsequenceName!");
            }
            entityColumn.setSequenceName(sequenceGenerator.sequenceName());
        } else if (field.isAnnotationPresent(GeneratedValue.class)) {
            GeneratedValue generatedValue = field.getAnnotation(GeneratedValue.class);
            if (generatedValue.generator().equals("UUID")) {
                if (field.getType().equals(String.class)) {
                    entityColumn.setUuid(true);
                } else {
                    throw new RuntimeException(field.getName()
                            + " - @GeneratedValue?UUID?String");
                }
            } else if (generatedValue.generator().equals("JDBC")) {
                if (Number.class.isAssignableFrom(field.getType())) {
                    entityColumn.setIdentity(true);
                    entityColumn.setGenerator("JDBC");
                } else {
                    throw new RuntimeException(field.getName()
                            + " - @GeneratedValue?UUID?String");
                }
            } else {
                // ?generator??idsql,mysql=CALL
                // IDENTITY(),hsqldb=SELECT SCOPE_IDENTITY()
                // ??generator
                if (generatedValue.strategy() == GenerationType.IDENTITY) {
                    // mysql
                    entityColumn.setIdentity(true);
                    if (!generatedValue.generator().equals("")) {
                        String generator = null;
                        MapperHelper.IdentityDialect identityDialect = MapperHelper.IdentityDialect
                                .getDatabaseDialect(generatedValue.generator());
                        if (identityDialect != null) {
                            generator = identityDialect.getIdentityRetrievalStatement();
                        } else {
                            generator = generatedValue.generator();
                        }
                        entityColumn.setGenerator(generator);
                    }
                } else {
                    throw new RuntimeException(field.getName()
                            + " - @GeneratedValue?????:"
                            + "\n1.?@GeneratedValue(generator=\"UUID\")"
                            + "\n2.useGeneratedKeys@GeneratedValue(generator=\\\"JDBC\\\")  "
                            + "\n3.mysql?@GeneratedValue(strategy=GenerationType.IDENTITY[,generator=\"Mysql\"])");
                }
            }
        }
        columnList.add(entityColumn);
        if (entityColumn.isId()) {
            pkColumnList.add(entityColumn);
        }
        if (entityColumn.getOrderBy() != null) {
            obColumnList.add(entityColumn);
        }
    }
    if (pkColumnList.size() == 0) {
        pkColumnList = columnList;
    }
    entityClassColumns.put(entityClass, columnList);
    entityClassPKColumns.put(entityClass, pkColumnList);
    entityOrderByColumns.put(entityClass, obColumnList);
}

From source file:org.apache.streams.data.data.util.ActivitySerDeTest.java

/**
 * Tests that defined activity verbs have an example which can be loaded into
 * Activity beans and into verb-specific beans
 * @throws Exception//from   w w  w.  j a v  a  2s.  co m
 */
@Test
public void testVerbSerDe() throws Exception {

    Reflections reflections = new Reflections(
            new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.apache.streams.pojo.json"))
                    .setScanners(new SubTypesScanner()));
    Set<Class<? extends Activity>> verbs = reflections.getSubTypesOf(Activity.class);

    for (Class verbClass : verbs) {
        LOGGER.info("Verb: " + verbClass.getSimpleName());
        Activity activity = (Activity) verbClass.newInstance();
        String verbName = activity.getVerb();
        String testfile = verbName.toLowerCase() + ".json";
        LOGGER.info("Serializing: activities/" + testfile);
        assert (ActivitySerDeTest.class.getClassLoader().getResource("activities/" + testfile) != null);
        InputStream testActivityFileStream = ActivitySerDeTest.class.getClassLoader()
                .getResourceAsStream("activities/" + testfile);
        assert (testActivityFileStream != null);
        activity = MAPPER.convertValue(MAPPER.readValue(testActivityFileStream, verbClass), Activity.class);
        String activityString = MAPPER.writeValueAsString(activity);
        LOGGER.info("Deserialized: " + activityString);
    }
}

From source file:com.expressui.core.dao.ReferenceEntityDao.java

/**
 * Finds all reference entities of given type ordered by com.expressui.core.entity.ReferenceEntity.ORDER_BY_PROPERTY
 * and com.expressui.core.entity.ReferenceEntity.DISPLAY_PROPERTY.
 *
 * @param entityType type of entity// w w  w . ja va 2s.c o m
 * @param <T>        type of entity
 * @return all reference entities
 */
@Override
public <T> List<T> findAll(Class<? extends T> entityType) {
    Query query = getEntityManager().createQuery("SELECT e FROM " + entityType.getSimpleName() + " e"
            + " ORDER BY e." + ReferenceEntity.ORDER_BY_PROPERTY + ", e." + ReferenceEntity.DISPLAY_PROPERTY);

    setReadOnly(query);

    return query.getResultList();
}