List of usage examples for com.google.common.collect ImmutableSet forEach
default void forEach(Consumer<? super T> action)
From source file:br.com.blackhubos.eventozero.hook.Hooks.java
@SuppressWarnings("unchecked") public static void hookAll() { try {/*from w w w .ja v a 2s. c o m*/ ImmutableSet<ClassInfo> classes = ClassPath.from(classLoader) .getTopLevelClasses("br.com.blackhubos.eventozero.hook.hooks"); classes.forEach(cls -> { try { Class<?> hookClass = Class.forName(cls.getName()); if (!Hook.class.isAssignableFrom(hookClass)) { return; } Hook hookInst = (Hook) hookClass.newInstance(); if (hookInst.canBeHooked()) { hookInst.hook(); hooks.put((Class<Hook>) hookClass, hookInst); logger.info(String.format("[Hooks] %s carregado com sucesso.", cls.getSimpleName())); } } catch (Exception e) { logger.log(Level.SEVERE, "Could not load hook " + cls.getName()); logger.log(Level.SEVERE, "See the stacktrace: "); e.printStackTrace(); } }); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.spectralogic.ds3contractcomparator.print.simpleprinter.Ds3EnumConstantDiffSimplePrinter.java
/** * Prints the changes between two {@link ImmutableList} of {@link Ds3Property}. If both lists are * empty, then nothing is printed./*from w w w. j a va 2s . c o m*/ */ private static void printProperties(final ImmutableList<Ds3Property> oldProperties, final ImmutableList<Ds3Property> newProperties, final boolean printProperties, final WriterHelper writer) { if (!printProperties || (isEmpty(oldProperties) && isEmpty(newProperties))) { //do not print empty values return; } writer.append(indent(INDENT + 1)).append("Properties:").append("\n"); final ImmutableSet<String> propertyNames = getPropertyNameUnion(oldProperties, newProperties); final ImmutableMap<String, Ds3Property> oldPropertyMap = toPropertyMap(oldProperties); final ImmutableMap<String, Ds3Property> newPropertyMap = toPropertyMap(newProperties); propertyNames .forEach(name -> printPropertyDiff(oldPropertyMap.get(name), newPropertyMap.get(name), writer)); }
From source file:com.spectralogic.ds3contractcomparator.print.simpleprinter.Ds3AnnotationDiffSimplePrinter.java
/** * Prints the changes between two {@link ImmutableList} of {@link Ds3AnnotationElement}. If both lists are * empty, then nothing is printed./*from w ww . jav a2 s . co m*/ */ private static void printAnnotationElements(final ImmutableList<Ds3AnnotationElement> oldElements, final ImmutableList<Ds3AnnotationElement> newElements, final WriterHelper writer) { if (isEmpty(oldElements) && isEmpty(newElements)) { //do not print empty values return; } writer.append(indent(INDENT + 1)).append("AnnotationElements:").append("\n"); final ImmutableSet<String> annotationNames = getAnnotationElementNameUnion(oldElements, newElements); final ImmutableMap<String, Ds3AnnotationElement> oldParamMap = toAnnotationElementMap(oldElements); final ImmutableMap<String, Ds3AnnotationElement> newParamMap = toAnnotationElementMap(newElements); annotationNames .forEach(name -> printAnnotationElementDiff(oldParamMap.get(name), newParamMap.get(name), writer)); }
From source file:com.spectralogic.ds3contractcomparator.print.simpleprinter.Ds3RequestDiffSimplePrinter.java
/** * Prints the changes between two {@link ImmutableList} of {@link Ds3Param}. If both lists are * empty, then nothing is printed./*ww w. j a va2s . c o m*/ * @param label Label describing these parameters, such as RequiredParameters or OptionalParameters */ private static void printRequestParameters(final String label, final ImmutableList<Ds3Param> oldParams, final ImmutableList<Ds3Param> newParams, final WriterHelper writer) { if (isEmpty(oldParams) && isEmpty(newParams)) { //do not print empty values return; } writer.append(indent(INDENT)).append(label).append("\n"); final ImmutableSet<String> paramNames = getParamNameUnion(oldParams, newParams); final ImmutableMap<String, Ds3Param> oldParamMap = toParamMap(oldParams); final ImmutableMap<String, Ds3Param> newParamMap = toParamMap(newParams); paramNames.forEach(name -> printParamDiff(oldParamMap.get(name), newParamMap.get(name), writer)); }
From source file:com.spectralogic.ds3contractcomparator.print.simpleprinter.Ds3RequestDiffSimplePrinter.java
/** * Prints the changes between two {@link ImmutableList} of {@link Ds3ResponseCode}. If both lists are * empty, then nothing is printed.//from ww w .j a v a2s . c o m */ private static void printResponseCodes(final ImmutableList<Ds3ResponseCode> oldCodes, final ImmutableList<Ds3ResponseCode> newCodes, final WriterHelper writer) { if (isEmpty(oldCodes) && isEmpty(newCodes)) { //do not print empty values return; } writer.append(indent(INDENT)).append("ResponseCodes:").append("\n"); final ImmutableSet<Integer> codes = getResponseCodeUnion(oldCodes, newCodes); final ImmutableMap<Integer, Ds3ResponseCode> oldCodeMap = toCodeMap(oldCodes); final ImmutableMap<Integer, Ds3ResponseCode> newCodeMap = toCodeMap(newCodes); codes.forEach(code -> printResponseCodeDiff(oldCodeMap.get(code), newCodeMap.get(code), writer)); }
From source file:com.spectralogic.ds3contractcomparator.print.simpleprinter.Ds3TypeDiffSimplePrinter.java
/** * Prints the changes between two {@link ImmutableList} of {@link Ds3Element}. If both lists are * empty, then nothing is printed./*from w w w. ja va2s . c o m*/ */ private static void printElements(final ImmutableList<Ds3Element> oldElements, final ImmutableList<Ds3Element> newElements, final WriterHelper writer, final boolean printAllAnnotations) { if (isEmpty(oldElements) && isEmpty(newElements)) { //do not print empty values return; } writer.append(indent(INDENT)).append("Elements:").append("\n"); final ImmutableSet<String> elementNames = getElementNameUnion(oldElements, newElements); final ImmutableMap<String, Ds3Element> oldMap = toElementMap(oldElements); final ImmutableMap<String, Ds3Element> newMap = toElementMap(newElements); elementNames .forEach(name -> printElementDiff(oldMap.get(name), newMap.get(name), writer, printAllAnnotations)); }
From source file:com.spectralogic.ds3contractcomparator.print.simpleprinter.Ds3TypeDiffSimplePrinter.java
/** * Prints the changes between two {@link ImmutableList} of {@link Ds3Element}. If both lists are * empty, then nothing is printed.//from w ww.j a v a2 s. c om */ private static void printEnumConstants(final ImmutableList<Ds3EnumConstant> oldEnums, final ImmutableList<Ds3EnumConstant> newEnums, final WriterHelper writer, final boolean printProperties) { if (isEmpty(oldEnums) && isEmpty(newEnums)) { //do not print empty values return; } writer.append(indent(INDENT)).append("EnumConstants:").append("\n"); final ImmutableSet<String> enumNames = getEnumConstantNameUnion(oldEnums, newEnums); final ImmutableMap<String, Ds3EnumConstant> oldMap = toEnumConstantMap(oldEnums); final ImmutableMap<String, Ds3EnumConstant> newMap = toEnumConstantMap(newEnums); enumNames.forEach( name -> printEnumConstantDiff(oldMap.get(name), newMap.get(name), writer, printProperties)); }
From source file:com.spectralogic.ds3contractcomparator.print.htmlprinter.generators.row.ModifiedHtmlRowGenerator.java
/** * Recursively traverses two objects using reflection and constructs the modified * rows that represent the changes and differences between the objects. *//* w ww . ja va 2 s .c om*/ public static <T> ImmutableList<Row> createModifiedRows(final T oldObject, final T newObject, final int indent) { if (oldObject == null && newObject == null) { return ImmutableList.of(); } final Field[] fields = getFields(oldObject, newObject); final ImmutableList.Builder<Row> builder = ImmutableList.builder(); for (final Field field : fields) { final String property = field.getName(); final Optional<String> oldValue = getPropertyValue(oldObject, property); final Optional<String> newValue = getPropertyValue(newObject, property); if (oldValue.isPresent() || newValue.isPresent()) { final int fieldIndent = toModifiedFieldIndent(indent, oldObject, newObject, field); if (field.getType() == ImmutableList.class) { //Field is a list, recursively print each element in the list builder.add(new NoChangeRow(fieldIndent, property, "")); final ImmutableList<Object> oldObjList = getListPropertyFromObject(field, oldObject); final ImmutableList<Object> newObjList = getListPropertyFromObject(field, newObject); if (hasContent(oldObjList) || hasContent(newObjList)) { final String uniqueProperty = getPropertyNameFromList(oldObjList, newObjList); final ImmutableSet<String> parameterUnion = toPropertyUnion(oldObjList, newObjList, uniqueProperty); final ImmutableMap<String, Object> oldMap = toPropertyMap(oldObjList, uniqueProperty); final ImmutableMap<String, Object> newMap = toPropertyMap(newObjList, uniqueProperty); parameterUnion.forEach(param -> builder .addAll(createModifiedRows(oldMap.get(param), newMap.get(param), fieldIndent + 1))); } } else if (oldValue.isPresent() && newValue.isPresent() && oldValue.get().equals(newValue.get())) { //Element is the same in both contracts builder.add(new NoChangeRow(fieldIndent, property, oldValue.get())); } else { //Element is different between old and new contracts builder.add(new ModifiedRow(fieldIndent, property, oldValue.orElse(RowConstants.NA), newValue.orElse(RowConstants.NA))); } } } return builder.build(); }
From source file:rocks.devonthe.stickychunk.database.MongodbDatabase.java
public void saveUserData(ImmutableSet<UserData> loadedUserDatas) { loadedUserDatas.forEach(this::saveUserData); }
From source file:rocks.devonthe.stickychunk.database.MongodbDatabase.java
public void saveRegionData(ImmutableSet<LoadedRegion> loadedRegions) { loadedRegions.forEach(this::saveRegionData); }