Example usage for java.lang Class getClass

List of usage examples for java.lang Class getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.trustedanalytics.platformoperations.ApplicationConfiguration.java

private <T> T getClient(Class<T> clientType, String url) {
    return Feign.builder().encoder(new JacksonEncoder()).decoder(new JacksonDecoder())
            .logger(new ScramblingSlf4jLogger(clientType.getClass())).logLevel(Logger.Level.FULL)
            .target(clientType, url);//  w  w w  . j  a v  a 2s .  c  om
}

From source file:fm.pattern.tokamak.server.service.DataServiceImpl.java

private <T> String entity(Class<T> entity) {
    if (entity.isAnnotationPresent(Entity.class)) {
        return entity.getAnnotation(Entity.class).name();
    }/*  w ww . j  a  v  a  2  s  . c o m*/
    throw new IllegalStateException(entity.getClass().getSimpleName()
            + " must have an @Entity annotation configured with the entity name.");
}

From source file:com.qmetry.qaf.automation.ui.webdriver.QAFWebComponent.java

@SuppressWarnings("unchecked")
public <T extends QAFWebComponent> List<T> findElements(String loc, Class<T> t) {
    List<QAFWebElement> eles = findElements(loc);
    List<T> objs = new ArrayList<T>();
    for (QAFWebElement ele : eles) {
        T obj = (T) ComponentFactory.getObject(t.getClass(), loc, this, this);
        obj.setId(((QAFExtendedWebElement) ele).getId());
        obj.parentElement = this;
        obj.cacheable = true;//from w  w  w.  ja  v a2 s  .c  om
        objs.add(obj);
    }
    return objs;
}

From source file:com.wcs.base.util.StringUtils.java

private static boolean isClassOrInterface(Class objClass, String className) {
    if (objClass.getClass().getName().equals(className))
        return true;
    Class[] classes = objClass.getInterfaces();
    for (int i = 0; i < classes.length; i++) {
        if (classes[i].getName().equals("java.util." + className))
            return true;
    }/*from ww  w.  jav a2  s .c  o  m*/
    return false;
}

From source file:jp.co.ctc_g.jfw.core.util.Beans.java

/**
 * ???????????/*from   w ww .  j a  va  2  s.c om*/
 * @param propertyName ??
 * @param target 
 * @return ????
 */
public static Class<?> detectDeclaredPropertyType(String propertyName, Class<?> target) {
    Args.checkNotBlank(propertyName);
    Args.checkNotNull(target);
    String[] properties = propertyName.split("\\.");
    Class<?> result = target;
    for (String property : properties) {
        PropertyDescriptor pd = findPropertyDescriptorFor(result, property);
        if (pd == null) {
            if (L.isDebugEnabled()) {
                Map<String, Object> replace = new HashMap<String, Object>(1);
                replace.put("property", propertyName);
                replace.put("class", target.getClass().getName());
                L.debug(Strings.substitute(R.getString("D-UTIL#0015"), replace));
            }
            return null;
        }
        result = pd.getPropertyType();
    }
    return result;
}

From source file:org.gbif.registry.metasync.util.converter.DateTimeConverter.java

@Override
public Object convert(Class type, Object value) {
    checkNotNull(type, "type cannot be null");
    checkNotNull(value, "Value cannot be null");
    checkArgument(type.equals(DateTime.class), "Conversion target should be org.joda.time.DateTime, but is %s",
            type.getClass());
    checkArgument(String.class.isAssignableFrom(value.getClass()), "Value should be a string, but is a %s",
            value.getClass());//from  www.j a v  a  2s. c  om
    DateTime dateTime = null;
    try {
        dateTime = formatter.parseDateTime((String) value);
    } catch (IllegalArgumentException e) {
        LOG.debug("Could not parse date: [{}]", value, e);
    }
    return dateTime;
}

From source file:com.evolveum.midpoint.testing.rest.TestJsonProvider.java

@Override
public T readFrom(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType,
        MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
        throws IOException, WebApplicationException {

    if (String.class.isAssignableFrom(type.getClass())) {
        return (T) IOUtils.toString(entityStream);
    }/*from   w w  w.  jav  a2  s.com*/

    T result = super.readFrom(type, genericType, annotations, mediaType, httpHeaders, entityStream);
    if (result instanceof PrismObject) {
        return (T) ((PrismObject) result).asObjectable();
    }

    return result;
}

From source file:org.gbif.registry.metasync.util.converter.LanguageConverter.java

@Override
public Object convert(Class type, Object value) {
    checkNotNull(type, "type cannot be null");

    if (value == null) {
        return Language.ENGLISH;
    }//from   w ww .j  a  va 2 s. c o m

    checkArgument(type.equals(Language.class),
            "Conversion target should be org.gbif.api.vocabulary.Language, but is %s", type.getClass());
    checkArgument(String.class.isAssignableFrom(value.getClass()), "Value should be a string, but is a %s",
            value.getClass());

    return Language.fromIsoCode((String) value);
}

From source file:com.espertech.esper.filter.FilterSpecCompiler.java

private static FilterSpecParam handleInSetNode(ExprInNode constituent,
        LinkedHashMap<String, Pair<EventType, String>> arrayEventTypes,
        ExprEvaluatorContext exprEvaluatorContext, String statementName) throws ExprValidationException {
    ExprNode left = constituent.getChildNodes()[0];
    if (!(left instanceof ExprFilterOptimizableNode)) {
        return null;
    }//from  ww  w .  jav  a 2 s.  c  om

    ExprFilterOptimizableNode filterOptimizableNode = (ExprFilterOptimizableNode) left;
    FilterSpecLookupable lookupable = filterOptimizableNode.getFilterLookupable();
    FilterOperator op = FilterOperator.IN_LIST_OF_VALUES;
    if (constituent.isNotIn()) {
        op = FilterOperator.NOT_IN_LIST_OF_VALUES;
    }

    int expectedNumberOfConstants = constituent.getChildNodes().length - 1;
    List<FilterSpecParamInValue> listofValues = new ArrayList<FilterSpecParamInValue>();
    Iterator<ExprNode> it = Arrays.asList(constituent.getChildNodes()).iterator();
    it.next(); // ignore the first node as it's the identifier
    while (it.hasNext()) {
        ExprNode subNode = it.next();
        if (ExprNodeUtility.isConstantValueExpr(subNode)) {
            ExprConstantNode constantNode = (ExprConstantNode) subNode;
            Object constant = constantNode.evaluate(null, true, exprEvaluatorContext);
            if (constant instanceof Collection) {
                return null;
            }
            if (constant instanceof Map) {
                return null;
            }
            if ((constant != null) && (constant.getClass().isArray())) {
                for (int i = 0; i < Array.getLength(constant); i++) {
                    Object arrayElement = Array.get(constant, i);
                    Object arrayElementCoerced = handleConstantsCoercion(lookupable, arrayElement);
                    listofValues.add(new InSetOfValuesConstant(arrayElementCoerced));
                    if (i > 0) {
                        expectedNumberOfConstants++;
                    }
                }
            } else {
                constant = handleConstantsCoercion(lookupable, constant);
                listofValues.add(new InSetOfValuesConstant(constant));
            }
        }
        if (subNode instanceof ExprContextPropertyNode) {
            ExprContextPropertyNode contextPropertyNode = (ExprContextPropertyNode) subNode;
            Class returnType = contextPropertyNode.getType();
            if (JavaClassHelper.isImplementsInterface(contextPropertyNode.getType(), Collection.class)
                    || JavaClassHelper.isImplementsInterface(contextPropertyNode.getType(), Map.class)) {
                return null;
            }
            if ((returnType != null) && (returnType.getClass().isArray())) {
                return null;
            }
            SimpleNumberCoercer coercer = getNumberCoercer(left.getExprEvaluator().getType(),
                    contextPropertyNode.getType(), lookupable.getExpression());
            listofValues.add(new InSetOfValuesContextProp(contextPropertyNode.getPropertyName(),
                    contextPropertyNode.getGetter(), coercer));
        }
        if (subNode instanceof ExprIdentNode) {
            ExprIdentNode identNodeInner = (ExprIdentNode) subNode;
            if (identNodeInner.getStreamId() == 0) {
                break; // for same event evals use the boolean expression, via count compare failing below
            }

            boolean isMustCoerce = false;
            Class numericCoercionType = JavaClassHelper.getBoxedType(lookupable.getReturnType());
            if (identNodeInner.getExprEvaluator().getType() != lookupable.getReturnType()) {
                if (JavaClassHelper.isNumeric(lookupable.getReturnType())) {
                    if (!JavaClassHelper.canCoerce(identNodeInner.getExprEvaluator().getType(),
                            lookupable.getReturnType())) {
                        throwConversionError(identNodeInner.getExprEvaluator().getType(),
                                lookupable.getReturnType(), lookupable.getExpression());
                    }
                    isMustCoerce = true;
                } else {
                    break; // assumed not compatible
                }
            }

            FilterSpecParamInValue inValue;
            String streamName = identNodeInner.getResolvedStreamName();
            if (arrayEventTypes != null && !arrayEventTypes.isEmpty()
                    && arrayEventTypes.containsKey(streamName)) {
                Pair<Integer, String> indexAndProp = getStreamIndex(identNodeInner.getResolvedPropertyName());
                inValue = new InSetOfValuesEventPropIndexed(identNodeInner.getResolvedStreamName(),
                        indexAndProp.getFirst(), indexAndProp.getSecond(), isMustCoerce, numericCoercionType,
                        statementName);
            } else {
                inValue = new InSetOfValuesEventProp(identNodeInner.getResolvedStreamName(),
                        identNodeInner.getResolvedPropertyName(), isMustCoerce, numericCoercionType);
            }

            listofValues.add(inValue);
        }
    }

    // Fallback if not all values in the in-node can be resolved to properties or constants
    if (listofValues.size() == expectedNumberOfConstants) {
        return new FilterSpecParamIn(lookupable, op, listofValues);
    }
    return null;
}

From source file:es.osoco.grails.plugins.otp.authentication.OneTimePasswordAuthenticationProvider.java

@Override
public boolean supports(Class<? extends Object> authentication) {
    boolean supported = OneTimePasswordAuthenticationToken.class.isAssignableFrom(authentication);
    if (logger.isDebugEnabled()) {
        logger.debug("Supports " + authentication.getClass().getName() + " ?  " + supported);
    }//  w w w  .j ava 2 s .c o m
    return supported;
}