Example usage for java.util Collections EMPTY_MAP

List of usage examples for java.util Collections EMPTY_MAP

Introduction

In this page you can find the example usage for java.util Collections EMPTY_MAP.

Prototype

Map EMPTY_MAP

To view the source code for java.util Collections EMPTY_MAP.

Click Source Link

Document

The empty map (immutable).

Usage

From source file:se.uu.it.cs.recsys.ruleminer.impl.FPGrowthImpl.java

/**
 *
 * @param singlePrefixPath, ordered single prefix path from a FP Tree
 * @return pairs of (frequent pattern, its support); returns empty map if
 * input is null or empty//ww  w  . j av  a  2  s.co  m
 */
public static Map<Set<Integer>, Integer> getFrequentPatternFromSinglePrefixPath(List<Item> singlePrefixPath) {
    if (singlePrefixPath == null || singlePrefixPath.isEmpty()) {
        LOGGER.warn("Nonsence to give null or empty input. Do you agree?");
        return Collections.EMPTY_MAP;
    }

    Set<Item> itemSetFromPath = new HashSet<>(singlePrefixPath);

    Set<Set<Item>> powerSet = Sets.powerSet(itemSetFromPath);

    Map<Set<Integer>, Integer> r = new HashMap<>();

    Util.removeEmptySet(powerSet).forEach(itemSet -> {
        int localMinSupport = FPTreeUtil.getMinSupport(itemSet);

        r.put(itemSet.stream().map(item -> item.getId()).collect(Collectors.toSet()), localMinSupport);
    });

    return r;
}

From source file:org.apache.cayenne.access.DataDomain.java

private void init(String name) {

    this.filters = new CopyOnWriteArrayList<DataChannelFilter>();
    this.nodesByDataMapName = new ConcurrentHashMap<String, DataNode>();
    this.nodes = new ConcurrentHashMap<String, DataNode>();

    // properties are read-only, so no need for concurrent map, or any specific map
    // for that matter
    this.properties = Collections.EMPTY_MAP;

    setName(name);/*  ww  w. j  av a  2 s  . c o  m*/
}

From source file:msi.gaml.types.GamaType.java

@Override
public Map<String, OperatorProto> getFieldGetters() {
    return getters == null ? Collections.EMPTY_MAP : getters;
}

From source file:com.tesora.dve.common.catalog.CatalogDAO.java

@SuppressWarnings("unchecked")
public List<CatalogEntity> queryCatalogEntity(String queryStr) {
    return queryCatalogEntity(queryStr, Collections.EMPTY_MAP);
}

From source file:com.adobe.ags.curly.test.ErrorBehaviorTest.java

@Test
public void testHalt() throws IOException, ParseException {
    ApplicationState.getInstance().errorBehaviorProperty().set(ErrorBehavior.HALT);
    Action fail1 = failureAction();
    Action fail2 = failureAction();
    List<Action> actions = Arrays.asList(fail1, fail2);
    ActionGroupRunner runner = new ActionGroupRunner("Action Halt Test", ignore -> client, actions,
            Collections.EMPTY_MAP, Collections.EMPTY_SET);
    runner.run();//from  w  w  w.jav  a2  s.c  o m
    assertResults(runner.getResult(), false, false);
    assertFalse(ApplicationState.getInstance().runningProperty().get());
}

From source file:org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity.ProportionalCapacityPreemptionPolicy.java

@SuppressWarnings("unchecked")
@VisibleForTesting//from   w  ww . ja va 2s. c  om
public ProportionalCapacityPreemptionPolicy(RMContext context, CapacityScheduler scheduler, Clock clock) {
    init(context.getYarnConfiguration(), context, scheduler);
    this.clock = clock;
    allPartitions = Collections.EMPTY_SET;
    leafQueueNames = Collections.EMPTY_SET;
    preemptableQueues = Collections.EMPTY_MAP;
}

From source file:edu.mayo.qdm.executor.drools.DroolsExecutor.java

public void doExecuteBatch(Iterable<Patient> patients, KnowledgeBase knowledgeBase,
        MeasurementPeriod measurementPeriod, Map<String, String> valueSetDefinitions, ResultCallback callback) {
    final StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();

    try {//from w ww .  j av a 2s  .c  o m
        if (this.log.isDebugEnabled()) {
            ksession.addEventListener(new DefaultWorkingMemoryEventListener() {

                @Override
                public void objectInserted(ObjectInsertedEvent event) {
                    Object obj = event.getObject();
                    if (obj instanceof PreconditionResult) {
                        PreconditionResult precondition = (PreconditionResult) obj;
                        log.debug("Inserting Fact - Precondition: `" + precondition.getId() + "`, Patient: "
                                + precondition.getPatient());
                    } else {
                        log.debug("Inserting Fact: " + obj.toString());
                    }
                }

                @Override
                public void objectRetracted(ObjectRetractedEvent event) {
                    Object obj = event.getOldObject();
                    if (obj instanceof PreconditionResult) {
                        PreconditionResult precondition = (PreconditionResult) obj;
                        log.debug("Retracting Fact - Precondition: `" + precondition.getId() + "`, Patient: "
                                + precondition.getPatient());
                    } else {
                        log.debug("Retracting Fact: " + obj.toString());
                    }
                }

            });
        }

        ksession.setGlobal("droolsUtil", this.droolsUtil);
        ksession.setGlobal("measurementPeriod", measurementPeriod);
        ksession.setGlobal("valueSetDefinitions",
                valueSetDefinitions != null ? valueSetDefinitions : Collections.EMPTY_MAP);

        for (Patient patient : patients) {
            ksession.insert(patient);
        }

        ksession.fireAllRules();

        Collection<FactHandle> handles = ksession.getFactHandles(new ObjectFilter() {
            @Override
            public boolean accept(Object object) {
                return (object instanceof PreconditionResult) && ((PreconditionResult) object).isPopulation();
            }
        });

        for (FactHandle handle : handles) {
            PreconditionResult precondition = (PreconditionResult) ksession.getObject(handle);
            callback.hit(precondition.getId(), precondition.getPatient());
        }
    } finally {
        ksession.dispose();
    }
}

From source file:org.geoserver.wms.wms_1_1_1.GetMapIntegrationTest.java

@Override
protected void onSetUp(SystemTestData testData) throws Exception {
    super.onSetUp(testData);
    Catalog catalog = getCatalog();/* w  w w. j  av a 2 s .  c om*/
    testData.addStyle("Population", "Population.sld", GetMapIntegrationTest.class, catalog);
    testData.addVectorLayer(new QName(MockData.SF_URI, "states", MockData.SF_PREFIX), Collections.EMPTY_MAP,
            "states.properties", getClass(), catalog);
    // add a parametric style to the mix
    testData.addStyle("parametric", "parametric.sld", org.geoserver.wms.map.GetMapIntegrationTest.class,
            catalog);

    // add a translucent style to the mix
    testData.addStyle("translucent", "translucent.sld", GetMapIntegrationTest.class, catalog);

    testData.addStyle("raster", "raster.sld", SystemTestData.class, catalog);
    testData.addStyle("demTranslucent", "demTranslucent.sld", GetMapIntegrationTest.class, catalog);

    Map properties = new HashMap();
    properties.put(LayerProperty.STYLE, "raster");
    testData.addRasterLayer(new QName(MockData.SF_URI, "mosaic_holes", MockData.SF_PREFIX), "mosaic_holes.zip",
            null, properties, GetMapIntegrationTest.class, catalog);
}

From source file:org.apache.struts2.components.URL.java

public boolean start(Writer writer) {
    boolean result = super.start(writer);

    if (value != null) {
        value = findString(value);/*from  w w  w .  j a  va 2s. co  m*/
    }

    // no explicit url set so attach params from current url, do
    // this at start so body params can override any of these they wish.
    try {
        // ww-1266
        String includeParams = (urlIncludeParams != null ? urlIncludeParams.toLowerCase() : GET);

        if (this.includeParams != null) {
            includeParams = findString(this.includeParams);
        }

        if (NONE.equalsIgnoreCase(includeParams)) {
            mergeRequestParameters(value, parameters, Collections.EMPTY_MAP);
        } else if (ALL.equalsIgnoreCase(includeParams)) {
            mergeRequestParameters(value, parameters, req.getParameterMap());

            // for ALL also include GET parameters
            includeGetParameters();
            includeExtraParameters();
        } else if (GET.equalsIgnoreCase(includeParams)
                || (includeParams == null && value == null && action == null)) {
            includeGetParameters();
            includeExtraParameters();
        } else if (includeParams != null) {
            LOG.warn("Unknown value for includeParams parameter to URL tag: " + includeParams);
        }
    } catch (Exception e) {
        LOG.warn("Unable to put request parameters (" + req.getQueryString() + ") into parameter map.", e);
    }

    return result;
}

From source file:com.adaptris.core.marshaller.xstream.AliasedElementReflectionConverter.java

protected void doMarshal(final Object source, final HierarchicalStreamWriter writer,
        final MarshallingContext context) {
    final List<FieldInfo> fields = new ArrayList<>();
    final Map<String, java.lang.reflect.Field> defaultFieldDefinition = new HashMap<>();

    // Attributes might be preferred to child elements ...
    reflectionProvider.visitSerializableFields(source, new ReflectionProvider.Visitor() {
        final Set<String> writtenAttributes = new HashSet<>();

        public void visit(String fieldName, Class type, Class definedIn, Object value) {
            if (!mapper.shouldSerializeMember(definedIn, fieldName)) {
                return;
            }//from ww w .j ava2 s.c o  m
            if (!defaultFieldDefinition.containsKey(fieldName)) {
                Class lookupType = source.getClass();
                // See XSTR-457 and OmitFieldsTest
                if (definedIn != source.getClass() && !mapper.shouldSerializeMember(lookupType, fieldName)) {
                    lookupType = definedIn;
                }
                defaultFieldDefinition.put(fieldName, reflectionProvider.getField(lookupType, fieldName));
            }

            SingleValueConverter converter = mapper.getConverterFromItemType(fieldName, type, definedIn);
            if (converter != null) {
                final String attribute = mapper
                        .aliasForAttribute(mapper.serializedMember(definedIn, fieldName));
                if (value != null) {
                    if (writtenAttributes.contains(fieldName)) { // TODO: use attribute
                        throw new ConversionException("Cannot write field with name '" + fieldName
                                + "' twice as attribute for object of type " + source.getClass().getName());
                    }
                    final String str = converter.toString(value);
                    if (str != null) {
                        writer.addAttribute(attribute, str);
                    }
                }
                writtenAttributes.add(fieldName); // TODO: use attribute
            } else {
                fields.add(new FieldInfo(fieldName, type, definedIn, value));
            }
        }
    });

    new Object() {
        {
            for (Iterator<FieldInfo> fieldIter = fields.iterator(); fieldIter.hasNext();) {
                FieldInfo info = (FieldInfo) fieldIter.next();
                // Check if the field is not null, we don't output null fields
                if (info.value != null) {
                    Mapper.ImplicitCollectionMapping mapping = mapper
                            .getImplicitCollectionDefForFieldName(source.getClass(), info.fieldName);
                    if (mapping != null) {
                        if (context instanceof ReferencingMarshallingContext) {
                            if (info.value != Collections.EMPTY_LIST && info.value != Collections.EMPTY_SET
                                    && info.value != Collections.EMPTY_MAP) {
                                ReferencingMarshallingContext refContext = (ReferencingMarshallingContext) context;
                                refContext.registerImplicit(info.value);
                            }
                        }
                        final boolean isCollection = info.value instanceof Collection;
                        final boolean isMap = info.value instanceof Map;
                        final boolean isEntry = isMap && mapping.getKeyFieldName() == null;
                        final boolean isArray = info.value.getClass().isArray();

                        for (Iterator iter = isArray ? new ArrayIterator(info.value)
                                : isCollection ? ((Collection) info.value).iterator()
                                        : isEntry ? ((Map) info.value).entrySet().iterator()
                                                : ((Map) info.value).values().iterator(); iter.hasNext();) {
                            Object obj = iter.next();
                            final String itemName;
                            final Class itemType;
                            if (obj == null) {
                                itemType = Object.class;
                                itemName = mapper.serializedClass(null);
                            } else if (isEntry) {
                                final String entryName = mapping.getItemFieldName() != null
                                        ? mapping.getItemFieldName()
                                        : mapper.serializedClass(Map.Entry.class);
                                Map.Entry entry = (Map.Entry) obj;
                                ExtendedHierarchicalStreamWriterHelper.startNode(writer, entryName,
                                        entry.getClass());
                                writeItem(entry.getKey(), context, writer);
                                writeItem(entry.getValue(), context, writer);
                                writer.endNode();
                                continue;
                            } else if (mapping.getItemFieldName() != null) {
                                itemType = mapping.getItemType();
                                itemName = mapping.getItemFieldName();
                            } else {
                                itemType = obj.getClass();
                                itemName = mapper.serializedClass(itemType);
                            }
                            writeField(info.fieldName, itemName, itemType, info.definedIn, obj);
                        }
                    }
                    // Field is not an implicit collection
                    else {
                        writeField(info.fieldName, null, info.type, info.definedIn, info.value);
                    }
                }
            }
        }

        //      void writeFieldStandard(String fieldName, String aliasName, Class fieldType, Class definedIn, Object newObj) {
        //        Class actualType = newObj != null ? newObj.getClass() : fieldType;
        //        ExtendedHierarchicalStreamWriterHelper.startNode(
        //            writer,
        //            aliasName != null ? aliasName : mapper.serializedMember(
        //                source.getClass(), fieldName), actualType);
        //
        //        // We don't process null fields (field values)
        //        if (newObj != null) {
        //          Class defaultType = mapper.defaultImplementationOf(fieldType);
        //          if (!actualType.equals(defaultType)) {
        //            String serializedClassName = mapper.serializedClass(actualType);
        //            if (!serializedClassName
        //                .equals(mapper.serializedClass(defaultType))) {
        //              String attributeName = mapper.aliasForSystemAttribute("class");
        //              if (attributeName != null) {
        //                writer.addAttribute(attributeName, serializedClassName);
        //              }
        //            }
        //          }
        //
        //          final Field defaultField = (Field) defaultFieldDefinition
        //              .get(fieldName);
        //          if (defaultField.getDeclaringClass() != definedIn) {
        //            String attributeName = mapper.aliasForSystemAttribute("defined-in");
        //            if (attributeName != null) {
        //              writer.addAttribute(attributeName,
        //                  mapper.serializedClass(definedIn));
        //            }
        //          }
        //
        //          Field field = reflectionProvider.getField(definedIn, fieldName);
        //          marshallField(context, newObj, field);
        //        }
        //        writer.endNode();
        //      }

        // Modified version of method from that super class
        void writeField(String fieldName, String aliasName, Class fieldType, Class definedIn, Object newObj) {
            Class<?> actualType = newObj != null ? newObj.getClass() : fieldType;
            String elementName = aliasName != null ? aliasName
                    : mapper.serializedMember(source.getClass(), fieldName);

            String classAttributeName = null;
            String definedAttributeName = null;
            // We don't process null fields (field values)
            if (newObj != null) {
                Class defaultType = mapper.defaultImplementationOf(fieldType);
                if (!actualType.equals(defaultType)) {
                    String serializedClassName = mapper.serializedClass(actualType);
                    if (!serializedClassName.equals(mapper.serializedClass(defaultType))) {
                        classAttributeName = mapper.aliasForSystemAttribute("class");
                    }
                }

                final Field defaultField = (Field) defaultFieldDefinition.get(fieldName);
                if (defaultField.getDeclaringClass() != definedIn) {
                    definedAttributeName = mapper.aliasForSystemAttribute("defined-in");
                }
            }

            writeOutElementBasedOnClassType(elementName, definedIn, actualType, classAttributeName,
                    definedAttributeName);
            if (newObj != null) {
                Field field = reflectionProvider.getField(definedIn, fieldName);
                marshallField(context, newObj, field);
            }
            writer.endNode();
        }

        // Now where the super class would have written out the field name
        // followed by a class attribute that contained the subclass name,
        // we will write out the subclass alias name as the element with no
        // class attribute at all.
        private void writeOutElementBasedOnClassType(String elementName, Class definedIn, Class<?> actualType,
                String classAttributeName, String definedAttributeName) {
            boolean isClassAttributeSet = !StringUtils.isBlank(classAttributeName);
            if (isClassAttributeSet) {
                String serializedClassName = mapper.serializedClass(actualType);
                ExtendedHierarchicalStreamWriterHelper.startNode(writer, serializedClassName, actualType);
            } else {
                String serializedClassName = mapper.serializedClass(actualType);

                ExtendedHierarchicalStreamWriterHelper.startNode(writer, elementName, actualType);
                if (classAttributeName != null) {
                    writer.addAttribute(classAttributeName, serializedClassName);
                }
                if (definedAttributeName != null) {
                    writer.addAttribute(definedAttributeName, mapper.serializedClass(definedIn));
                }
            }
        }

        void writeItem(Object item, MarshallingContext context, HierarchicalStreamWriter writer) {
            if (item == null) {
                String name = mapper.serializedClass(null);
                ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, Mapper.Null.class);
                writer.endNode();
            } else {
                String name = mapper.serializedClass(item.getClass());
                ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, item.getClass());
                context.convertAnother(item);
                writer.endNode();
            }
        }
    };
}