Example usage for java.util Deque addLast

List of usage examples for java.util Deque addLast

Introduction

In this page you can find the example usage for java.util Deque addLast.

Prototype

void addLast(E e);

Source Link

Document

Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

Usage

From source file:Main.java

public static void main(String[] args) {
    Deque<String> deque = new LinkedList<>();
    deque.addLast("Oracle");
    deque.offerLast("Java");
    deque.offerLast("CSS");
    deque.offerLast("XML");

    System.out.println("Deque: " + deque);

    // remove elements from the Deque until it is empty
    while (deque.peekFirst() != null) {
        System.out.println("Head  Element: " + deque.peekFirst());
        deque.removeFirst();/*from w w w.  j av  a  2 s  .  co  m*/
        System.out.println("Removed one  element from  Deque");
        System.out.println("Deque: " + deque);
    }

    // the Deque is empty. Try to call its peekFirst(),
    // getFirst(), pollFirst() and removeFirst() methods
    System.out.println("deque.isEmpty(): " + deque.isEmpty());

    System.out.println("deque.peekFirst(): " + deque.peekFirst());
    System.out.println("deque.pollFirst(): " + deque.pollFirst());

    String str = deque.getFirst();
    System.out.println("deque.getFirst(): " + str);
    str = deque.removeFirst();
    System.out.println("deque.removeFirst(): " + str);

}

From source file:Main.java

public static void main(String[] args) {

    Deque<Integer> deque = new ArrayDeque<Integer>(8);

    deque.add(20);/*  www  .jav  a  2 s  . com*/
    deque.add(30);
    deque.add(20);
    deque.add(18);
    deque.add(22);
    deque.add(24);

    deque.addLast(10);
    deque.addLast(12);

    System.out.println(deque);
}

From source file:com.qcadoo.model.api.utils.TreeNumberingServiceImpl.java

public static void incrementLastChainNumber(final Deque<String> chain) {
    Integer nextNumber = Integer.valueOf(chain.pollLast()) + 1;
    chain.addLast(nextNumber.toString());
}

From source file:com.qcadoo.model.api.utils.TreeNumberingServiceImpl.java

public static void incrementLastChainCharacter(final Deque<String> chain, final int charNumber) {
    int quotient = charNumber / 26;
    int modulo = charNumber % 26;

    if (quotient <= 0) {
        chain.addLast(String.valueOf((char) (65 + charNumber)));
    } else {//from   w w  w .ja va2 s  . c om
        chain.addLast(
                String.valueOf((char) (65 + (quotient - 1))).concat(String.valueOf((char) (65 + modulo))));
    }

    chain.addLast("1");
}

From source file:ocr.sapphire.image.EdgeBasedImagePreprocessor.java

/**
 * <p>Rotate the component so that the first point is the leftmost.</p>
 * <p>Normalization doesnot make difference when reverse the Fourier series
 * but neuron networks may "feel" easier to recorgnize normalized series.</p>
 * @param points//  ww w. j a v a  2s.  c  o m
 * @return
 */
private static Deque<Point> normalize(Deque<Point> c) {
    double leftmost = Double.MAX_VALUE;
    for (Point p : c) {
        if (p.x < leftmost) {
            leftmost = p.x;
        }
    }
    while (c.getFirst().x > leftmost) {
        c.addLast(c.removeFirst());
    }
    return c;
}

From source file:ocr.sapphire.image.EdgeBasedImagePreprocessor.java

/**
 * Join b to a, return a./*from  www  .  ja  va2s  .  c o  m*/
 * @param a
 * @param afirst join at the first point of a?
 * @param b
 * @param bfirst join at the first point of b?
 * @return
 */
private static Deque<Point> join(Deque<Point> a, boolean afirst, Deque<Point> b, boolean bfirst) {
    if (!bfirst) {
        Collections.reverse((List<Point>) b);
    }
    // don't reverse a, may confuse the network
    if (afirst) {
        for (Point p : b) {
            a.addFirst(p);
        }
    } else {
        for (Point p : b) {
            a.addLast(p);
        }
    }
    return a;
}

From source file:org.nickelproject.util.testUtil.ClasspathUtil.java

private static Iterable<String> getAllSubClasses(final Class<?>... pTags) {
    final Deque<String> vClassNames = Lists.newLinkedList();
    final Set<String> vResults = Sets.newHashSet();
    for (final Class<?> vClass : pTags) {
        vClassNames.add(vClass.getCanonicalName());
    }/*from  w  w  w  .jav  a2  s .  c om*/
    while (!vClassNames.isEmpty()) {
        final String vCurrentClass = vClassNames.pollFirst();
        for (final String vChild : kChildren.get(vCurrentClass)) {
            vClassNames.addLast(vChild);
            vResults.add(vChild);
        }
    }
    return vResults;
}

From source file:cz.cuni.mff.ksi.jinfer.autoeditor.automatonvisualizer.layouts.AutomatonToDot.java

public String convertToDot(Automaton<T> automaton, Transformer<Step<T>, String> edgeLabelTransformer) {
    StringBuilder sb = new StringBuilder();
    sb.append("digraph finite_state_machine {\n" + "\trankdir=LR;\n" + "\tnode [shape = circle];\n");
    List<State<T>> finiteStates = new LinkedList<State<T>>();
    Deque<State<T>> queue = new ArrayDeque<State<T>>();
    Set<State<T>> visited = new HashSet<State<T>>();
    queue.addLast(automaton.getInitialState());
    visited.add(automaton.getInitialState());
    while (!queue.isEmpty()) {
        State<T> actual = queue.removeFirst();
        if (actual.getFinalCount() > 0) {
            finiteStates.add(actual);//from  ww w.  j  a  v a2 s  .  c o  m
        }
        for (Step<T> step : automaton.getDelta().get(actual)) {
            sb.append("\t");
            sb.append(step.getSource().getName());
            sb.append(" -> ");
            sb.append(step.getDestination().getName());
            sb.append(" [ label = \"");
            sb.append(edgeLabelTransformer.transform(step));
            sb.append("|");
            sb.append(step.getUseCount());
            sb.append("\" ];\n");
            if (!visited.contains(step.getDestination())) {
                queue.addLast(step.getDestination());
                visited.add(step.getDestination());
            }
        }
    }
    sb.append("\n}");
    return sb.toString();
}

From source file:com.linuxbox.enkive.message.MultiPartHeaderImpl.java

@Override
public void generateAttachmentSummaries(List<AttachmentSummary> result, Deque<Integer> positionsAbove) {
    int counter = 1;
    for (ContentHeader header : getPartHeaders()) {
        positionsAbove.addLast(counter);
        header.generateAttachmentSummaries(result, positionsAbove);
        positionsAbove.removeLast();// w  w w  .j  a  v  a  2  s .  c  om
        ++counter;
    }
}

From source file:com.espertech.esper.epl.spec.PatternStreamSpecRaw.java

private static void recursiveCompile(EvalFactoryNode evalNode, StatementContext context,
        ExprEvaluatorContext evaluatorContext, Set<String> eventTypeReferences, boolean isInsertInto,
        MatchEventSpec tags, Deque<Integer> subexpressionIdStack, Stack<EvalFactoryNode> parentNodeStack,
        LinkedHashSet<String> allTagNamesOrdered) throws ExprValidationException {
    int counter = 0;
    parentNodeStack.push(evalNode);/*from   w  w w .j  ava 2 s  .co  m*/
    for (EvalFactoryNode child : evalNode.getChildNodes()) {
        subexpressionIdStack.addLast(counter++);
        recursiveCompile(child, context, evaluatorContext, eventTypeReferences, isInsertInto, tags,
                subexpressionIdStack, parentNodeStack, allTagNamesOrdered);
        subexpressionIdStack.removeLast();
    }
    parentNodeStack.pop();

    LinkedHashMap<String, Pair<EventType, String>> newTaggedEventTypes = null;
    LinkedHashMap<String, Pair<EventType, String>> newArrayEventTypes = null;

    if (evalNode instanceof EvalFilterFactoryNode) {
        EvalFilterFactoryNode filterNode = (EvalFilterFactoryNode) evalNode;
        String eventName = filterNode.getRawFilterSpec().getEventTypeName();
        EventType resolvedEventType = FilterStreamSpecRaw.resolveType(context.getEngineURI(), eventName,
                context.getEventAdapterService(), context.getPlugInTypeResolutionURIs());
        EventType finalEventType = resolvedEventType;
        String optionalTag = filterNode.getEventAsName();
        boolean isPropertyEvaluation = false;
        boolean isParentMatchUntil = isParentMatchUntil(evalNode, parentNodeStack);

        // obtain property event type, if final event type is properties
        if (filterNode.getRawFilterSpec().getOptionalPropertyEvalSpec() != null) {
            PropertyEvaluator optionalPropertyEvaluator = PropertyEvaluatorFactory.makeEvaluator(
                    filterNode.getRawFilterSpec().getOptionalPropertyEvalSpec(), resolvedEventType,
                    filterNode.getEventAsName(), context.getEventAdapterService(),
                    context.getMethodResolutionService(), context.getSchedulingService(),
                    context.getVariableService(), context.getEngineURI(), context.getStatementId(),
                    context.getStatementName(), context.getAnnotations(), subexpressionIdStack,
                    context.getConfigSnapshot());
            finalEventType = optionalPropertyEvaluator.getFragmentEventType();
            isPropertyEvaluation = true;
        }

        if (finalEventType instanceof EventTypeSPI) {
            eventTypeReferences.add(((EventTypeSPI) finalEventType).getMetadata().getPrimaryName());
        }

        // If a tag was supplied for the type, the tags must stay with this type, i.e. a=BeanA -> b=BeanA -> a=BeanB is a no
        if (optionalTag != null) {
            Pair<EventType, String> pair = tags.getTaggedEventTypes().get(optionalTag);
            EventType existingType = null;
            if (pair != null) {
                existingType = pair.getFirst();
            }
            if (existingType == null) {
                pair = tags.getArrayEventTypes().get(optionalTag);
                if (pair != null) {
                    throw new ExprValidationException("Tag '" + optionalTag + "' for event '" + eventName
                            + "' used in the repeat-until operator cannot also appear in other filter expressions");
                }
            }
            if ((existingType != null) && (existingType != finalEventType)) {
                throw new ExprValidationException("Tag '" + optionalTag + "' for event '" + eventName
                        + "' has already been declared for events of type "
                        + existingType.getUnderlyingType().getName());
            }
            pair = new Pair<EventType, String>(finalEventType, eventName);

            // add tagged type
            if (isPropertyEvaluation || isParentMatchUntil) {
                newArrayEventTypes = new LinkedHashMap<String, Pair<EventType, String>>();
                newArrayEventTypes.put(optionalTag, pair);
            } else {
                newTaggedEventTypes = new LinkedHashMap<String, Pair<EventType, String>>();
                newTaggedEventTypes.put(optionalTag, pair);
            }
        }

        // For this filter, filter types are all known tags at this time,
        // and additionally stream 0 (self) is our event type.
        // Stream type service allows resolution by property name event if that name appears in other tags.
        // by defaulting to stream zero.
        // Stream zero is always the current event type, all others follow the order of the map (stream 1 to N).
        String selfStreamName = optionalTag;
        if (selfStreamName == null) {
            selfStreamName = "s_" + UuidGenerator.generate();
        }
        LinkedHashMap<String, Pair<EventType, String>> filterTypes = new LinkedHashMap<String, Pair<EventType, String>>();
        Pair<EventType, String> typePair = new Pair<EventType, String>(finalEventType, eventName);
        filterTypes.put(selfStreamName, typePair);
        filterTypes.putAll(tags.getTaggedEventTypes());

        // for the filter, specify all tags used
        LinkedHashMap<String, Pair<EventType, String>> filterTaggedEventTypes = new LinkedHashMap<String, Pair<EventType, String>>(
                tags.getTaggedEventTypes());
        filterTaggedEventTypes.remove(optionalTag);

        // handle array tags (match-until clause)
        LinkedHashMap<String, Pair<EventType, String>> arrayCompositeEventTypes = null;
        if (tags.getArrayEventTypes() != null && !tags.getArrayEventTypes().isEmpty()) {
            arrayCompositeEventTypes = new LinkedHashMap<String, Pair<EventType, String>>();
            String patternSubexEventType = getPatternSubexEventType(context.getStatementId(), "pattern",
                    subexpressionIdStack);

            for (Map.Entry<String, Pair<EventType, String>> entry : tags.getArrayEventTypes().entrySet()) {
                LinkedHashMap<String, Pair<EventType, String>> specificArrayType = new LinkedHashMap<String, Pair<EventType, String>>();
                specificArrayType.put(entry.getKey(), entry.getValue());
                EventType arrayTagCompositeEventType = context.getEventAdapterService()
                        .createSemiAnonymousMapType(patternSubexEventType,
                                Collections.<String, Pair<EventType, String>>emptyMap(), specificArrayType,
                                isInsertInto);

                String tag = entry.getKey();
                if (!filterTypes.containsKey(tag)) {
                    Pair<EventType, String> pair = new Pair<EventType, String>(arrayTagCompositeEventType, tag);
                    filterTypes.put(tag, pair);
                    arrayCompositeEventTypes.put(tag, pair);
                }
            }
        }

        StreamTypeService streamTypeService = new StreamTypeServiceImpl(filterTypes, context.getEngineURI(),
                true, false);
        List<ExprNode> exprNodes = filterNode.getRawFilterSpec().getFilterExpressions();

        FilterSpecCompiled spec = FilterSpecCompiler.makeFilterSpec(resolvedEventType, eventName, exprNodes,
                filterNode.getRawFilterSpec().getOptionalPropertyEvalSpec(), filterTaggedEventTypes,
                arrayCompositeEventTypes, streamTypeService, null, context, subexpressionIdStack);
        filterNode.setFilterSpec(spec);
    } else if (evalNode instanceof EvalObserverFactoryNode) {
        EvalObserverFactoryNode observerNode = (EvalObserverFactoryNode) evalNode;
        try {
            ObserverFactory observerFactory = context.getPatternResolutionService()
                    .create(observerNode.getPatternObserverSpec());

            StreamTypeService streamTypeService = getStreamTypeService(context.getEngineURI(),
                    context.getStatementId(), context.getEventAdapterService(), tags.getTaggedEventTypes(),
                    tags.getArrayEventTypes(), subexpressionIdStack, "observer");
            ExprValidationContext validationContext = new ExprValidationContext(streamTypeService,
                    context.getMethodResolutionService(), null, context.getSchedulingService(),
                    context.getVariableService(), evaluatorContext, context.getEventAdapterService(),
                    context.getStatementName(), context.getStatementId(), context.getAnnotations(),
                    context.getContextDescriptor());
            List<ExprNode> validated = validateExpressions(
                    observerNode.getPatternObserverSpec().getObjectParameters(), validationContext);

            MatchedEventConvertor convertor = new MatchedEventConvertorImpl(tags.getTaggedEventTypes(),
                    tags.getArrayEventTypes(), allTagNamesOrdered, context.getEventAdapterService());

            observerNode.setObserverFactory(observerFactory);
            observerFactory.setObserverParameters(validated, convertor);
        } catch (ObserverParameterException e) {
            throw new ExprValidationException("Invalid parameter for pattern observer: " + e.getMessage(), e);
        } catch (PatternObjectException e) {
            throw new ExprValidationException("Failed to resolve pattern observer: " + e.getMessage(), e);
        }
    } else if (evalNode instanceof EvalGuardFactoryNode) {
        EvalGuardFactoryNode guardNode = (EvalGuardFactoryNode) evalNode;
        try {
            GuardFactory guardFactory = context.getPatternResolutionService()
                    .create(guardNode.getPatternGuardSpec());

            StreamTypeService streamTypeService = getStreamTypeService(context.getEngineURI(),
                    context.getStatementId(), context.getEventAdapterService(), tags.getTaggedEventTypes(),
                    tags.getArrayEventTypes(), subexpressionIdStack, "guard");
            ExprValidationContext validationContext = new ExprValidationContext(streamTypeService,
                    context.getMethodResolutionService(), null, context.getSchedulingService(),
                    context.getVariableService(), evaluatorContext, context.getEventAdapterService(),
                    context.getStatementName(), context.getStatementId(), context.getAnnotations(),
                    context.getContextDescriptor());
            List<ExprNode> validated = validateExpressions(
                    guardNode.getPatternGuardSpec().getObjectParameters(), validationContext);

            MatchedEventConvertor convertor = new MatchedEventConvertorImpl(tags.getTaggedEventTypes(),
                    tags.getArrayEventTypes(), allTagNamesOrdered, context.getEventAdapterService());

            guardNode.setGuardFactory(guardFactory);
            guardFactory.setGuardParameters(validated, convertor);
        } catch (GuardParameterException e) {
            throw new ExprValidationException("Invalid parameter for pattern guard: " + e.getMessage(), e);
        } catch (PatternObjectException e) {
            throw new ExprValidationException("Failed to resolve pattern guard: " + e.getMessage(), e);
        }
    } else if (evalNode instanceof EvalEveryDistinctFactoryNode) {
        EvalEveryDistinctFactoryNode distinctNode = (EvalEveryDistinctFactoryNode) evalNode;
        MatchEventSpec matchEventFromChildNodes = analyzeMatchEvent(distinctNode);
        StreamTypeService streamTypeService = getStreamTypeService(context.getEngineURI(),
                context.getStatementId(), context.getEventAdapterService(),
                matchEventFromChildNodes.getTaggedEventTypes(), matchEventFromChildNodes.getArrayEventTypes(),
                subexpressionIdStack, "every-distinct");
        ExprValidationContext validationContext = new ExprValidationContext(streamTypeService,
                context.getMethodResolutionService(), null, context.getSchedulingService(),
                context.getVariableService(), evaluatorContext, context.getEventAdapterService(),
                context.getStatementName(), context.getStatementId(), context.getAnnotations(),
                context.getContextDescriptor());
        List<ExprNode> validated;
        try {
            validated = validateExpressions(distinctNode.getExpressions(), validationContext);
        } catch (ExprValidationPropertyException ex) {
            throw new ExprValidationPropertyException(ex.getMessage()
                    + ", every-distinct requires that all properties resolve from sub-expressions to the every-distinct",
                    ex.getCause());
        }

        MatchedEventConvertor convertor = new MatchedEventConvertorImpl(
                matchEventFromChildNodes.getTaggedEventTypes(), matchEventFromChildNodes.getArrayEventTypes(),
                allTagNamesOrdered, context.getEventAdapterService());

        distinctNode.setConvertor(convertor);

        // Determine whether some expressions are constants or time period
        List<ExprNode> distinctExpressions = new ArrayList<ExprNode>();
        Long msecToExpire = null;
        for (ExprNode expr : validated) {
            if (expr instanceof ExprTimePeriod) {
                Double secondsExpire = (Double) ((ExprTimePeriod) expr).evaluate(null, true, evaluatorContext);
                if ((secondsExpire != null) && (secondsExpire > 0)) {
                    msecToExpire = Math.round(1000d * secondsExpire);
                }
                log.debug("Setting every-distinct msec-to-expire to " + msecToExpire);
            } else if (expr.isConstantResult()) {
                log.warn(
                        "Every-distinct node utilizes an expression returning a constant value, please check expression '"
                                + expr.toExpressionString()
                                + "', not adding expression to distinct-value expression list");
            } else {
                distinctExpressions.add(expr);
            }
        }
        if (distinctExpressions.isEmpty()) {
            throw new ExprValidationException(
                    "Every-distinct node requires one or more distinct-value expressions that each return non-constant result values");
        }
        distinctNode.setDistinctExpressions(distinctExpressions, msecToExpire);
    } else if (evalNode instanceof EvalMatchUntilFactoryNode) {
        EvalMatchUntilFactoryNode matchUntilNode = (EvalMatchUntilFactoryNode) evalNode;

        // compile bounds expressions, if any
        MatchEventSpec untilMatchEventSpec = new MatchEventSpec(tags.getTaggedEventTypes(),
                tags.getArrayEventTypes());
        StreamTypeService streamTypeService = getStreamTypeService(context.getEngineURI(),
                context.getStatementId(), context.getEventAdapterService(),
                untilMatchEventSpec.getTaggedEventTypes(), untilMatchEventSpec.getArrayEventTypes(),
                subexpressionIdStack, "until");
        ExprValidationContext validationContext = new ExprValidationContext(streamTypeService,
                context.getMethodResolutionService(), null, context.getSchedulingService(),
                context.getVariableService(), evaluatorContext, context.getEventAdapterService(),
                context.getStatementName(), context.getStatementId(), context.getAnnotations(),
                context.getContextDescriptor());

        String message = "Match-until bounds value expressions must return a numeric value";
        if (matchUntilNode.getLowerBounds() != null) {
            ExprNode validated = ExprNodeUtility.getValidatedSubtree(matchUntilNode.getLowerBounds(),
                    validationContext);
            matchUntilNode.setLowerBounds(validated);
            if ((validated.getExprEvaluator().getType() == null)
                    || (!JavaClassHelper.isNumeric(validated.getExprEvaluator().getType()))) {
                throw new ExprValidationException(message);
            }
        }

        if (matchUntilNode.getUpperBounds() != null) {
            ExprNode validated = ExprNodeUtility.getValidatedSubtree(matchUntilNode.getUpperBounds(),
                    validationContext);
            matchUntilNode.setUpperBounds(validated);
            if ((validated.getExprEvaluator().getType() == null)
                    || (!JavaClassHelper.isNumeric(validated.getExprEvaluator().getType()))) {
                throw new ExprValidationException(message);
            }
        }

        MatchedEventConvertor convertor = new MatchedEventConvertorImpl(
                untilMatchEventSpec.getTaggedEventTypes(), untilMatchEventSpec.getArrayEventTypes(),
                allTagNamesOrdered, context.getEventAdapterService());
        matchUntilNode.setConvertor(convertor);

        // compile new tag lists
        Set<String> arrayTags = null;
        EvalNodeAnalysisResult matchUntilAnalysisResult = EvalNodeUtil
                .recursiveAnalyzeChildNodes(matchUntilNode.getChildNodes().get(0));
        for (EvalFilterFactoryNode filterNode : matchUntilAnalysisResult.getFilterNodes()) {
            String optionalTag = filterNode.getEventAsName();
            if (optionalTag != null) {
                if (arrayTags == null) {
                    arrayTags = new HashSet<String>();
                }
                arrayTags.add(optionalTag);
            }
        }

        if (arrayTags != null) {
            for (String arrayTag : arrayTags) {
                if (!tags.getArrayEventTypes().containsKey(arrayTag)) {
                    tags.getArrayEventTypes().put(arrayTag, tags.getTaggedEventTypes().get(arrayTag));
                    tags.getTaggedEventTypes().remove(arrayTag);
                }
            }
        }
        matchUntilNode.setTagsArrayedSet(getIndexesForTags(allTagNamesOrdered, arrayTags));
    } else if (evalNode instanceof EvalFollowedByFactoryNode) {
        EvalFollowedByFactoryNode followedByNode = (EvalFollowedByFactoryNode) evalNode;
        StreamTypeService streamTypeService = new StreamTypeServiceImpl(context.getEngineURI(), false);
        ExprValidationContext validationContext = new ExprValidationContext(streamTypeService,
                context.getMethodResolutionService(), null, context.getSchedulingService(),
                context.getVariableService(), evaluatorContext, context.getEventAdapterService(),
                context.getStatementName(), context.getStatementId(), context.getAnnotations(),
                context.getContextDescriptor());

        if (followedByNode.getOptionalMaxExpressions() != null) {
            List<ExprNode> validated = new ArrayList<ExprNode>();
            for (ExprNode maxExpr : followedByNode.getOptionalMaxExpressions()) {
                if (maxExpr == null) {
                    validated.add(null);
                } else {
                    ExprNodeSummaryVisitor visitor = new ExprNodeSummaryVisitor();
                    maxExpr.accept(visitor);
                    if (!visitor.isPlain()) {
                        String errorMessage = "Invalid maximum expression in followed-by, "
                                + visitor.getMessage() + " are not allowed within the expression";
                        log.error(errorMessage);
                        throw new ExprValidationException(errorMessage);
                    }

                    ExprNode validatedExpr = ExprNodeUtility.getValidatedSubtree(maxExpr, validationContext);
                    validated.add(validatedExpr);
                    if ((validatedExpr.getExprEvaluator().getType() == null)
                            || (!JavaClassHelper.isNumeric(validatedExpr.getExprEvaluator().getType()))) {
                        String message = "Invalid maximum expression in followed-by, the expression must return an integer value";
                        throw new ExprValidationException(message);
                    }
                }
            }
            followedByNode.setOptionalMaxExpressions(validated);
        }
    }

    if (newTaggedEventTypes != null) {
        tags.getTaggedEventTypes().putAll(newTaggedEventTypes);
    }
    if (newArrayEventTypes != null) {
        tags.getArrayEventTypes().putAll(newArrayEventTypes);
    }
}