public boolean isFilter() { if (_beanClazz != null) { return ReflectionUtils.is(_beanClazz, Filter.class); } return false; }
public boolean isRenderer() { if (_beanClazz != null) { return ReflectionUtils.isAnnotationPresent(_beanClazz, RendererBean.class) && ReflectionUtils.is(_beanClazz, Renderer.class); } return false; }
/** * @return true if thisType is a valid type ofThatType, either as a single * instance or as an array of ofThatType */ public static boolean is(final Type thisType, final Class<?> ofThatType) { return is(thisType, ofThatType, true); }
public static boolean isNumber(final Type type) { if (type instanceof Class<?>) { final Class<?> clazz = (Class<?>) type; final boolean numberClass = is(clazz, Number.class, false); if (numberClass) { return true; } return type == byte.class || type == int.class || type == short.class || type == long.class || type == float.class || type == double.class; } return false; }
public boolean isAnalyzer() { if (_beanClazz != null) { return ReflectionUtils.is(_beanClazz, Analyzer.class); } return false; }
@Override public boolean isConvertable(final Class<?> type) { return ReflectionUtils.is(type, Serializable.class) || type.isPrimitive(); } }
@Override public final int getWindowCount(final Class<? extends DCWindow> windowClass) { int count = 0; for (final DCWindow window : _windows) { if (ReflectionUtils.is(window.getClass(), windowClass)) { count++; } } return count; }
@Override public boolean isConvertable(final Class<?> type) { return type.isArray() || ReflectionUtils.is(type, List.class); } }
@SuppressWarnings("unchecked") public static <E> List<E> filterOnClass(final Collection<?> superTypeList, final Class<E> subType) { final List<E> result = new ArrayList<>(); for (final Object object : superTypeList) { if (object != null) { if (ReflectionUtils.is(object.getClass(), subType)) { result.add((E) object); } } } return result; }
@Override public final Set<ProvidedPropertyDescriptor> getProvidedPropertiesByType(final Class<?> cls) { final Set<ProvidedPropertyDescriptor> result = new HashSet<>(); for (final ProvidedPropertyDescriptor descriptor : _providedProperties) { if (ReflectionUtils.is(descriptor.getType(), cls)) { result.add(descriptor); } } return result; }
protected void putValue(final E value, final String[] categories) throws IllegalArgumentException, NullPointerException { if (value != null) { if (!ReflectionUtils.is(value.getClass(), valueClass)) { throw new IllegalArgumentException("Cannot put value [" + value + "] of type [" + value.getClass() + "] when Crosstab.valueClass is [" + valueClass + "]"); } } final String key = getKey(categories); values.put(key, value); }
@SuppressWarnings("unchecked") public <E> InputColumn<E> narrow(final Class<E> e) { final Class<?> javaEquivalentClass = _column.getType().getJavaEquivalentClass(); if (ReflectionUtils.is(javaEquivalentClass, e)) { return (InputColumn<E>) this; } throw new IllegalArgumentException("Can only narrow this column to supertypes of: " + javaEquivalentClass); }
protected AnnotationBasedAnalyzerComponentDescriptor(final Class<A> analyzerClass) throws DescriptorException { super(analyzerClass, true); if (!ReflectionUtils.is(analyzerClass, Analyzer.class)) { throw new DescriptorException(analyzerClass + " does not implement " + Analyzer.class.getName()); } visitClass(); }
protected AnnotationBasedTransformerComponentDescriptor(final Class<T> transformerClass) throws DescriptorException { super(transformerClass, false); if (!ReflectionUtils.is(transformerClass, Transformer.class)) { throw new DescriptorException(transformerClass + " does not implement " + Transformer.class.getName()); } visitClass(); }
protected AnnotationBasedFilterComponentDescriptor(final Class<F> filterClass) throws DescriptorException { super(filterClass, false); if (!ReflectionUtils.is(filterClass, Filter.class)) { throw new DescriptorException(filterClass + " does not implement " + Filter.class.getName()); } visitClass(); }
@Override public void onAdd(final Datastore datastore) { if (ReflectionUtils.is(datastore.getClass(), _datastoreClass)) { _comboBox.setEditable(true); _comboBox.addItem(datastore); _comboBox.setEditable(false); } }
private InputColumn<?> getFirstRelevantSourceColumn(final List<? extends InputColumn<?>> sourceColumns, final ConfiguredPropertyDescriptor inputProperty) { assert inputProperty.isInputColumn(); final Class<?> expectedDataType = inputProperty.getTypeArgument(0); for (final InputColumn<?> inputColumn : sourceColumns) { final Class<?> actualDataType = inputColumn.getDataType(); if (ReflectionUtils.is(actualDataType, expectedDataType, false)) { return inputColumn; } } return null; }
@Override public final boolean isDistributable() { final Distributed distributed = getAnnotation(Distributed.class); if (distributed != null) { return distributed.value(); } final boolean hasDistributionAdvice = ReflectionUtils.is(getComponentClass(), HasDistributionAdvice.class); if (hasDistributionAdvice) { return true; } return isDistributableByDefault(); }
@Override public void onAdd(final InputColumn<?> sourceColumn) { if (_dataType == Object.class || ReflectionUtils.is(sourceColumn.getDataType(), _dataType)) { addAvailableInputColumn(sourceColumn); updateVisibility(); updateUI(); } }