List of usage examples for java.lang Class getName
public String getName()
From source file:net.iponweb.hadoop.streaming.parquet.ParquetAsTextOutputFormat.java
private static CompressionCodecName getCodec(JobConf conf) { CompressionCodecName codec;//from w w w .j ava 2 s. co m if (ParquetOutputFormat.isCompressionSet(conf)) { // explicit parquet config codec = ParquetOutputFormat.getCompression(conf); } else if (getCompressOutput(conf)) { // from hadoop config // find the right codec Class<?> codecClass = getOutputCompressorClass(conf, DefaultCodec.class); LOG.info("Compression set through hadoop codec: " + codecClass.getName()); codec = CompressionCodecName.fromCompressionCodec(codecClass); } else { codec = CompressionCodecName.UNCOMPRESSED; } LOG.info("Compression: " + codec.name()); return codec; }
From source file:org.echocat.jemoni.jmx.support.SpringUtils.java
@Nonnull private static String buildMessageFor(@Nonnull Class<?> fromType, boolean expectedStatic, @Nonnull Class<?> returnType, @Nonnull String name, @Nullable Class<?>[] parameterTypes) { return "Could not find method " + (expectedStatic ? "static " : " ") + returnType.getName() + " public " + fromType.getName() + "." + name + "(" + join(parameterTypes) + ")."; }
From source file:io.fabric8.spring.boot.AbstractServiceRegistar.java
private static String createAlias(String name, Class type, String protocol, String port, Boolean external) { StringBuilder sb = new StringBuilder(); sb.append(type.getName()).append("-").append(name); if (Strings.isNotBlank(protocol)) { sb.append("-").append(protocol); }//w ww . j a v a 2s . co m if (Strings.isNotBlank(port)) { sb.append("-").append(port); } if (external) { sb.append("-external"); } return sb.toString(); }
From source file:co.cask.cdap.client.rest.TestUtils.java
public static void verifyException(Class<? extends RuntimeException> expectedException, Callable<Void> callable) { try {//from ww w. j a v a 2 s. c o m callable.call(); Assert.fail("Expected exception type: " + expectedException.getName()); } catch (Exception e) { Assert.assertEquals(expectedException, e.getClass()); } }
From source file:net.dv8tion.jda.core.utils.JDALogger.java
/** * Will get the {@link org.slf4j.Logger} for the given Class * or create and cache a fallback logger if there is no SLF4J implementation present. * <p>//from w w w. ja v a 2 s .com * The fallback logger will be an instance of a slightly modified version of SLF4Js SimpleLogger. * * @param clazz * The class used for the Logger name * * @return Logger for given Class */ public static Logger getLog(Class<?> clazz) { synchronized (LOGS) { if (SLF4J_ENABLED) return LoggerFactory.getLogger(clazz); return LOGS.computeIfAbsent(clazz.getName(), (n) -> new SimpleLogger(clazz.getSimpleName())); } }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T newInstance(@NonNull Class<T> cls) { final Constructor ctor = getDefaultConstructor(cls); try {/*from ww w. j av a2 s .c om*/ return (T) ctor.newInstance(); } catch (Throwable t) { t.printStackTrace(); throw new RuntimeException("Failed to instantiate " + cls.getName() + ": " + t.getLocalizedMessage()); } }
From source file:com.izforge.izpack.panels.licence.LicenceLoader.java
/** * Finds the IzPanel target class for the given {@code panelClass}. * * @param panelClass The panel class./*from ww w . j a v a 2 s. c o m*/ * @return The related IzPanel class. * @throws ResourceException If a related IzPanel class could not be found. * * @see PanelHelper#getIzPanel(String) */ static Class<?> findTargetClass(Class<?> panelClass) throws ResourceException { Class<?> targetClass = PanelHelper.getIzPanel(panelClass.getName()); if (null == targetClass) { throw new ResourceNotFoundException( "No IzPanel implementation found for " + panelClass.getSimpleName()); } return targetClass; }
From source file:com.lonepulse.robozombie.response.Deserializers.java
/** * <p>Retrieves the {@link AbstractDeserializer} which is defined for the given {@link Class}.</p> * //from ww w .j a v a 2 s .c o m * @param deserializerType * the {@link Class} whose implementation of {@link AbstractDeserializer} is retrieved * <br><br> * @return the implementation of {@link AbstractDeserializer} for the given {@link Class} * <br><br> * @throws DeserializerInstantiationException * if a custom deserializer failed to be instantiated using its <b>default constructor</b> * <br><br> * @since 1.3.0 */ public static final AbstractDeserializer<?> resolve(Class<? extends AbstractDeserializer<?>> deserializerType) { try { synchronized (DESERIALIZERS) { String key = deserializerType.getName(); AbstractDeserializer<?> deserializer = DESERIALIZERS.get(key); if (deserializer == null) { deserializer = deserializerType.newInstance(); DESERIALIZERS.put(key, deserializer); } return deserializer; } } catch (Exception e) { throw new DeserializerInstantiationException(deserializerType, e); } }
From source file:Main.java
private static boolean isTypeMatch(Class<?> one, Class<?> two) { if (one.equals(two)) { return true; }/* ww w .j a v a2s. c o m*/ if (one.isPrimitive()) { if (one.getName().equals("int") && two.getName().equals("java.lang.Integer")) { return true; } if (one.getName().equals("long") && two.getName().equals("java.lang.Long")) { return true; } if (one.getName().equals("float") && two.getName().equals("java.lang.Float")) { return true; } if (one.getName().equals("double") && two.getName().equals("java.lang.Double")) { return true; } if (one.getName().equals("char") && two.getName().equals("java.lang.Character")) { return true; } if (one.getName().equals("byte") && two.getName().equals("java.lang.Byte")) { return true; } if (one.getName().equals("short") && two.getName().equals("java.lang.Short")) { return true; } if (one.getName().equals("boolean") && two.getName().equals("java.lang.Boolean")) { return true; } } return false; }
From source file:net.abhinavsarkar.spelhelper.ImplicitMethodResolver.java
private static Method lookupMethod(final EvaluationContext context, final Class<?> type, final String name) { for (Class<?> clazz : InheritenceUtil.getInheritance(type)) { Object variable = ((SpelHelper) context.lookupVariable(SpelHelper.CONTEXT_LOOKUP_KEY)) .lookupImplicitMethod(clazz.getName() + "." + name); if (variable instanceof Method) { return (Method) variable; }/*from w w w. j a v a2 s . c o m*/ } return null; }