Example usage for java.lang.reflect Type equals

List of usage examples for java.lang.reflect Type equals

Introduction

In this page you can find the example usage for java.lang.reflect Type equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:org.openflexo.antar.binding.TypeUtils.java

public static boolean isString(Type type) {
    if (type == null) {
        return false;
    }//from   ww  w. ja v a 2 s .c o  m
    return type.equals(String.class);
}

From source file:org.openflexo.antar.binding.TypeUtils.java

public static boolean isVoid(Type type) {
    if (type == null) {
        return false;
    }//  w ww.j  a  v a 2 s  .co  m
    return type.equals(Void.class) || type.equals(Void.TYPE);
}

From source file:org.openflexo.antar.binding.TypeUtils.java

public static boolean isBoolean(Type type) {
    if (type == null) {
        return false;
    }//from  w w  w  .ja va2  s  . co  m
    return type.equals(Boolean.class) || type.equals(Boolean.TYPE);
}

From source file:org.openflexo.antar.binding.TypeUtils.java

public static boolean isByte(Type type) {
    if (type == null) {
        return false;
    }//from  w  ww. ja v  a  2  s.  c o  m
    return type.equals(Byte.class) || type.equals(Byte.TYPE);
}

From source file:org.openflexo.antar.binding.TypeUtils.java

public static boolean isChar(Type type) {
    if (type == null) {
        return false;
    }/*  www . j a v a2  s  . c o  m*/
    return type.equals(Character.class) || type.equals(Character.TYPE);
}

From source file:org.apache.pig.backend.hadoop.executionengine.tez.util.TezCompilerUtil.java

public static boolean bagDataTypeInCombinePlan(PhysicalPlan combinePlan) throws ExecException {
    PhysicalOperator lr = combinePlan.getLeaves().get(0);
    POForEach fe = (POForEach) combinePlan.getPredecessors(lr).get(0);

    // Hack. class.getTypeName() is only available in JDK8
    Type dataBagType = new TOBAG().getReturnType();

    List<PhysicalPlan> inputPlans = fe.getInputPlans();
    for (PhysicalPlan inputPlan : inputPlans) {
        PhysicalOperator leaf = inputPlan.getLeaves().get(0);
        if (leaf.getResultType() == DataType.BAG) {
            return true;
        } else if (leaf instanceof POUserFunc) {
            POUserFunc func = (POUserFunc) leaf;
            // Return type of Intermediate func in combiner plan is always Tuple.
            // Need to check original or Final EvalFunc return type
            if (dataBagType.equals(func.getOriginalReturnType())) {
                return true;
            }/*from  ww  w.j a  va2s . c  om*/
        }
    }
    return false;
}

From source file:org.restlet.ext.jaxrs.internal.wrappers.params.ParameterList.java

/**
 * @return the collection type for the given {@link ParameterizedType
 *         parametrized Type}.<br>
 *         If the given type do not represent an collection, null is
 *         returned./*from w  w  w.  j  av  a  2 s  . co m*/
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Class<Collection<?>> collType(ParameterizedType type) {
    final Type rawType = type.getRawType();
    if (rawType.equals(List.class)) {
        return (Class) ArrayList.class;
    } else if (rawType.equals(Set.class)) {
        return (Class) HashSet.class;
    } else if (rawType.equals(SortedSet.class)) {
        return (Class) TreeSet.class;
    } else if (rawType.equals(Collection.class)) {
        localLogger.config(ParameterList.COLL_PARAM_NOT_DEFAULT);
        return (Class) ArrayList.class;
    }
    return null;
}

From source file:com.bstek.dorado.data.method.MethodAutoMatchingUtils.java

private static int isTypeAssignableFrom(Type targetType, Type sourceType) {
    Class<?> targetClass = toClass(targetType);
    Class<?> sourceClass = toClass(sourceType);

    int rate = 5;
    if (!targetType.equals(sourceType)) {
        rate = 4;//  w  w  w.  jav a2 s .  c o m
        boolean b = targetClass.isAssignableFrom(sourceClass);
        if (b) {
            Class<?> targetElementClass = getElementType(targetType);
            if (targetElementClass != null) {
                Class<?> sourceElementClass = getElementType(sourceType);
                if (sourceElementClass != null) {
                    return isTypeAssignableFrom(targetElementClass, sourceElementClass);
                }
            }
        } else if (targetClass.isPrimitive()) {
            targetClass = MethodUtils.toNonPrimitiveClass(targetClass);
            b = targetClass.isAssignableFrom(sourceClass);
        }

        if (!b) {
            b = Number.class.isAssignableFrom(targetClass) && Number.class.isAssignableFrom(sourceClass);
        }
        if (!b) {
            rate = 0;
        }
    }
    return rate;
}

From source file:richtercloud.reflection.form.builder.jpa.typehandler.ElementCollectionTypeHandler.java

/**
 *
 * @param type//from   ww  w  . j  a  va2  s  .com
 * @param fieldValue
 * @param fieldName
 * @param declaringClass
 * @param updateListener
 * @param reflectionFormBuilder
 * @throws IllegalArgumentException if the generic type of {@code type} as
 * returned by {@link #retrieveTypeGenericType(java.lang.reflect.Type) } is
 * {@code String} or a primitive wrapper
 * @return the result of the handling
 */
@Override
protected Pair<JComponent, ComponentHandler<?>> handleGenericType(Type type, List<Object> fieldValue,
        String fieldName, Class<?> declaringClass,
        final FieldUpdateListener<FieldUpdateEvent<List<Object>>> updateListener,
        JPAReflectionFormBuilder reflectionFormBuilder) {
    Type genericType = retrieveTypeGenericType(type);
    if (genericType.equals(String.class) || genericType.equals(Byte.class) || genericType.equals(Boolean.class)
            || genericType.equals(Character.class) || genericType.equals(Integer.class)
            || genericType.equals(Long.class) || genericType.equals(Short.class)
            || genericType.equals(Double.class) || genericType.equals(Float.class)) {
        throw new IllegalArgumentException(String.format(
                "generic type %s or primitive wrapper not supported (is %s)", String.class, genericType));
    }
    EmbeddableListPanel retValue = new EmbeddableListPanel(reflectionFormBuilder, (Class<?>) genericType,
            fieldValue, messageHandler, embeddableFieldHandler);
    retValue.addItemListener(new ListPanelItemListener<Object>() {

        @Override
        public void onItemAdded(ListPanelItemEvent<Object> event) {
            updateListener.onUpdate(new FieldUpdateEvent<>(event.getItem()));
        }

        @Override
        public void onItemRemoved(ListPanelItemEvent<Object> event) {
            updateListener.onUpdate(new FieldUpdateEvent<>(event.getItem()));
        }
    });
    return new ImmutablePair<JComponent, ComponentHandler<?>>(retValue, this);
}

From source file:org.datalorax.populace.core.populate.mutator.change.ChangeBigDecimalMutator.java

@Override
public Object mutate(final Type type, final Object currentValue, final Object parent,
        final PopulatorContext config) {
    Validate.isTrue(type.equals(BigDecimal.class), "BigDecimal type expected");
    if (currentValue == null) {
        return null;
    }/*from   w  w w.j a va  2  s  .c  o  m*/

    final BigDecimal bigDecimal = (BigDecimal) currentValue;
    return bigDecimal.divide(DIVISOR, BigDecimal.ROUND_HALF_EVEN);
}