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.opendaylight.ovsdb.southbound.transactions.md.OvsdbBridgeUpdateCommandTest.java

@SuppressWarnings("unchecked")
@Test//from  w  ww.j  a va 2s .  co m
public void testToRemoveMethods() throws Exception {
    Bridge bridge = mock(Bridge.class);
    UUID uuid = mock(UUID.class);
    Bridge oldBridge = mock(Bridge.class);
    oldBridgeRows.put(uuid, oldBridge);
    when(bridge.getUuid()).thenReturn(uuid);
    MemberModifier.field(OvsdbBridgeUpdateCommand.class, "oldBridgeRows").set(ovsdbBridgeUpdateCommand,
            oldBridgeRows);
    Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
    Map<String, String> map = new HashMap<>();
    map.put("key", "value");
    when(column.getData()).thenReturn(map);

    //test bridgeOtherConfigsToRemove()
    when(oldBridge.getOtherConfigColumn()).thenReturn(column);
    when(bridge.getOtherConfigColumn()).thenReturn(column);
    InstanceIdentifier<Node> bridgeIid = PowerMockito.mock(InstanceIdentifier.class);
    List<InstanceIdentifier<BridgeOtherConfigs>> resultBridgeOtherConfigs = Whitebox
            .invokeMethod(ovsdbBridgeUpdateCommand, "bridgeOtherConfigsToRemove", bridgeIid, bridge);
    assertEquals(ArrayList.class, resultBridgeOtherConfigs.getClass());
    verify(oldBridge, times(2)).getOtherConfigColumn();

    //test externalIdsToRemove()
    when(oldBridge.getExternalIdsColumn()).thenReturn(column);
    when(column.getData()).thenReturn(map);
    when(bridge.getExternalIdsColumn()).thenReturn(column);
    List<InstanceIdentifier<BridgeExternalIds>> resultBridgeExternalIds = Whitebox
            .invokeMethod(ovsdbBridgeUpdateCommand, "externalIdsToRemove", bridgeIid, bridge);
    assertEquals(ArrayList.class, resultBridgeExternalIds.getClass());
    verify(oldBridge, times(2)).getExternalIdsColumn();

    //test protocolEntriesToRemove()
    Column<GenericTableSchema, Set<String>> column1 = mock(Column.class);
    Set<String> set = new HashSet<>();
    set.add("element");
    when(column1.getData()).thenReturn(set);
    when(oldBridge.getProtocolsColumn()).thenReturn(column1);
    when(column.getData()).thenReturn(map);
    when(bridge.getProtocolsColumn()).thenReturn(column1);
    List<InstanceIdentifier<ProtocolEntry>> resultProtocolEntry = Whitebox
            .invokeMethod(ovsdbBridgeUpdateCommand, "protocolEntriesToRemove", bridgeIid, bridge);
    assertEquals(ArrayList.class, resultProtocolEntry.getClass());
    verify(oldBridge, times(2)).getProtocolsColumn();
}

From source file:com.google.openrtb.json.AbstractOpenRtbJsonWriter.java

/**
 * Write any extensions that may exist in a message.
 *
 * @param msg A message that may contain extensions
 * @param gen The JSON generator/*from  w ww.j  av  a  2  s  . co  m*/
 * @param <EM> Type of message being serialized, containing extensions
 * @throws IOException any serialization error
 */
@SuppressWarnings("unchecked")
protected final <EM extends ExtendableMessage<EM>> void writeExtensions(EM msg, JsonGenerator gen)
        throws IOException {
    boolean openExt = false;

    for (Map.Entry<FieldDescriptor, Object> field : msg.getAllFields().entrySet()) {
        FieldDescriptor fd = field.getKey();
        if (fd.isExtension()) {
            if (fd.isRepeated()) {
                List<Object> extValue = (List<Object>) field.getValue();
                if (!extValue.isEmpty()) {
                    OpenRtbJsonExtWriter<Object> extWriter = factory.getWriter(msg.getClass(),
                            extValue.get(0).getClass(), fd.getName());
                    if (extWriter != null) {
                        openExt = openExt(gen, openExt);
                        extWriter.writeRepeated(extValue, gen);
                    }
                }
            } else {
                Object extValue = field.getValue();
                OpenRtbJsonExtWriter<Object> extWriter = factory.getWriter(msg.getClass(), extValue.getClass(),
                        fd.getName());
                if (extWriter != null) {
                    openExt = openExt(gen, openExt);
                    extWriter.writeSingle(extValue, gen);
                }
            }
        }
    }

    if (openExt) {
        gen.writeEndObject();
    }
}

From source file:com.lzsoft.rules.core.RulesEngine.java

private Double sumFiledValuebyFieldName(List<Object> objs, Double sumD, PropertyElmt propertyElmt, String clazz)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    String fieldType;//from  w  w  w .  j av a  2s  .  c om
    String fieldname = propertyElmt.getField();

    if (objs.getClass().getName().toLowerCase().indexOf("list") >= 0) {
        for (Object obj : (List) objs) {
            if (obj.getClass().getName().toLowerCase().indexOf("list") >= 0) {
                for (Object object : (List) obj) {
                    if (object.getClass().getName().equals(clazz)) {
                        Object objValue = PropertyUtils.getProperty(object, fieldname);// ?mappingfieldname??
                        fieldType = PropertyUtils.getPropertyType(object, fieldname).getSimpleName();// ?mappingfieldname???
                        if ("Double".equals(fieldType)) {
                            sumD += (Double) objValue;
                        } else if ("BigDecimal".equals(fieldType)) {
                            sumD += ((BigDecimal) objValue).doubleValue();
                        }
                    }
                }
            }
        }
    } else {
        for (Object object : objs) {
            Object objValue = PropertyUtils.getProperty(object, fieldname);// ?mappingfieldname??
            fieldType = PropertyUtils.getPropertyType(object, fieldname).getSimpleName();// ?mappingfieldname???
            if ("Double".equals(fieldType)) {
                sumD += (Double) objValue;
            } else if ("BigDecimal".equals(fieldType)) {
                sumD += ((BigDecimal) objValue).doubleValue();
            }
        }
    }
    return sumD;
}

From source file:tiemens.util.instancer.antlr.InstancerCode.java

public Object create(final String command, final String clzname, final List<Object> arglist) {
    Object ret;//  ww w . j  a  va2  s .co  m
    ret = new String(
            "**ERROR** InstancerCode[cmd='" + command + "' clzname='" + clzname + "' arg='" + arglist + "']");

    logger.fine("clzname='" + clzname + "'");
    logger.fine("arglist.class=");
    if (arglist != null) {
        // Note: this should always pring "java.util.ArrayList"
        logger.fine(arglist.getClass().getName());
    } else {
        logger.fine("null");
        logger.severe("somehow got null for arglist");
    }
    logger.fine("arglist=" + arglist);
    if (arglist.size() > 0) {
        for (int i = 0, n = arglist.size(); i < n; i++) {
            logger.fine("arglist[" + i + "].class=" + arglist.get(i).getClass().getName());
            logger.fine("arglist[" + i + "]='" + arglist.get(i).toString() + "'");
        }
    }

    if ("new".equals(command)) {
        ret = createNew(clzname, arglist);
    } else if ("list".equals(command)) {
        ret = createList(clzname, arglist);
    }

    return ret;
}

From source file:org.pentaho.platform.repository.runtime.RuntimeElement.java

/**
 * Sets a list property in the paramMap. Special implementation note - Null values aren't supported in the Map.
 * So, if a null value is passed in, this implementation will remove the entry from the map.
 * /*from ww w  .ja va  2s  . co  m*/
 * @param key
 *          The key in the map.
 * @param value
 *          The list property to set.
 */
public void setListProperty(final String key, final List value) {
    this.updateOk();
    trace(Messages.getInstance().getString("RTREPO.DEBUG_PROPERTY_GETSET", "setList", key)); //$NON-NLS-1$ //$NON-NLS-2$
    checkType(key, value.getClass().getName(), true);
    Map theMap = getParamMapCPLX();
    if (value != null) {
        theMap.put(key, value);
    } else {
        theMap.remove(key);
    }
}

From source file:xquery4j.XQueryEvaluator.java

public List evaluateExpression(String expr, org.w3c.dom.Node contextNode) {
    try {//  w  w  w .j a v a  2  s .c o m
        contextObjectTL.set(contextObject);
        {
            FunctionLibraryList fll = new FunctionLibraryList();
            fll.addFunctionLibrary(jel);
            config.setExtensionBinder("java", fll);
        }

        StaticQueryContext sqc = new StaticQueryContext(config);
        for (QName var : vars.keySet()) {
            sqc.declareGlobalVariable(StructuredQName.fromClarkName(var.toString()), SequenceType.SINGLE_ITEM,
                    convertJavaToSaxon(vars.get(var)), false);
        }
        DynamicQueryContext dqc = new DynamicQueryContext(config);
        XQueryExpression e = sqc.compileQuery(expr);

        if (contextNode != null) {
            if (!(contextNode instanceof Document || contextNode instanceof DocumentFragment)) {
                try {
                    contextNode = DOMUtils.parse(DOMUtils.domToString(contextNode));
                } catch (Exception e1) {
                    throw new RuntimeException("", e1);
                }
                //                    DocumentFragment frag = contextNode.getOwnerDocument().createDocumentFragment();
                //                    frag.appendChild(contextNode);
                //                    contextNode = frag;
            }
            dqc.setContextItem(new DocumentWrapper(contextNode, "", config));
        }

        List value = e.evaluate(dqc);
        List value2 = new ArrayList();
        for (Object o : value) {
            Object o2 = o;
            if (o2 instanceof NodeInfo) {
                try {
                    Node o3 = DOMUtils.parse(DOMUtils.domToString(NodeOverNodeInfo.wrap((NodeInfo) o2)))
                            .getDocumentElement();
                    o2 = o3;
                } catch (Exception e1) {
                    throw new RuntimeException("Error converting result", e1);
                }
            }
            value2.add(o2);
        }
        __log.debug("result for expression " + expr + " " + value2 + " value class "
                + (value2 == null ? null : value2.getClass()));
        return value2;
    } catch (XPathException e) {
        __log.error("", e);
        throw new RuntimeException(e);
    } finally {
        contextObjectTL.set(null);
    }
}

From source file:org.eclipse.emf.teneo.mapping.elist.PersistableFeatureMap.java

/** Constructor */
public PersistableFeatureMap(InternalEObject owner, EStructuralFeature feature, List<FeatureMap.Entry> list) {
    super(owner, feature);
    elementType = determineElementType();

    if (list == null) {
        delegate = new ArrayList<FeatureMap.Entry>();
        isLoaded = true;//from   ww  w  .  j a  va2 s .c om
    } else if (list instanceof EList<?>) {
        AssertUtil.assertTrue("The passed elist is not a featuremap but a : " + list.getClass().getName()
                + ". Error in featureMap: " + getLogString(), list instanceof FeatureMap);

        delegate = replaceEntryAll(list);
        isLoaded = true;
    } else {
        delegate = list;
        isLoaded = list.size() > 0;
    }

    logString = "FeatureMap of member " + getEStructuralFeature().getName() + " owned by "
            + owner.getClass().getName() + " with delegate list " + delegate.getClass().getName();

    if (log.isDebugEnabled()) {
        log.debug("Created persistable featuremap " + logString);
    }
}

From source file:org.powertac.visualizer.services.VisualizerServiceTournament.java

public void initOnce() {
    initialized = true;/*from  w ww  . jav  a2s. co m*/

    log.info("initOnce()");
    visualizerBean.newRun();

    dispatcher.initialize();
    // registrations for message listeners:
    List<Initializable> initializers = VisualizerApplicationContext.listBeansOfType(Initializable.class);
    for (Initializable init : initializers) {
        log.debug("initializing..." + init.getClass().getName());
        init.initialize();
    }

    List<DomainRepo> repos = VisualizerApplicationContext.listBeansOfType(DomainRepo.class);
    for (DomainRepo repo : repos) {
        log.debug("recycling..." + repos.getClass().getName());
        repo.recycle();
    }
}

From source file:org.pentaho.platform.engine.services.runtime.SimpleRuntimeElement.java

/**
 * Sets a list property in the paramMap. Special implementation note - Null values aren't supported in the Map.
 * So, if a null value is passed in, this implementation will remove the entry from the map.
 * //from  ww  w  . j  a v a2  s .c om
 * @param key
 *          The key in the map.
 * @param value
 *          The list property to set.
 */
public void setListProperty(final String key, final List value) {
    this.updateOk();
    trace(Messages.getInstance().getString("RTREPO.DEBUG_PROPERTY_GETSET", "setList", key)); //$NON-NLS-1$ //$NON-NLS-2$
    Map theMap = getParamMapCPLX();
    if (value != null) {
        checkType(key, value.getClass().getName(), true);
        theMap.put(key, value);
    } else {
        theMap.remove(key);
    }
}

From source file:de.javakaffee.kryoserializers.KryoTest.java

@Test(enabled = true)
public void testSingletonList() throws Exception {
    final List<?> obj = Collections.singletonList("foo");
    final List<?> deserialized = deserialize(serialize(obj), obj.getClass());
    assertDeepEquals(deserialized, obj);
}