Example usage for java.util List getClass

List of usage examples for java.util List getClass

Introduction

In this page you can find the example usage for java.util List getClass.

Prototype

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

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.apache.cassandra.cql.jdbc.HandleObjects.java

private static final <X> ByteBuffer makeByteBuffer4List(AbstractJdbcType<?> instanceType, List<X> value) {
    return ListMaker.getInstance(instanceType).decompose(value.getClass().cast(value));
}

From source file:pt.ua.tm.neji.core.batch.BatchExecutor.java

protected static <A, B> Processor newProcessor(final Class<? extends Processor> processorCls,
        final Context context, final A input, final List<B> outputList, final Object... args)
        throws NejiException {
    Validate.notNull(processorCls);/*  w  ww .  j av  a  2 s. c o m*/
    Validate.notNull(context);
    Validate.notNull(input);
    Validate.notNull(outputList);

    int numberArgs = 3 + (args != null ? args.length : 0);
    List<Object> values = new ArrayList<>(numberArgs);
    values.add(context);
    values.add(input);
    values.add(outputList);

    List<Class> types = new ArrayList<>(numberArgs);
    types.add(context.getClass());
    types.add(input.getClass());
    types.add(outputList.getClass());

    if (args != null) {
        for (Object arg : args) {
            values.add(arg);
            types.add(arg.getClass());
        }
    }

    try {
        return (Processor) ConstructorUtils.invokeConstructor(processorCls, values.toArray(),
                types.toArray(new Class[types.size()]));
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException
            | InstantiationException ex) {
        logger.error("Error creating new pipeline processor.", ex);
        throw new NejiException("Error creating new pipeline processor.", ex);
    }
}

From source file:edu.asu.cse564.samples.crud.io.GradebookIO.java

public static void writeToGradebook(List<Gradebook> gradebookList, String filename) {
    //GradebookIO gbio = new GradebookIO();
    try {/*  ww w.  j av  a 2s  .  c o m*/
        //String path = gbio.getPath(filename);
        String path = filename;
        File file = new File(path);

        // if file doesnt exists, then create it
        if (!file.exists()) {
            LOG.info("Creating file as it does not exist");
            file.createNewFile();
            LOG.debug("Created file = {}", file.getAbsolutePath());
        }
        String jsonString = null;
        jsonString = Converter.convertFromObjectToJSON(gradebookList, gradebookList.getClass());
        LOG.info("File path = {}", file.getAbsolutePath());
        FileWriter fw = new FileWriter(file.getAbsoluteFile());
        try (BufferedWriter bw = new BufferedWriter(fw)) {
            bw.write(jsonString);
        }
    } catch (Exception e) {
        e.printStackTrace();
        ;
    }
}

From source file:pt.ua.tm.neji.core.batch.BatchExecutor.java

protected static <A, B> Processor newProcessor(final Class<? extends Processor> processorCls,
        final Context context, final A input, final List<B> outputList, boolean addAnnotationsWithoutIDs,
        final Object... args) throws NejiException {
    Validate.notNull(processorCls);/*from   www . ja  v a 2 s  .c  om*/
    Validate.notNull(context);
    Validate.notNull(input);
    Validate.notNull(outputList);

    int numberArgs = 3 + (args != null ? args.length : 0);
    List<Object> values = new ArrayList<>(numberArgs);
    values.add(context);
    values.add(input);
    values.add(outputList);
    values.add(addAnnotationsWithoutIDs);

    List<Class> types = new ArrayList<>(numberArgs);
    types.add(context.getClass());
    types.add(input.getClass());
    types.add(outputList.getClass());
    types.add(boolean.class);

    if (args != null) {
        for (Object arg : args) {
            values.add(arg);
            types.add(arg.getClass());
        }
    }

    try {
        return (Processor) ConstructorUtils.invokeConstructor(processorCls, values.toArray(),
                types.toArray(new Class[types.size()]));
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException
            | InstantiationException ex) {
        logger.error("Error creating new pipeline processor.", ex);
        throw new NejiException("Error creating new pipeline processor.", ex);
    }
}

From source file:org.apache.hadoop.hive.ql.exec.SerializationUtilities.java

/**
 * Clones using the powers of XML. Do not use unless necessary.
 * @param roots The roots.//w w w.  j  ava2  s  .  c  o  m
 * @return The clone.
 */
public static List<Operator<?>> cloneOperatorTree(List<Operator<?>> roots) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
    CompilationOpContext ctx = roots.isEmpty() ? null : roots.get(0).getCompilationOpContext();
    serializePlan(roots, baos, true);
    @SuppressWarnings("unchecked")
    List<Operator<?>> result = deserializePlan(new ByteArrayInputStream(baos.toByteArray()), roots.getClass(),
            true);
    // Restore the context.
    LinkedList<Operator<?>> newOps = new LinkedList<>(result);
    while (!newOps.isEmpty()) {
        Operator<?> newOp = newOps.poll();
        newOp.setCompilationOpContext(ctx);
        List<Operator<?>> children = newOp.getChildOperators();
        if (children != null) {
            newOps.addAll(children);
        }
    }
    return result;
}

From source file:org.apache.hadoop.hive.ql.exec.SerializationUtilities.java

public static List<Operator<?>> cloneOperatorTree(List<Operator<?>> roots, int indexForTezUnion) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
    CompilationOpContext ctx = roots.isEmpty() ? null : roots.get(0).getCompilationOpContext();
    serializePlan(roots, baos, true);//from   w w  w.  j a v a2s .c  o  m
    @SuppressWarnings("unchecked")
    List<Operator<?>> result = deserializePlan(new ByteArrayInputStream(baos.toByteArray()), roots.getClass(),
            true);
    // Restore the context.
    LinkedList<Operator<?>> newOps = new LinkedList<>(result);
    while (!newOps.isEmpty()) {
        Operator<?> newOp = newOps.poll();
        newOp.setIndexForTezUnion(indexForTezUnion);
        newOp.setCompilationOpContext(ctx);
        List<Operator<?>> children = newOp.getChildOperators();
        if (children != null) {
            newOps.addAll(children);
        }
    }
    return result;
}

From source file:org.camunda.spin.impl.json.jackson.format.ListJacksonJsonTypeDetector.java

protected JavaType constructType(Object object) {
    TypeFactory typeFactory = TypeFactory.defaultInstance();

    if (object instanceof List && !((List<?>) object).isEmpty()) {
        List<?> list = (List<?>) object;
        Object firstElement = list.get(0);
        return typeFactory.constructCollectionType(list.getClass(), constructType(firstElement));

    } else {//from w  w w  .  j a  v a2s. co m
        return typeFactory.constructType(object.getClass());
    }
}

From source file:org.obiba.magma.type.LineStringType.java

@Override
public Class<?> getJavaClass() {
    List<Coordinate> line;
    line = new ArrayList<>();
    return line.getClass();
}

From source file:org.obiba.magma.type.LineStringType.java

@Override
public boolean acceptsJavaClass(@NotNull Class<?> clazz) {
    List<Coordinate> line;
    line = new ArrayList<>();
    return line.getClass().isAssignableFrom(clazz);
}

From source file:org.abstracthorizon.proximity.ProximityIntegrationTest.java

/**
 * Test simple dir.//from  w w  w  .ja  v  a 2 s. c  o m
 */
public void testSimpleDir() {
    try {
        List items = proximity.listItems(getRequest("/"));
        logger.info("Got response of type " + items.getClass() + ":" + items);
        items = proximity.listItems(getRequest("/public"));
        logger.info("Got response of type " + items.getClass() + ":" + items);
        items = proximity.listItems(getRequest("/public/ant"));
        logger.info("Got response of type " + items.getClass() + ":" + items);
    } catch (ProximityException ex) {
        logger.error("Got ex but i should not have it!", ex);
        fail();
    }
}