List of usage examples for java.lang Class getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader.java
/** * Loads a config class filling it with the corresponding values. * //from w w w . j a v a2 s . c om * @param object * config object * @throws ConfigurationException */ public void load(Object object) throws ConfigurationException { Class<?> config = object.getClass(); if (!CoreBootstrap.isAnnotatedType(config)) { config = config.getSuperclass(); logger.debug(bundle.getString("proxy-detected", config, config.getClass().getSuperclass())); } logger.debug(bundle.getString("loading-configuration-class", config.getName())); for (Field field : Reflections.getNonStaticDeclaredFields(config)) { loadField(field, object, config); } }
From source file:at.ac.tuwien.infosys.jcloudscale.datastore.core.DatastoreImpl.java
@Override public <T> void deleteById(Class<T> clazz, String id) { ValidatorChain validatorChain = new ValidatorChainImpl(); validatorChain.add(new NotNullValidator(id)); validatorChain.validate();// w w w . ja v a 2 s . c o m log.info("Deleting object with ID " + id); datastoreDriver.delete(this, clazz.getClass(), id); log.info("Finished deleting Object."); }
From source file:org.xframium.page.keyWord.step.KeyWordStepFactory.java
/** * Adds the key word./*www. j a va 2 s .c o m*/ * * @param keyWord * the key word * @param kwImpl * the kw impl */ public void addKeyWord(String keyWord, Class kwImpl) { if (stepMap.containsKey(keyWord)) log.warn("Overwriting Keyword [" + keyWord + "] of type [" + stepMap.get(keyWord).getClass().getSimpleName() + "] with [" + kwImpl.getClass().getSimpleName()); stepMap.put(keyWord.toUpperCase(), kwImpl); classMap.put(kwImpl, keyWord); SerializationManager.instance().getDefaultAdapter().addCustomMapping(kwImpl, new ReflectionSerializer()); }
From source file:com.ebay.erl.mobius.core.mapred.MultiInputsHelpersRepository.java
public MultiInputsHelpersRepository register(Class<? extends InputFormat> inputFormat, Class<? extends MultiInputsHelper> aFinder) { if (this.mapping.containsKey(inputFormat)) { MultiInputsHelper oldFinder = this.mapping.get(inputFormat); LOGGER.warn("Override the handler for [" + inputFormat.getCanonicalName() + "] from [" + oldFinder.getClass().getCanonicalName() + "]" + " to [" + aFinder.getClass().getCanonicalName() + "]."); }// w w w . j av a2s . c o m this.mapping.put(inputFormat, ReflectionUtils.newInstance(aFinder, null)); return this; }
From source file:br.com.binarti.simplesearchexpr.converter.NumberSearchDataConverter.java
@SuppressWarnings("rawtypes") @Override// ww w . j a v a 2 s .c om protected Object asSingleObject(SimpleSearchExpressionField field, String value, Map<String, Object> params, Class<?> targetType) { if (value == null) return null; if (targetType.isPrimitive()) { targetType = ClassUtils.primitiveToWrapper(targetType); } try { Constructor constructor = targetType.getConstructor(String.class); return constructor.newInstance(value.trim()); } catch (Exception e) { throw new SimpleSearchDataConverterException( "Error converter " + value + " to " + targetType.getClass()); } }
From source file:org.jadira.scanner.classpath.types.JPackage.java
@Override public <A extends java.lang.annotation.Annotation> JAnnotation<A> getAnnotation(Class<A> annotation) throws ClasspathAccessException { Set<JAnnotation<?>> inspAnnotations = getAnnotations(); for (JAnnotation<?> next : inspAnnotations) { if (next.getName().equals(annotation.getName()) && (next.getActualAnnotation().getClass().equals(annotation.getClass()))) { @SuppressWarnings("unchecked") JAnnotation<A> retVal = (JAnnotation<A>) next; return retVal; }/*from w w w. j a va 2s .c o m*/ } return null; }
From source file:org.opencastproject.matterhorn.search.impl.AbstractSearchQuery.java
/** * This method is called if a certain type of object is expected by someone. If this is not the case (e. g. query * configuration is in good shape, then someone tries to "finish" a configuration part) we throw an * <code>IllegalStateException</code>. * * @throws IllegalStateException/*from w w w . java 2 s .co m*/ * if no or a different object is expected */ protected void ensureExpectation(Class<?> c) throws IllegalStateException { if (expectation == null) throw new IllegalStateException( "Malformed query configuration. No " + c.getClass().getName() + " is expected at this time"); if (!expectation.getCanonicalName().equals(c.getCanonicalName())) throw new IllegalStateException("Malformed query configuration. Something of type " + c.getClass().getName() + " is expected at this time"); expectation = null; }
From source file:org.ldp4j.server.sdk.StringContent.java
@Override public <S> S serialize(Class<S> clazz) throws IOException { Object result = null;//www.java 2s. co m if (clazz.isInstance(source)) { result = source; } else if (clazz.isAssignableFrom(InputStream.class)) { result = IOUtils.toBufferedInputStream(new ByteArrayInputStream(source.getBytes(charset))); } else if (clazz.isAssignableFrom(Reader.class)) { result = new StringReader(source); } else if (clazz.isAssignableFrom(CharSequence.class)) { result = CharSequence.class.cast(source); } else if (clazz.getClass().isArray() && Byte.TYPE.isAssignableFrom(clazz.getComponentType())) { result = (byte[]) source.getBytes(charset); } else { throw new IOException( String.format("Could not serialize String content to '%s'", clazz.getCanonicalName())); } return clazz.cast(result); }
From source file:com.sqewd.open.dal.core.persistence.DataManager.java
private void scanEntities(final List<Class<?>> classes) throws Exception { for (Class<?> type : classes) { if (type.isAnnotationPresent(Entity.class)) { log.debug("Found entity : [" + type.getCanonicalName() + "][" + type.getClassLoader().getClass().getCanonicalName() + "]"); ReflectionUtils.get().load(type); }//from w ww . j a va 2s . c o m } }
From source file:com.eviware.soapui.plugins.LoaderBase.java
protected SoapUIFactory createAutoFactory(Class<? extends Annotation> annotationType, Class<? extends SoapUIFactory> factoryClass, Class<?> clazz, Annotation annotation) throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException, NoSuchMethodException {/*w ww . ja va 2 s . c o m*/ return factoryClass.getConstructor(annotationType, clazz.getClass()).newInstance(annotation, clazz); }