Example usage for java.util Map getOrDefault

List of usage examples for java.util Map getOrDefault

Introduction

In this page you can find the example usage for java.util Map getOrDefault.

Prototype

default V getOrDefault(Object key, V defaultValue) 

Source Link

Document

Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.

Usage

From source file:org.wso2.carbon.sp.jobmanager.core.deployment.DeploymentManagerImpl.java

@Override
public void resourceAdded(ResourceNode resourceNode) {
    Map<String, List<SiddhiAppHolder>> waitingList = ServiceDataHolder.getResourcePool()
            .getAppsWaitingForDeploy();//from   w  w w .ja va2  s. co m
    Set<String> waitingParentAppNames = new HashSet<>(waitingList.keySet());
    List<SiddhiAppHolder> partialAppHoldersOfSiddhiApp;
    List<SiddhiAppHolder> currentDeployedPartialApps;
    boolean deployedCompletely;

    lock.lock();
    try {
        // Refresh iterator after the pool change (since new node added).
        resourceIterator = ServiceDataHolder.getResourcePool().getResourceNodeMap().values().iterator();

        for (String parentSiddhiAppName : waitingParentAppNames) {
            partialAppHoldersOfSiddhiApp = waitingList.getOrDefault(parentSiddhiAppName,
                    Collections.emptyList());
            deployedCompletely = true;
            currentDeployedPartialApps = new ArrayList<>();

            for (SiddhiAppHolder partialAppHolder : partialAppHoldersOfSiddhiApp) {
                ResourceNode deployedNode = deploy(
                        new SiddhiQuery(partialAppHolder.getAppName(), partialAppHolder.getSiddhiApp()), 0);

                if (deployedNode != null) {
                    partialAppHolder.setDeployedNode(deployedNode);
                    currentDeployedPartialApps.add(partialAppHolder);
                    LOG.info(String.format("Siddhi app %s of %s successfully deployed in %s.",
                            partialAppHolder.getAppName(), partialAppHolder.getParentAppName(), deployedNode));
                } else {
                    deployedCompletely = false;
                    break;
                }
            }
            if (deployedCompletely) {
                ServiceDataHolder.getResourcePool().getSiddhiAppHoldersMap().put(parentSiddhiAppName,
                        partialAppHoldersOfSiddhiApp);
                waitingList.remove(parentSiddhiAppName);
                LOG.info("Siddhi app " + parentSiddhiAppName + " successfully deployed.");
            } else {
                LOG.warn(String.format("Still insufficient resources to deploy %s. Hence, rolling back the "
                        + "deployment and waiting for additional resources.", parentSiddhiAppName));
                rollback(currentDeployedPartialApps);
            }
        }
        ServiceDataHolder.getResourcePool().persist();
    } finally {
        lock.unlock();
    }
}

From source file:fr.cph.stock.entities.Portfolio.java

protected Map<String, List<Equity>> getGapByCompanies() {
    final Map<String, List<Equity>> map = new TreeMap<>();
    List<Equity> companies;
    for (final Equity equity : getEquities()) {
        if (equity.getMarketCapitalizationType().getValue() == null || equity.getCompany().getFund()) {
            equity.setMarketCapitalizationType(MarketCapitalization.UNKNOWN);
        }//from   www.  j  a  v  a 2  s  .  c o m
        companies = map.getOrDefault(equity.getMarketCapitalizationType().getValue(), new ArrayList<>());
        companies.add(equity);
        map.put(equity.getMarketCapitalizationType().getValue(), companies);
    }
    return map;
}

From source file:com.google.api.codegen.config.GapicProductConfig.java

/** Return the list of information about clients to be generated. */
private static ImmutableList<GapicInterfaceInput> createInterfaceInputsWithGapicConfig(
        DiagCollector diagCollector, List<InterfaceConfigProto> interfaceConfigProtosList,
        ImmutableMap<String, Interface> protoInterfaces, SymbolTable symbolTable) {

    // Maps name of interfaces to found interfaces from proto.
    Map<String, Interface> interfaceMap = new LinkedHashMap<>(protoInterfaces);

    // Maps name of interfaces to found InterfaceConfigs from config yamls.
    Map<String, InterfaceConfigProto> interfaceConfigProtos = new LinkedHashMap<>();

    // Parse GAPIC config for interfaceConfigProtos.
    for (InterfaceConfigProto interfaceConfigProto : interfaceConfigProtosList) {
        Interface apiInterface = symbolTable.lookupInterface(interfaceConfigProto.getName());
        if (apiInterface == null || !apiInterface.isReachable()) {
            diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL, "interface not found: %s",
                    interfaceConfigProto.getName()));
            continue;
        }/*from  w ww  .j  ava2  s. co m*/
        interfaceConfigProtos.put(interfaceConfigProto.getName(), interfaceConfigProto);
        interfaceMap.put(interfaceConfigProto.getName(), apiInterface);
    }

    // Store info about each Interface in a GapicInterfaceInput object.
    ImmutableList.Builder<GapicInterfaceInput> interfaceInputs = ImmutableList.builder();
    for (Entry<String, Interface> interfaceEntry : interfaceMap.entrySet()) {
        String serviceFullName = interfaceEntry.getKey();
        Interface apiInterface = interfaceEntry.getValue();
        GapicInterfaceInput.Builder interfaceInput = GapicInterfaceInput.newBuilder()
                .setInterface(apiInterface);

        InterfaceConfigProto interfaceConfigProto = interfaceConfigProtos.getOrDefault(serviceFullName,
                InterfaceConfigProto.getDefaultInstance());
        interfaceInput.setInterfaceConfigProto(interfaceConfigProto);

        Map<Method, MethodConfigProto> methodsToGenerate;
        methodsToGenerate = findMethodsToGenerateWithConfigYaml(apiInterface, interfaceConfigProto,
                diagCollector);
        if (methodsToGenerate == null) {
            return null;
        }
        interfaceInput.setMethodsToGenerate(methodsToGenerate);
        interfaceInputs.add(interfaceInput.build());
    }

    return interfaceInputs.build();
}

From source file:alfio.controller.EventController.java

@RequestMapping(value = "/event/{eventName}", method = { RequestMethod.GET, RequestMethod.HEAD })
public String showEvent(@PathVariable("eventName") String eventName, Model model, HttpServletRequest request,
        Locale locale) {//  w  w  w. j  a  v a2 s .c  o m

    return eventRepository.findOptionalByShortName(eventName)
            .filter(e -> e.getStatus() != Event.Status.DISABLED).map(event -> {
                Optional<String> maybeSpecialCode = SessionUtil.retrieveSpecialPriceCode(request);
                Optional<SpecialPrice> specialCode = maybeSpecialCode
                        .flatMap((trimmedCode) -> specialPriceRepository.getByCode(trimmedCode));

                Optional<PromoCodeDiscount> promoCodeDiscount = SessionUtil
                        .retrievePromotionCodeDiscount(request).flatMap((code) -> promoCodeRepository
                                .findPromoCodeInEventOrOrganization(event.getId(), code));

                final ZonedDateTime now = ZonedDateTime.now(event.getZoneId());
                //hide access restricted ticket categories
                List<TicketCategory> ticketCategories = ticketCategoryRepository
                        .findAllTicketCategories(event.getId());
                Map<Integer, String> categoriesDescription = ticketCategoryDescriptionRepository
                        .descriptionsByTicketCategory(ticketCategories.stream().map(TicketCategory::getId)
                                .collect(Collectors.toList()), locale.getLanguage());

                List<SaleableTicketCategory> saleableTicketCategories = ticketCategories.stream()
                        .filter((c) -> !c.isAccessRestricted() || (specialCode
                                .filter(sc -> sc.getTicketCategoryId() == c.getId()).isPresent()))
                        .map((m) -> new SaleableTicketCategory(m,
                                categoriesDescription.getOrDefault(m.getId(), ""), now, event,
                                ticketReservationManager.countAvailableTickets(event, m),
                                configurationManager.getIntConfigValue(
                                        Configuration.from(event.getOrganizationId(), event.getId(), m.getId(),
                                                ConfigurationKeys.MAX_AMOUNT_OF_TICKETS_BY_RESERVATION),
                                        5),
                                promoCodeDiscount.filter(promoCode -> shouldApplyDiscount(promoCode, m))
                                        .orElse(null)))
                        .collect(Collectors.toList());
                //

                final int orgId = event.getOrganizationId();
                final int eventId = event.getId();
                Map<ConfigurationKeys, Optional<String>> geoInfoConfiguration = configurationManager
                        .getStringConfigValueFrom(
                                Configuration.from(orgId, eventId, ConfigurationKeys.MAPS_PROVIDER),
                                Configuration.from(orgId, eventId, ConfigurationKeys.MAPS_CLIENT_API_KEY),
                                Configuration.from(orgId, eventId, ConfigurationKeys.MAPS_HERE_APP_ID),
                                Configuration.from(orgId, eventId, ConfigurationKeys.MAPS_HERE_APP_CODE));

                LocationDescriptor ld = LocationDescriptor.fromGeoData(event.getLatLong(),
                        TimeZone.getTimeZone(event.getTimeZone()), geoInfoConfiguration);

                final boolean hasAccessPromotions = ticketCategoryRepository
                        .countAccessRestrictedRepositoryByEventId(event.getId()) > 0
                        || promoCodeRepository.countByEventAndOrganizationId(event.getId(),
                                event.getOrganizationId()) > 0;

                String eventDescription = eventDescriptionRepository
                        .findDescriptionByEventIdTypeAndLocale(event.getId(),
                                EventDescription.EventDescriptionType.DESCRIPTION, locale.getLanguage())
                        .orElse("");

                final EventDescriptor eventDescriptor = new EventDescriptor(event, eventDescription);
                List<SaleableTicketCategory> expiredCategories = saleableTicketCategories.stream()
                        .filter(SaleableTicketCategory::getExpired).collect(Collectors.toList());
                List<SaleableTicketCategory> validCategories = saleableTicketCategories.stream()
                        .filter(tc -> !tc.getExpired()).collect(Collectors.toList());
                List<SaleableAdditionalService> additionalServices = additionalServiceRepository
                        .loadAllForEvent(event.getId()).stream().map((as) -> getSaleableAdditionalService(event,
                                locale, as, promoCodeDiscount.orElse(null)))
                        .collect(Collectors.toList());
                Predicate<SaleableTicketCategory> waitingQueueTargetCategory = tc -> !tc.getExpired()
                        && !tc.isBounded();
                boolean validPaymentConfigured = isEventHasValidPaymentConfigurations(event,
                        configurationManager);

                List<SaleableAdditionalService> notExpiredServices = additionalServices.stream()
                        .filter(SaleableAdditionalService::isNotExpired).collect(Collectors.toList());

                List<SaleableAdditionalService> supplements = adjustIndex(0,
                        notExpiredServices.stream()
                                .filter(a -> a.getType() == AdditionalService.AdditionalServiceType.SUPPLEMENT)
                                .collect(Collectors.toList()));
                List<SaleableAdditionalService> donations = adjustIndex(supplements.size(),
                        notExpiredServices.stream()
                                .filter(a -> a.getType() == AdditionalService.AdditionalServiceType.DONATION)
                                .collect(Collectors.toList()));

                model.addAttribute("event", eventDescriptor)//
                        .addAttribute("organization", organizationRepository.getById(event.getOrganizationId()))
                        .addAttribute("ticketCategories", validCategories)//
                        .addAttribute("expiredCategories", expiredCategories)//
                        .addAttribute("containsExpiredCategories", !expiredCategories.isEmpty())//
                        .addAttribute("showNoCategoriesWarning", validCategories.isEmpty())
                        .addAttribute("hasAccessPromotions", hasAccessPromotions)
                        .addAttribute("promoCode", specialCode.map(SpecialPrice::getCode).orElse(null))
                        .addAttribute("locationDescriptor", ld)
                        .addAttribute("pageTitle", "show-event.header.title")
                        .addAttribute("hasPromoCodeDiscount", promoCodeDiscount.isPresent())
                        .addAttribute("promoCodeDiscount", promoCodeDiscount.orElse(null))
                        .addAttribute("displayWaitingQueueForm",
                                EventUtil.displayWaitingQueueForm(event, saleableTicketCategories,
                                        configurationManager, eventStatisticsManager.noSeatsAvailable()))
                        .addAttribute("displayCategorySelectionForWaitingQueue",
                                saleableTicketCategories.stream().filter(waitingQueueTargetCategory)
                                        .count() > 1)
                        .addAttribute("unboundedCategories",
                                saleableTicketCategories.stream().filter(waitingQueueTargetCategory)
                                        .collect(Collectors.toList()))
                        .addAttribute("preSales", EventUtil.isPreSales(event, saleableTicketCategories))
                        .addAttribute("userLanguage", locale.getLanguage())
                        .addAttribute("showAdditionalServices", !notExpiredServices.isEmpty())
                        .addAttribute("showAdditionalServicesDonations", !donations.isEmpty())
                        .addAttribute("showAdditionalServicesSupplements", !supplements.isEmpty())
                        .addAttribute("enabledAdditionalServicesDonations", donations)
                        .addAttribute("enabledAdditionalServicesSupplements", supplements)
                        .addAttribute("forwardButtonDisabled",
                                (saleableTicketCategories.stream()
                                        .noneMatch(SaleableTicketCategory::getSaleable))
                                        || !validPaymentConfigured)
                        .addAttribute("useFirstAndLastName", event.mustUseFirstAndLastName())
                        .addAttribute("validPaymentMethodAvailable", validPaymentConfigured)
                        .addAttribute("validityStart", event.getBegin())
                        .addAttribute("validityEnd", event.getEnd());

                model.asMap().putIfAbsent("hasErrors", false);//
                return "/event/show-event";
            }).orElse(REDIRECT + "/");
}

From source file:com.hortonworks.registries.schemaregistry.SchemaVersionLifecycleManager.java

private CustomSchemaStateExecutor createSchemaReviewExecutor(Map<String, Object> props,
        SchemaVersionLifecycleStateMachine.Builder builder) {
    Map<String, Object> schemaReviewExecConfig = (Map<String, Object>) props
            .getOrDefault("customSchemaStateExecutor", Collections.emptyMap());
    String className = (String) schemaReviewExecConfig.getOrDefault("className",
            DEFAULT_SCHEMA_REVIEW_EXECUTOR_CLASS);
    Map<String, ?> executorProps = (Map<String, ?>) schemaReviewExecConfig.getOrDefault("props",
            Collections.emptyMap());
    CustomSchemaStateExecutor customSchemaStateExecutor;
    try {//from   www  . j ava 2  s.c o  m
        customSchemaStateExecutor = (CustomSchemaStateExecutor) Class
                .forName(className, true, Thread.currentThread().getContextClassLoader()).newInstance();
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        LOG.error("Error encountered while loading class [{}]", className, e);
        throw new IllegalArgumentException(e);
    }

    customSchemaStateExecutor.init(builder, SchemaVersionLifecycleStates.REVIEWED.getId(),
            SchemaVersionLifecycleStates.CHANGES_REQUIRED.getId(), executorProps);

    return customSchemaStateExecutor;
}

From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java

/**
 * If no value present, choose a empty string
 *
 * @param title/*from   w  ww  .  j  a  v  a  2s  . c  om*/
 * @param link
 * @param description
 * @param language
 * @param imageUrl
 * @return
 */
private Component getSecondStage(Source s) {
    Label header = new Label(Language.get(Word.SOURCE));
    header.addStyleName(ValoTheme.LABEL_H1);

    FormLayout forms = new FormLayout();
    forms.setSizeFull();

    TextField textFieldId = new TextField(Language.get(Word.ID));
    textFieldId.setEnabled(false);
    textFieldId.setValue(s.getId());
    textFieldId.setWidth("750px");

    TextField textFieldName = new TextField(Language.get(Word.NAME));
    textFieldName.setValue(s.getName());
    textFieldName.setWidth("750px");

    TextField textFieldDescription = new TextField(Language.get(Word.DESCRIPTION));
    textFieldDescription.setValue(s.getDescription());
    textFieldDescription.setWidth("750px");

    TextField textFieldURL = new TextField(Language.get(Word.URL));
    if (s.getUrl() != null) {
        textFieldURL.setValue(s.getUrl().toExternalForm());
    }
    textFieldURL.setWidth("750px");

    ComboBox<Category> comboBoxCategories = new ComboBox<>(Language.get(Word.CATEGORY),
            EnumSet.allOf(Category.class));
    comboBoxCategories.setItemCaptionGenerator(c -> c.getName());
    comboBoxCategories.setItemIconGenerator(c -> c.getIcon());
    comboBoxCategories.setEmptySelectionAllowed(false);
    comboBoxCategories.setTextInputAllowed(false);
    comboBoxCategories.setWidth("375px");
    if (s.getCategory() != null) {
        comboBoxCategories.setSelectedItem(s.getCategory());
    }

    ComboBox<Locale> comboBoxLanguage = new ComboBox<>(Language.get(Word.LANGUAGE), getLanguages());
    comboBoxLanguage.setItemCaptionGenerator(l -> l.getDisplayLanguage(VaadinSession.getCurrent().getLocale()));
    comboBoxLanguage.setEmptySelectionAllowed(false);
    comboBoxLanguage.setWidth("375px");
    if (!s.getLanguage().isEmpty()) {
        Locale selected = new Locale(s.getLanguage());
        comboBoxLanguage.setSelectedItem(selected);
    }

    Locale loc = VaadinSession.getCurrent().getLocale();

    Map<String, Locale> countries = getCountries();
    List<Locale> locales = countries.values().parallelStream()
            .sorted((l1, l2) -> l1.getDisplayCountry(loc).compareTo(l2.getDisplayCountry(loc)))
            .collect(Collectors.toList());
    ComboBox<Locale> comboBoxCountry = new ComboBox<>(Language.get(Word.COUNTRY), locales);
    comboBoxCountry.setItemCaptionGenerator(l -> l.getDisplayCountry(VaadinSession.getCurrent().getLocale()));
    comboBoxCountry.setItemIconGenerator(l -> FamFamFlags.fromLocale(l));
    comboBoxCountry.setEmptySelectionAllowed(false);
    comboBoxCountry.setWidth("375px");
    if (!s.getCountry().isEmpty()) {
        comboBoxCountry.setSelectedItem(countries.getOrDefault(s.getCountry(), Locale.ROOT));
    }

    Image imageLogo = new Image(Language.get(Word.LOGO));

    TextField textFieldLogo = new TextField(Language.get(Word.LOGO_URL));
    if (s.getLogo() != null) {
        textFieldLogo.setValue(s.getLogo().toExternalForm());
        imageLogo.setSource(new ExternalResource(s.getLogo()));
    }
    textFieldLogo.addValueChangeListener(ce -> imageLogo.setSource(new ExternalResource(ce.getValue())));
    textFieldLogo.setWidth("750px");

    if (imageLogo.getHeight() > 125) {
        imageLogo.setHeight("125px");
    }

    forms.addComponents(textFieldId, textFieldName, textFieldDescription, textFieldURL, comboBoxCategories,
            comboBoxLanguage, comboBoxCountry, textFieldLogo, imageLogo);

    Runnable cancel = () -> close();
    Runnable next = () -> validateSecondStage(s, textFieldId.getValue(), textFieldName.getValue(),
            textFieldURL.getValue(), textFieldDescription.getValue(),
            comboBoxCategories.getSelectedItem().orElse(null),
            comboBoxLanguage.getSelectedItem().orElse(Locale.ROOT),
            comboBoxCountry.getSelectedItem().orElse(Locale.ROOT), textFieldLogo.getValue());

    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.addComponents(header, forms, getFooter(cancel, next));
    windowLayout.setComponentAlignment(header, Alignment.MIDDLE_CENTER);
    return windowLayout;
}

From source file:com.facebook.presto.accumulo.tools.RewriteIndex.java

private void deleteIndexEntries(Connector connector, AccumuloTable table, long start) {
    LOG.info(format("Scanning index table %s to delete index entries", table.getIndexTableName()));
    BatchScanner scanner = null;//w  w  w .  ja va 2s .co  m
    BatchWriter indexWriter = null;
    try {
        // Create index writer and metrics writer, but we are never going to flush the metrics writer
        indexWriter = connector.createBatchWriter(table.getIndexTableName(), bwc);
        scanner = connector.createBatchScanner(table.getIndexTableName(), auths, 10);
        LOG.info(format("Created batch scanner against %s with auths %s", table.getIndexTableName(), auths));

        IteratorSetting timestampFilter = new IteratorSetting(21, "timestamp", TimestampFilter.class);
        TimestampFilter.setRange(timestampFilter, 0L, start);
        scanner.addScanIterator(timestampFilter);

        scanner.setRanges(connector.tableOperations().splitRangeByTablets(table.getIndexTableName(),
                new Range(), Integer.MAX_VALUE));

        // Scan the index table, gathering row IDs into batches
        long numTotalMutations = 0L;

        Map<ByteBuffer, RowStatus> rowIdStatuses = new HashMap<>();
        Multimap<ByteBuffer, Mutation> queryIndexEntries = MultimapBuilder.hashKeys().hashSetValues().build();
        Text text = new Text();
        for (Entry<Key, Value> entry : scanner) {
            ++numTotalMutations;

            ByteBuffer rowID = ByteBuffer.wrap(entry.getKey().getColumnQualifier(text).copyBytes());
            Mutation mutation = new Mutation(entry.getKey().getRow(text).copyBytes());
            mutation.putDelete(entry.getKey().getColumnFamily(text).copyBytes(),
                    entry.getKey().getColumnQualifier(text).copyBytes(),
                    entry.getKey().getColumnVisibilityParsed(), start);

            // Get status of this row ID
            switch (rowIdStatuses.getOrDefault(rowID, RowStatus.UNKNOWN)) {
            case ABSENT:
            case UNKNOWN:
                // Absent or unknown? Add it to the collection to check the status and/or delete
                queryIndexEntries.put(rowID, mutation);
                break;
            case PRESENT: // Present? No op
                break;
            }

            if (queryIndexEntries.size() == 100000) {
                flushDeleteEntries(connector, table, start, indexWriter,
                        ImmutableMultimap.copyOf(queryIndexEntries), rowIdStatuses);
                queryIndexEntries.clear();
            }
        }

        flushDeleteEntries(connector, table, start, indexWriter, ImmutableMultimap.copyOf(queryIndexEntries),
                rowIdStatuses);
        queryIndexEntries.clear();

        LOG.info(format(
                "Finished scanning index entries. There are %s distinct row IDs containing %s entries. %s rows present in the data table and %s absent",
                rowIdStatuses.size(), numTotalMutations,
                rowIdStatuses.entrySet().stream().filter(entry -> entry.getValue().equals(RowStatus.PRESENT))
                        .count(),
                rowIdStatuses.entrySet().stream().filter(entry -> entry.getValue().equals(RowStatus.ABSENT))
                        .count()));

        if (dryRun) {
            LOG.info(format("Would have deleted %s index entries", numDeletedIndexEntries));
        } else {
            LOG.info(format("Deleted %s index entries", numDeletedIndexEntries));
        }
    } catch (AccumuloException | AccumuloSecurityException e) {
        LOG.error("Accumulo exception", e);
    } catch (TableNotFoundException e) {
        LOG.error("Table not found, must have been deleted during process", e);
    } finally {
        if (indexWriter != null) {
            try {
                indexWriter.close();
            } catch (MutationsRejectedException e) {
                LOG.error("Server rejected mutations", e);
            }
        }

        if (scanner != null) {
            scanner.close();
        }
    }
}

From source file:com.hortonworks.streamline.streams.actions.storm.topology.StormTopologyActionsImpl.java

private void setupSecuredStormCluster(Map<String, Object> conf) {
    thriftTransport = (String) conf.get(TopologyLayoutConstants.STORM_THRIFT_TRANSPORT);

    if (conf.containsKey(TopologyLayoutConstants.STORM_NIMBUS_PRINCIPAL_NAME)) {
        String nimbusPrincipal = (String) conf.get(TopologyLayoutConstants.STORM_NIMBUS_PRINCIPAL_NAME);
        String kerberizedNimbusServiceName = nimbusPrincipal.split("/")[0];
        jaasFilePath = Optional.of(createJaasFile(kerberizedNimbusServiceName));
    } else {//www.  ja v  a 2s  . c o  m
        jaasFilePath = Optional.empty();
    }

    principalToLocal = (String) conf.getOrDefault(TopologyLayoutConstants.STORM_PRINCIPAL_TO_LOCAL,
            DEFAULT_PRINCIPAL_TO_LOCAL);

    if (thriftTransport == null) {
        if (jaasFilePath.isPresent()) {
            thriftTransport = (String) conf.get(TopologyLayoutConstants.STORM_SECURED_THRIFT_TRANSPORT);
        } else {
            thriftTransport = (String) conf.get(TopologyLayoutConstants.STORM_NONSECURED_THRIFT_TRANSPORT);
        }
    }

    // if it's still null, set to default
    if (thriftTransport == null) {
        thriftTransport = DEFAULT_THRIFT_TRANSPORT_PLUGIN;
    }
}

From source file:io.stallion.dataAccess.db.DB.java

public Schema modelToSchema(Class cls) {
    try {//from   w  ww. j av a2s  . c  o m
        Field metaField = cls.getField("meta");
        if (metaField != null) {
            Map<String, Object> o = (Map<String, Object>) metaField.get(null);
            if (o != null && !empty(o.getOrDefault("tableName", "").toString())) {
                return metaDataModelToSchema(cls, o);
            }
        }
    } catch (NoSuchFieldException e) {
        Log.exception(e, "Error finding meta field");
    } catch (IllegalAccessException e) {
        Log.exception(e, "Error accesing meta field");
    }
    return annotatedModelToSchema(cls);
}