List of usage examples for java.lang Class getCanonicalName
public String getCanonicalName()
From source file:de.highbyte_le.weberknecht.request.RequestWrapper.java
public <T extends Enum<T>> T getParameterAsEnum(String name, Class<T> enumType, T defaultValue) { T retVal = defaultValue;//from w ww.j a va2s.c o m String val = getParameter(name); try { if (val != null) { retVal = Enum.valueOf(enumType, val); } } catch (IllegalArgumentException e) { logger.debug("getParameterAsEnum() - " + "invalid enum value '" + val + "' for parameter " + name + " and type " + enumType.getCanonicalName()); } return retVal; }
From source file:com.netspective.medigy.model.data.EntitySeedDataPopulator.java
public void populateSeedData() throws HibernateException { com.netspective.medigy.model.session.Session session = new ProcessSession(); session.setProcessName(EntitySeedDataPopulator.class.getName()); HibernateUtil.beginTransaction();// w w w. j a va 2 s .co m HibernateUtil.getSession().save(session); SessionManager.getInstance().pushActiveSession(session); if (log.isInfoEnabled()) log.info("Initializing with seed data"); globalParty = new Party(Party.SYS_GLOBAL_PARTY_NAME); HibernateUtil.getSession().save(globalParty); for (final Map.Entry<Class, Class> entry : configuration.getCustomReferenceEntitiesAndCachesMap() .entrySet()) { final Class aClass = entry.getKey(); CachedCustomReferenceEntity[] cachedEntities = (CachedCustomReferenceEntity[]) entry.getValue() .getEnumConstants(); Object[][] data = new Object[cachedEntities.length][3]; int i = 0; for (final CachedCustomReferenceEntity c : cachedEntities) { data[i][0] = c.getCode(); data[i][1] = c.getCode(); // LABEL data[i][2] = globalParty; i++; } if (log.isInfoEnabled()) log.info(aClass.getCanonicalName() + " cached enums addded."); populateEntity(HibernateUtil.getSession(), aClass, new String[] { "code", "label", "party" }, data); } HibernateUtil.commitTransaction(); SessionManager.getInstance().popActiveSession(); }
From source file:com.haulmont.cuba.web.gui.components.WebPickerField.java
@Override public void setValue(Object value) { if (value != null) { if (datasource == null && metaClass == null) { throw new IllegalStateException("Datasource or metaclass must be set for field"); }// w ww . ja v a2s . c o m Class fieldClass = getMetaClass().getJavaClass(); Class<?> valueClass = value.getClass(); if (!fieldClass.isAssignableFrom(valueClass)) { throw new IllegalArgumentException( String.format("Could not set value with class %s to field with class %s", fieldClass.getCanonicalName(), valueClass.getCanonicalName())); } } super.setValue(value); }
From source file:jobhunter.api.infojobs.Client.java
public <T> Optional<T> get(Class<T> clazz, String url) throws InfoJobsAPIException { HttpGet httpGet = new HttpGet(url); try (CloseableHttpClient client = HttpClients.custom().setDefaultCredentialsProvider(provider).build()) { try (CloseableHttpResponse response = client.execute(httpGet)) { if (response.getStatusLine().getStatusCode() == 200) { T entity = mapper.readValue(response.getEntity().getContent(), clazz); return Optional.of(entity); } else { Error error = mapper.readValue(response.getEntity().getContent(), Error.class); throw new InfoJobsAPIException(error); }//from ww w.j a v a2 s. co m } } catch (IOException e) { l.error("Failed to GET {} from {}", clazz.getCanonicalName(), url, e); throw new InfoJobsAPIException(e.getLocalizedMessage()); } }
From source file:at.treedb.backup.Export.java
/** * Full backup of the complete database. * /* w w w .java 2 s. co m*/ * @throws Exception */ public void backup() throws Exception { initBackup(BACKUP_TYPE.FULL, null); try { dbInfo.setStartTime(); if (dao.isHibernate()) { ((DAOhibernate) dao).beginStatelessTransaction(); } else { dao.beginTransaction(); } for (Class<?> c : DBentities.getClasses()) { if (isIgnoreClass(c)) { continue; } System.out.println(c.getCanonicalName()); dumpClass(dbInfo, c, null, BACKUP_TYPE.FULL); } dao.endTransaction(); if (xstream == null) { xstream = new XStream(); } dbInfo.setEndTime(); write("dbinfo.xml", xstream.toXML(dbInfo), date); } catch (Exception e) { dao.rollback(); sevenZOutput.close(); archive.delete(); throw e; } sevenZOutput.close(); }
From source file:capital.scalable.restdocs.javadoc.JavadocReaderImpl.java
private ClassJavadoc readFiles(Class<?> clazz, String relativePath) { if (absoluteBaseDirs.isEmpty()) { // No absolute directory is configured and thus we try to find the file relative. ClassJavadoc classJavadoc = readFile(new File(relativePath)); if (classJavadoc != null) { return classJavadoc; }// w w w . j av a 2s . co m } else { // Try to find the file in all configured directories. for (File dir : absoluteBaseDirs) { ClassJavadoc classJavadoc = readFile(new File(dir, relativePath)); if (classJavadoc != null) { return classJavadoc; } } } log.warn("No Javadoc found for class {}", clazz.getCanonicalName()); return new ClassJavadoc(); }
From source file:play.modules.swagger.PlayReader.java
public String getFullMethodName(Class clazz, Method method) { if (!clazz.getCanonicalName().contains("$")) { return clazz.getCanonicalName() + "$." + method.getName(); } else {//w w w .j a v a 2 s.c o m return clazz.getCanonicalName() + "." + method.getName(); } }
From source file:com.medigy.persist.model.data.EntitySeedDataPopulator.java
public void populateSeedData() throws HibernateException { com.medigy.persist.model.session.Session processSession = new ProcessSession(); processSession.setProcessName(EntitySeedDataPopulator.class.getName()); if (!useEjb)//from w w w . j ava2s.co m session.save(processSession); else entityManager.persist(processSession); SessionManager.getInstance().pushActiveSession(processSession); if (log.isInfoEnabled()) log.info("Initializing with seed data"); globalParty = new Party(Party.SYS_GLOBAL_PARTY_NAME); if (!useEjb) session.save(globalParty); else entityManager.persist(globalParty); final Map<Class, Class<? extends CachedReferenceEntity>> referenceEntitiesAndCachesMap = HibernateUtil .getReferenceEntitiesAndRespectiveEnums(configuration); for (final Map.Entry<Class, Class<? extends CachedReferenceEntity>> entry : referenceEntitiesAndCachesMap .entrySet()) { final Class aClass = entry.getKey(); CachedReferenceEntity[] cachedEntities = (CachedReferenceEntity[]) entry.getValue().getEnumConstants(); Object[][] data = new Object[cachedEntities.length][2]; int i = 0; for (final CachedReferenceEntity c : cachedEntities) { data[i][0] = c.getCode(); data[i][1] = c.getLabel(); // LABEL i++; } if (log.isInfoEnabled()) log.info(aClass.getCanonicalName() + " cached enums addded."); populateCachedReferenceEntities(aClass, cachedEntities, new String[] { "code", "label" }, data); } final Map<Class, Class<? extends CachedCustomReferenceEntity>> customReferenceEntitiesAndCachesMap = HibernateUtil .getCustomReferenceEntitiesAndRespectiveEnums(configuration); for (final Map.Entry<Class, Class<? extends CachedCustomReferenceEntity>> entry : customReferenceEntitiesAndCachesMap .entrySet()) { final Class aClass = entry.getKey(); CachedCustomReferenceEntity[] cachedEntities = (CachedCustomReferenceEntity[]) entry.getValue() .getEnumConstants(); Object[][] data = new Object[cachedEntities.length][4]; int i = 0; for (final CachedCustomReferenceEntity c : cachedEntities) { data[i][0] = c.getCode(); data[i][1] = c.getLabel(); // LABEL data[i][2] = globalParty; if (c instanceof CachedCustomHierarchyReferenceEntity) data[i][3] = ((CachedCustomHierarchyReferenceEntity) c).getParent(); else data[i][3] = null; i++; } if (log.isInfoEnabled()) log.info(aClass.getCanonicalName() + " cached custom enums addded."); populateCachedCustomReferenceEntities(aClass, cachedEntities, new String[] { "code", "label", "party", "parentEntity" }, data); } //loadExternalReferenceData(); //populateEntityCacheData(); //HibernateUtil.commitTransaction(); SessionManager.getInstance().popActiveSession(); }
From source file:com.vaadin.spring.navigator.SpringViewProvider.java
private boolean isViewBeanNameValidForCurrentUI(String beanName) { try {/*from w ww . j a v a 2s . c o m*/ final Class<?> type = applicationContext.getType(beanName); Assert.isAssignable(View.class, type, "bean did not implement View interface"); final UI currentUI = UI.getCurrent(); final SpringView annotation = applicationContext.findAnnotationOnBean(beanName, SpringView.class); Assert.notNull(annotation, "class did not have a SpringView annotation"); if (annotation.ui().length == 0) { LOGGER.trace("View class [{}] with view name [{}] is available for all UI subclasses", type.getCanonicalName(), getViewNameFromAnnotation(type, annotation)); } else { Class<? extends UI> validUI = getValidUIClass(currentUI, annotation.ui()); if (validUI != null) { LOGGER.trace("View class [%s] with view name [{}] is available for UI subclass [{}]", type.getCanonicalName(), getViewNameFromAnnotation(type, annotation), validUI.getCanonicalName()); } else { return false; } } return true; } catch (NoSuchBeanDefinitionException ex) { return false; } }