List of usage examples for java.util List getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.obiba.magma.type.PolygonType.java
@Override public Class<?> getJavaClass() { List<List<Coordinate>> polygon; polygon = new ArrayList<List<Coordinate>>(); return polygon.getClass(); }
From source file:org.obiba.magma.type.PolygonType.java
@Override public boolean acceptsJavaClass(@Nonnull Class<?> clazz) { List<List<Coordinate>> polygon; polygon = new ArrayList<List<Coordinate>>(); return polygon.getClass().isAssignableFrom(clazz); }
From source file:com.adobe.acs.commons.util.impl.ReflectionUtilTest.java
@Test public void test_isArray() { List<Integer> integerList = Arrays.asList(1, 2); Integer[] integers = ReflectionUtil.toArray(integerList); assertFalse(isArray(integerList.getClass())); assertTrue(isArray(integers.getClass())); }
From source file:com.autentia.common.util.ClassWithList.java
private <T> void printInfo(List<T> list) throws SecurityException, NoSuchMethodException { final TypeVariable<?>[] types = list.getClass().getTypeParameters(); for (TypeVariable<?> clazz : types) { print(clazz);/*from ww w .j ava2 s . co m*/ // ParameterizedType pt = (ParameterizedType)clazz; // log.debug(clazz.getName() + " | " + clazz.getGenericDeclaration().getClass().getName()); // for (TypeVariable<?> type : clazz.getGenericDeclaration().getTypeParameters()) { ParameterizedType pt = (ParameterizedType) type; log.debug(type.getClass().getName()); } // // for (Type type : clazz.getBounds()) { // ParameterizedType pt = (ParameterizedType)type; // print(pt); // log.debug(pt.getOwnerType()); // log.debug(pt.getRawType()); // log.debug(pt.getActualTypeArguments()); // } } }
From source file:ch.admin.suis.msghandler.servlet.MonitorServlet.java
private void doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {/*w ww .j av a 2s . c o m*/ FilterClient filterClient = handleParam(request); List<DBLogEntry> dbLogEntries = filterClient.filter(mhContext.getLogService().getAllEntries()); response.getWriter().println(toJson(dbLogEntries, dbLogEntries.getClass())); response.setContentType(JSON); response.setStatus(HttpServletResponse.SC_OK); } catch (LogServiceException ex) { LOG.error(ex.getMessage(), ex); throw new ServletException(ex); } catch (MonitorException ex) { LOG.error("Unable to process the task: " + ex.getMessage(), ex); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); response.setContentType(TEXT); response.getWriter().println("Invalid request: " + ex.getMessage()); } catch (IOException ex) { LOG.fatal("MonitorServlet: " + ex.getMessage(), ex); throw ex; } }
From source file:com.bc.fiduceo.post.PostProcessingTool_IOTest.java
@Test public void testInitialisation() throws Exception { final Options options = PostProcessingTool.getOptions(); final PosixParser parser = new PosixParser(); final CommandLine commandLine = parser.parse(options, new String[] { "-j", processingConfigName, "-i", "/mmd_files", "-start", "2011-123", "-end", "2011-124", "-c", configDir.getPath() }); final FileWriter fileWriter = new FileWriter(new File(configDir, "system-config.xml")); fileWriter.write("<system-config></system-config>"); fileWriter.close();//from ww w . j a v a 2 s . c o m final PostProcessingContext context = PostProcessingTool.initializeContext(commandLine); final String separator = FileSystems.getDefault().getSeparator(); assertEquals(separator + "mmd_files", context.getMmdInputDirectory().toString()); assertEquals("03-May-2011 00:00:00", ProductData.UTC.createDateFormat().format(context.getStartDate())); assertEquals("04-May-2011 23:59:59", ProductData.UTC.createDateFormat().format(context.getEndDate())); final SystemConfig sysConfig = context.getSystemConfig(); assertNotNull(sysConfig); assertNull(sysConfig.getArchiveConfig()); final PostProcessingConfig config = context.getProcessingConfig(); assertNotNull(config); final List<Element> postProcessingElements = config.getPostProcessingElements(); assertNotNull(postProcessingElements); assertEquals("java.util.Collections$UnmodifiableList", postProcessingElements.getClass().getTypeName()); assertEquals(1, postProcessingElements.size()); assertEquals(TAG_NAME_SPHERICAL_DISTANCE, postProcessingElements.get(0).getName()); }
From source file:de.topicmapslab.kuria.runtime.util.TypeUtilTest.java
@SuppressWarnings("unchecked") @Test/* w w w . j a v a 2 s . c o m*/ public void testGetContainerType() { String[] tmp3 = new String[10]; assertEquals("Check String array: ", String.class, TypeUtil.getContainerType(tmp3.getClass())); String tmp4[] = new String[10]; assertEquals("Check String array: ", String.class, TypeUtil.getContainerType(tmp4.getClass())); try { Field field = TypeUtilTest.class.getDeclaredField("stringList"); assertEquals("Check List: ", String.class, TypeUtil.getContainerType(field.getGenericType())); assertTrue("Check Vector: ", TypeUtil.isList(field.getGenericType())); field = TypeUtilTest.class.getDeclaredField("stringList2"); assertEquals("Check ArrayListV: ", String.class, TypeUtil.getContainerType(field.getGenericType())); assertTrue("Check Vector: ", TypeUtil.isList(field.getGenericType())); field = TypeUtilTest.class.getDeclaredField("stringList3"); assertEquals("Check Vector: ", String.class, TypeUtil.getContainerType(field.getGenericType())); assertTrue("Check Vector: ", TypeUtil.isList(field.getGenericType())); field = TypeUtilTest.class.getDeclaredField("stack"); assertEquals("Check Stack: ", Object.class, TypeUtil.getContainerType(field.getGenericType())); field = TypeUtilTest.class.getDeclaredField("set1"); assertEquals("Check Sets Parameter: ", Integer.class, TypeUtil.getContainerType(field.getGenericType())); assertTrue("Check Set: ", TypeUtil.isSet(field.getGenericType())); field = TypeUtilTest.class.getDeclaredField("set2"); assertEquals("Check HashSet: ", Integer.class, TypeUtil.getContainerType(field.getGenericType())); assertTrue("Check HashSet: ", TypeUtil.isSet(field.getGenericType())); field = TypeUtilTest.class.getDeclaredField("set3"); assertEquals("Check untyped Set: ", Object.class, TypeUtil.getContainerType(field.getGenericType())); } catch (Exception e) { throw new RuntimeException(e); } // expecting object because no real reflection possible on var types. List<String> tmp = new ArrayList<String>(); assertEquals("Check ArrayList: ", Object.class, TypeUtil.getContainerType(tmp.getClass())); tmp = new ArrayStack(); assertEquals("Check ArrayList: ", Object.class, TypeUtil.getContainerType(tmp.getClass())); tmp = new Vector<String>(); assertEquals("Check ArrayList: ", Object.class, TypeUtil.getContainerType(tmp.getClass())); Set<Integer> tmp2 = new HashSet<Integer>(); assertEquals("Check HashSet: ", Object.class, TypeUtil.getContainerType(tmp2.getClass())); try { TypeUtil.getContainerType(String.class); } catch (IllegalArgumentException e) { return; } fail("No exception thrown"); }
From source file:com.seedboxer.seedboxer.sources.processors.RssConsumer.java
@SuppressWarnings("unchecked") @Override/*ww w . j av a 2 s . c o m*/ public void process(Exchange exchange) throws Exception { Message msg = exchange.getIn(); SyndFeed feed = (SyndFeed) msg.getBody(); List<SyndEntry> entries = feed.getEntries(); List<MatchableItem> items = new ArrayList<MatchableItem>(); LOGGER.debug("Incoming rss entries: {}", entries.size()); for (SyndEntry entry : entries) { items.add(new MatchableItem(entry.getTitle(), entry.getLink())); } exchange.getOut().setBody(items, items.getClass()); }
From source file:nl.flotsam.calendar.web.UriListHttpMessageConverterTest.java
@Test public void shouldParseXsltProducedCorrectly() throws IOException { Resource resource = new ClassPathResource("scala-tribes.ical"); UriListHttpMessageConverter converter = new UriListHttpMessageConverter(); List<URI> list = new ArrayList<URI>(); when(message.getHeaders()).thenReturn(headers); when(headers.getContentType()).thenReturn(MediaType.TEXT_PLAIN); when(message.getBody()).thenReturn(resource.getInputStream()); list = converter.read((Class<? extends List<URI>>) list.getClass(), message); assertThat(list.size(), is(8));//w w w . ja va2 s .co m }
From source file:com.lonepulse.zombielink.processor.SerializerEndpointTest.java
/** * <p>Test for {@link Serializers#JSON} with a generic type.</p> * //from www.j a va 2 s .c o m * @since 1.3.0 */ @Test public final void testSerializeGenericTypeToJson() throws ParseException, IOException { String subpath = "/jsonarray"; User user1 = new User(0, "Tenzen0", "Yakushiji0", 300, true); User user2 = new User(1, "Tenzen1", "Yakushiji1", 300, true); stubFor(put(urlEqualTo(subpath)).willReturn(aResponse().withStatus(200))); serializerEndpoint.serializeGenericTypeToJson(Arrays.asList(user1, user2)); List<User> users = Arrays.asList(user1, user2); verify(putRequestedFor(urlEqualTo(subpath)) .withRequestBody(equalTo(new Gson().toJson(users, users.getClass())))); }