From 0c4373663e22ffa18d953b2a9ee6f6b27d559bea Mon Sep 17 00:00:00 2001 From: Munir Ahmad Date: Wed, 7 Mar 2018 18:59:13 -0500 Subject: Make use of lambda Change-Id: I482b874a3e7e686068450c7b5ddf45e2b8ae0d47 Issue-ID: SO-437 Signed-off-by: Munir Ahmad --- .../installer/heat/ToscaResourceInstaller.java | 57 ++++++++++------------ .../mso/asdc/util/NotificationLogging.java | 20 +++----- .../core/plugins/LoggingAndURNMappingPlugin.java | 10 +--- 3 files changed, 36 insertions(+), 51 deletions(-) diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java index 591db355c5..8c08d3eb26 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java @@ -419,39 +419,34 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller { toscaResourceStruct.getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID); logger.debug("vfGroups:" + vfGroups.toString()); - vfGroups.sort(new Comparator() { - - @Override - public int compare(Group group1, - Group group2) { - - // Field name1Field = group1.class.getDeclaredField("name"); - // name1Field.setAccessible(true); - String thisName = group1.getName(); // (String) - // name1Field.get(group1); - String thatName = group2.getName(); // (String) - // name1Field.get(group2); - - Matcher m = lastDigit.matcher(thisName); - Matcher m2 = lastDigit.matcher(thatName); - - String thisDigit = "0"; - String thatDigit = "0"; - if (m.find()) { - thisDigit = m.group(); - } else { - return -1; - } - if (m2.find()) { - thatDigit = m2.group(); - } else { - return 1; - } + vfGroups.sort((group1, group2) -> { + + // Field name1Field = group1.class.getDeclaredField("name"); + // name1Field.setAccessible(true); + String thisName = group1.getName(); // (String) + // name1Field.get(group1); + String thatName = group2.getName(); // (String) + // name1Field.get(group2); + + Matcher m = lastDigit.matcher(thisName); + Matcher m2 = lastDigit.matcher(thatName); + + String thisDigit = "0"; + String thatDigit = "0"; + if (m.find()) { + thisDigit = m.group(); + } else { + return -1; + } + if (m2.find()) { + thatDigit = m2.group(); + } else { + return 1; + } - return new Integer(thisDigit).compareTo(new Integer(thatDigit)); + return new Integer(thisDigit).compareTo(new Integer(thatDigit)); - } - }); + }); logger.debug("vfGroupsAfter:" + vfGroups.toString()); diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java index c0a1f53283..f9871b745a 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java @@ -43,19 +43,15 @@ public class NotificationLogging implements InvocationHandler { private static Map> objectMethodsToLog = new HashMap<>(); protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC); - - private static InvocationHandler handler = new InvocationHandler() { - @Override - public Object invoke(Object arg0, Method arg1, Object[] arg2) - throws Throwable { - List methods = objectMethodsToLog.get(arg0); - if ((methods == null) || (methods.isEmpty())) { - // Do nothing for now... - return null; - } - methods.add(arg1); - return arg1.invoke(arg0, arg2); + + private static InvocationHandler handler = (arg0, arg1, arg2) -> { + List methods = objectMethodsToLog.get(arg0); + if ((methods == null) || (methods.isEmpty())) { + // Do nothing for now... + return null; } + methods.add(arg1); + return arg1.invoke(arg0, arg2); }; public static InvocationHandler getHandler() { diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index c346308e2b..730c1451d5 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -321,14 +321,8 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { } private void loadFromDB(DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) { - Command> command = new Command>() { - @SuppressWarnings("unchecked") - @Override - public List execute(CommandContext commandContext) { - return (List) commandContext.getDbSqlSession().selectList( - "mso.urnMapping.selectAll", null); - } - }; + Command> command = commandContext -> (List) commandContext.getDbSqlSession() + .selectList("mso.urnMapping.selectAll", null); CustomMyBatisSessionFactory sessionFactory = new CustomMyBatisSessionFactory(); sessionFactory.initFromProcessEngineConfiguration(processEngineConfiguration, -- cgit 1.2.3-korg