List of usage examples for java.lang Class isInstance
@HotSpotIntrinsicCandidate public native boolean isInstance(Object obj);
From source file:org.apache.solr.client.solrj.impl.SolrHttpRequestRetryHandler.java
@Override public boolean retryRequest(final IOException exception, final int executionCount, final HttpContext context) { log.debug("Retry http request {} out of {}", executionCount, this.retryCount); if (executionCount > this.retryCount) { log.debug("Do not retry, over max retry count"); return false; }//w w w . j a v a 2 s.c o m if (this.nonRetriableClasses.contains(exception.getClass())) { log.debug("Do not retry, non retriable class {}", exception.getClass().getName()); return false; } else { for (final Class<? extends IOException> rejectException : this.nonRetriableClasses) { if (rejectException.isInstance(exception)) { log.debug("Do not retry, non retriable class {}", exception.getClass().getName()); return false; } } } final HttpClientContext clientContext = HttpClientContext.adapt(context); final HttpRequest request = clientContext.getRequest(); if (requestIsAborted(request)) { log.debug("Do not retry, request was aborted"); return false; } if (handleAsIdempotent(clientContext)) { log.debug("Retry, request should be idempotent"); return true; } log.debug("Do not retry, no allow rules matched"); return false; }
From source file:edu.jhuapl.graphs.jfreechart.JFreeChartBaseSource.java
protected <T> T getParam(Map<String, Object> params, String fieldName, Class<T> klazz, T defaultValue) { Object val = params.get(fieldName); if (klazz.isInstance(val)) { return klazz.cast(val); } else {/* w ww . j a v a 2 s .com*/ return defaultValue; } }
From source file:hudson.util.PersistedList.java
public <U extends T> U get(Class<U> type) { for (T t : data) if (type.isInstance(t)) return type.cast(t); return null;/*w w w . j av a 2 s . c om*/ }
From source file:net.paslavsky.springrest.SpringAnnotationPreprocessor.java
private boolean isAnnotationPresent(Annotation[] annotations, Class<? extends Annotation> annotationClass) { for (Annotation annotation : annotations) { if (annotationClass.isInstance(annotation)) { return true; }/* w w w .j av a 2 s .c om*/ } return false; }
From source file:com.fheebiy.http.lite.apache.DefaultHttpRequestRetryHandler.java
/** * Used <code>retryCount</code> and <code>requestSentRetryEnabled</code> to determine * if the given method should be retried. *//* ww w .j a v a 2s . c o m*/ public boolean retryRequest(final IOException exception, final int executionCount, final HttpContext context) { if (executionCount > this.retryCount) { // Do not retry if over max retry count return false; } if (this.nonRetriableClasses.contains(exception.getClass())) { return false; } else { for (final Class<? extends IOException> rejectException : this.nonRetriableClasses) { if (rejectException.isInstance(exception)) { return false; } } } return retryRequest(context); }
From source file:org.bytesoft.bytejta.supports.jdbc.LocalXADataSource.java
public boolean isWrapperFor(Class<?> iface) { if (iface == null) { return false; } else if (iface.isInstance(this)) { return true; }/*from ww w. j av a 2 s .co m*/ return false; }
From source file:org.bytesoft.bytejta.supports.jdbc.LocalXADataSource.java
@SuppressWarnings("unchecked") public <T> T unwrap(Class<T> iface) { if (iface == null) { return null; } else if (iface.isInstance(this)) { return (T) this; }// w w w . ja v a 2 s .c o m return null; }
From source file:org.grails.datastore.mapping.query.order.ManualEntityOrdering.java
public List applyOrder(List results, Query.Order order) { final String name = order.getProperty(); @SuppressWarnings("hiding") final PersistentEntity entity = getEntity(); PersistentProperty property = entity.getPropertyByName(name); if (property == null) { final PersistentProperty identity = entity.getIdentity(); if (name.equals(identity.getName())) { property = identity;/*from w ww . j av a2 s . c o m*/ } } if (property != null) { final PersistentProperty finalProperty = property; Collections.sort(results, new Comparator() { public int compare(Object o1, Object o2) { if (entity.isInstance(o1) && entity.isInstance(o2)) { final String propertyName = finalProperty.getName(); Method readMethod = cachedReadMethods.get(propertyName); if (readMethod == null) { BeanWrapper b = PropertyAccessorFactory.forBeanPropertyAccess(o1); final PropertyDescriptor pd = b.getPropertyDescriptor(propertyName); if (pd != null) { readMethod = pd.getReadMethod(); if (readMethod != null) { ReflectionUtils.makeAccessible(readMethod); cachedReadMethods.put(propertyName, readMethod); } } } if (readMethod != null) { final Class<?> declaringClass = readMethod.getDeclaringClass(); if (declaringClass.isInstance(o1) && declaringClass.isInstance(o2)) { Object left = ReflectionUtils.invokeMethod(readMethod, o1); Object right = ReflectionUtils.invokeMethod(readMethod, o2); if (left == null && right == null) return 0; if (left != null && right == null) return 1; if (left == null) return -1; if ((left instanceof Comparable) && (right instanceof Comparable)) { return ((Comparable) left).compareTo(right); } } } } return 0; } }); } if (order.getDirection() == Query.Order.Direction.DESC) { results = reverse(results); } return results; }
From source file:com.jhonyu.framework.frame.datasource.RoutingDataSource.java
@Override @SuppressWarnings("unchecked") public <T> T unwrap(Class<T> iface) throws SQLException { if (iface.isInstance(this)) { return (T) this; }//from w ww . j a va2 s. c om return determineTargetDataSource().unwrap(iface); }
From source file:com.jhonyu.framework.frame.datasource.RoutingDataSource.java
@Override public boolean isWrapperFor(Class<?> iface) throws SQLException { return (iface.isInstance(this) || determineTargetDataSource().isWrapperFor(iface)); }