Replace the type specification in this constructor call with the diamond operator
and other small fixes
Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Issue-ID: POLICY-2760
Change-Id: I83821859a4a1dbbffbaeae15281abac2de3b5712
writer.println(e.getMessage());
executionStatus.setRight(executionStatus.getRight() + 1);
LOGGER.debug(COMMAND_LINE_ERROR, e);
- continue;
} catch (final Exception e) {
e.printStackTrace(writer);
LOGGER.error(COMMAND_LINE_ERROR, e);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
/**
/**
* This method merges the next set of quotes.
- *
+ *
* @param wordsSplitOnQuotes the words split on quotes
* @param wordsWithQuotesMerged the merged words
* @param wordIndex the current word index
/**
* Strip and split a word on blanks into an array of words split on blanks.
- *
+ *
* @param word the word to split
* @return the array of split words
*/
// Split on space characters
final String[] splitWords = singleSpaceWord.split(" ");
- for (final String splitWord : splitWords) {
- strippedAndSplitWords.add(splitWord);
- }
+ Collections.addAll(strippedAndSplitWords, splitWords);
return strippedAndSplitWords;
}
if (argValue instanceof String && !key.equals("o")) {
cliArgsList.add("-" + key);
cliArgsList.add(argValue.toString());
- } else if (argValue instanceof Boolean && (Boolean) argValue) {
+ } else if (argValue instanceof Boolean && (boolean) argValue) {
cliArgsList.add("-" + key);
}
} catch (Exception e) {
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
SlidingWindowList<Counter> valueList;
if (!cache.containsKey(host)) {
- cache.put(host, new HashMap<String, List<Counter>>());
+ cache.put(host, new HashMap<>());
}
if (cache.get(host).containsKey(id)) {
/**
* Get an engine service facade for sending REST requests. This method is package because it is used by unit test.
- *
+ *
* @param hostName the host name of the Apex engine
* @param port the port of the Apex engine
* @return the engine service facade
if (this == obj) {
return true;
}
-
+
if (!super.equals(obj)) {
return false;
}
-
+
if (getClass() != obj.getClass()) {
return false;
}
-
+
@SuppressWarnings("unchecked")
SlidingWindowList<V> other = (SlidingWindowList<V>) obj;
if (!getOuterType().equals(other.getOuterType())) {
return false;
}
-
+
return maxEntries == other.maxEntries;
}
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
if (messageHolder != null) {
final List<M> messages = messageHolder.getMessages();
if (messages != null) {
- messageBlockQueue.add(new MessageBlock<M>(messages, incomingData.getConn()));
+ messageBlockQueue.add(new MessageBlock<>(messages, incomingData.getConn()));
}
}
} catch (final IOException | ClassNotFoundException e) {
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param key the key of the concept
*/
public AxKeyInformation(final AxArtifactKey key) {
- this(key, new TreeMap<AxArtifactKey, AxKeyInfo>());
+ this(key, new TreeMap<>());
}
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param key the key of the context album container
*/
public AxContextAlbums(final AxArtifactKey key) {
- this(key, new TreeMap<AxArtifactKey, AxContextAlbum>());
+ this(key, new TreeMap<>());
}
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param key the key of the context album container
*/
public AxContextSchemas(final AxArtifactKey key) {
- this(key, new TreeMap<AxArtifactKey, AxContextSchema>());
+ this(key, new TreeMap<>());
}
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param key the key of the event
*/
public AxEvent(final AxArtifactKey key) {
- this(key, "", "", "", new TreeMap<String, AxField>());
+ this(key, "", "", "", new TreeMap<>());
}
/**
* @param nameSpace the name space of the event
*/
public AxEvent(final AxArtifactKey key, final String nameSpace) {
- this(key, nameSpace, "", "", new TreeMap<String, AxField>());
+ this(key, nameSpace, "", "", new TreeMap<>());
}
/**
* @param target the target of the event
*/
public AxEvent(final AxArtifactKey key, final String nameSpace, final String source, final String target) {
- this(key, nameSpace, source, target, new TreeMap<String, AxField>());
+ this(key, nameSpace, source, target, new TreeMap<>());
}
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param key the event container key
*/
public AxEvents(final AxArtifactKey key) {
- this(key, new TreeMap<AxArtifactKey, AxEvent>());
+ this(key, new TreeMap<>());
}
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param key the key
*/
public AxPolicies(final AxArtifactKey key) {
- this(key, new TreeMap<AxArtifactKey, AxPolicy>());
+ this(key, new TreeMap<>());
}
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param key the key of the policy
*/
public AxPolicy(final AxArtifactKey key) {
- this(key, "", new TreeMap<String, AxState>(), "");
+ this(key, "", new TreeMap<>(), "");
}
/**
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
this(new AxStateParamsBuilder()
.key(key) // Key
.trigger(AxArtifactKey.getNullKey()) // Trigger Reference
- .stateOutputs(new TreeMap<String, AxStateOutput>()) // State Outputs
- .contextAlbumReferenceSet(new TreeSet<AxArtifactKey>()) // Context Album Refs
+ .stateOutputs(new TreeMap<>()) // State Outputs
+ .contextAlbumReferenceSet(new TreeSet<>()) // Context Album Refs
.taskSelectionLogic(new AxTaskSelectionLogic()) // Task Selection Logic
- .stateFinalizerLogicMap(new TreeMap<String, AxStateFinalizerLogic>()) // State Finalizer Logics
+ .stateFinalizerLogicMap(new TreeMap<>()) // State Finalizer Logics
.defaultTask(AxArtifactKey.getNullKey()) // Default Task
- .taskReferenceMap(new TreeMap<AxArtifactKey, AxStateTaskReference>()) // Task References
+ .taskReferenceMap(new TreeMap<>()) // Task References
);
// @formatter:on
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
public AxTask(final AxArtifactKey key) {
this(key, // Task Key
- new TreeMap<String, AxInputField>(), // Input fields
- new TreeMap<String, AxOutputField>(), // Output Fields
- new TreeMap<String, AxTaskParameter>(), // Task Parameters
- new TreeSet<AxArtifactKey>(), // Context Album References
+ new TreeMap<>(), // Input fields
+ new TreeMap<>(), // Output Fields
+ new TreeMap<>(), // Task Parameters
+ new TreeSet<>(), // Context Album References
new AxTaskLogic(new AxReferenceKey(key)) // Task Logic
);
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param key the key
*/
public AxTasks(final AxArtifactKey key) {
- this(key, new TreeMap<AxArtifactKey, AxTask>());
+ this(key, new TreeMap<>());
}
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
*/
public PolicyAnalysisResult(final AxPolicyModel policyModel) {
for (final AxArtifactKey contextSchemaKey : policyModel.getSchemas().getSchemasMap().keySet()) {
- contextSchemaUsage.put(contextSchemaKey, new TreeSet<AxKey>());
+ contextSchemaUsage.put(contextSchemaKey, new TreeSet<>());
}
for (final Entry<AxArtifactKey, AxContextAlbum> contextAlbumEntry : policyModel.getAlbums().getAlbumsMap()
.entrySet()) {
- contextAlbumUsage.put(contextAlbumEntry.getKey(), new TreeSet<AxKey>());
+ contextAlbumUsage.put(contextAlbumEntry.getKey(), new TreeSet<>());
}
for (final AxArtifactKey eventKey : policyModel.getEvents().getEventMap().keySet()) {
- eventUsage.put(eventKey, new TreeSet<AxKey>());
+ eventUsage.put(eventKey, new TreeSet<>());
}
for (final AxArtifactKey taskKey : policyModel.getTasks().getTaskMap().keySet()) {
- taskUsage.put(taskKey, new TreeSet<AxKey>());
+ taskUsage.put(taskKey, new TreeSet<>());
}
}
}
}
- kafkaProducer.send(new ProducerRecord<String, Object>(kafkaProducerProperties.getProducerTopic(), name, event));
+ kafkaProducer.send(new ProducerRecord<>(kafkaProducerProperties.getProducerTopic(), name, event));
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("event sent from engine using {} to topic {} : {} ", this.name,
kafkaProducerProperties.getProducerTopic(), event);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
/**
* This class holds a cache of the synchronous events sent into Apex and that have not yet been replied to. It runs a
* thread to time out events that have not been replied to in the specified timeout.
- *
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class SynchronousEventCache extends PeeredReference implements Runnable {
/**
* Create a synchronous event cache that caches outstanding synchronous Apex events.
- *
+ *
* @param peeredMode the peered mode for which to return the reference
* @param consumer the consumer that is populating the cache
* @param producer the producer that is emptying the cache
/**
* Remove the record of an event sent to Apex if it exists in the cache.
- *
+ *
* @param executionId the execution ID of the event
* @return The removed event
*/
/**
* Check if an event exists in the to apex cache.
- *
+ *
* @param executionId the execution ID of the event
* @return true if the event exists, false otherwise
*/
/**
* Remove the record of an event received from Apex if it exists in the cache.
- *
+ *
* @param executionId the execution ID of the event
* @return The removed event
*/
/**
* Check if an event exists in the from apex cache.
- *
+ *
* @param executionId the execution ID of the event
* @return true if the event exists, false otherwise
*/
/**
* Cache a synchronized event sent in an event cache.
- *
+ *
* @param eventCacheMap the map to cache the event on
* @param executionId the execution ID of the event
* @param event the event to cache
}
// Add the event to the map
- eventCacheMap.put(executionId, new SimpleEntry<Long, Object>(System.currentTimeMillis(), event));
+ eventCacheMap.put(executionId, new SimpleEntry<>(System.currentTimeMillis(), event));
if (LOGGER.isDebugEnabled()) {
String message = "event has been cached:" + event;
/**
* Remove the record of an event if it exists in the cache.
- *
+ *
* @param eventCacheMap the map to remove the event from
* @param executionId the execution ID of the event
* @return The removed event
/**
* Time out events on an event cache map. Events that have a timeout longer than the configured timeout are timed
* out.
- *
+ *
* @param eventCacheMap the event cache to operate on
*/
private void timeoutEventsOnCache(final Map<Long, SimpleEntry<Long, Object>> eventCacheMap) {