当前位置: 首页>>代码示例>>Java>>正文


Java ListUtils.emptyIfNull方法代码示例

本文整理汇总了Java中org.apache.commons.collections4.ListUtils.emptyIfNull方法的典型用法代码示例。如果您正苦于以下问题:Java ListUtils.emptyIfNull方法的具体用法?Java ListUtils.emptyIfNull怎么用?Java ListUtils.emptyIfNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.collections4.ListUtils的用法示例。


在下文中一共展示了ListUtils.emptyIfNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
/**
 * Executes the expressions contained within the profile definition.
 * @param expressions A list of expressions to execute.
 * @param transientState Additional transient state provided to the expressions.
 * @param expressionType The type of expression; init, update, result.  Provides additional context if expression execution fails.
 * @return The result of executing each expression.
 */
private List<Object> execute(List<String> expressions, Map<String, Object> transientState, String expressionType) {
  List<Object> results = new ArrayList<>();

  for(String expr: ListUtils.emptyIfNull(expressions)) {
    try {
      // execute an expression
      Object result = executor.execute(expr, transientState, Object.class);
      results.add(result);

    } catch (Throwable e) {

      // in-scope variables = persistent state maintained by the profiler + the transient state
      Set<String> variablesInScope = new HashSet<>();
      variablesInScope.addAll(transientState.keySet());
      variablesInScope.addAll(executor.getState().keySet());

      String msg = format("Bad '%s' expression: error='%s', expr='%s', profile='%s', entity='%s', variables-available='%s'",
              expressionType, e.getMessage(), expr, profileName, entity, variablesInScope);
      LOG.error(msg, e);
      throw new ParseException(msg, e);
    }
  }

  return results;
}
 
开发者ID:apache,项目名称:metron,代码行数:33,代码来源:DefaultProfileBuilder.java

示例2: listToJsonArray

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
public static JsonArray listToJsonArray(List<Contribution> contributions) {
  String method = "listToJsonArray";
  logger.entering(clazz, method);

  JsonArrayBuilder contributionsBuilder = Json.createArrayBuilder();
  for (Contribution contribution : ListUtils.emptyIfNull(contributions)) {
    contributionsBuilder.add(contribution.toJson());
  }
  JsonArray contributionsOut = contributionsBuilder.build();

  logger.exiting(clazz, method, contributionsOut);
  return contributionsOut;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:14,代码来源:Occasion.java

示例3: listToDBList

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
public static BasicDBList listToDBList(List<Contribution> contributions) {
  String method = "listToString";
  logger.entering(clazz, method);
  BasicDBList dbl = new BasicDBList();
  for (Contribution contribution : ListUtils.emptyIfNull(contributions)) {
    dbl.add(contribution.toDbo());
  }
  logger.exiting(clazz, method);
  return dbl;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:11,代码来源:Occasion.java

示例4: listToString

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
public static String listToString(List<Contribution> contributions) {
  String method = "listToString";
  logger.entering(clazz, method);
  StringBuilder sb = new StringBuilder();
  for (Contribution contribution : ListUtils.emptyIfNull(contributions)) {
    sb.append(contribution.toString());
  }
  String str = sb.toString();
  logger.exiting(clazz, method, str);
  return str;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:12,代码来源:Occasion.java

示例5: dbListToList

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
public static List<Contribution> dbListToList(BasicDBList dbl) {
  String method = "dbListToList";
  logger.entering(clazz, method, dbl);

  List<Contribution> contributions = new ArrayList<>();
  for (Object dbo : ListUtils.emptyIfNull(dbl)) {
    contributions.add(new Contribution((BasicDBObject) dbo));
  }

  logger.exiting(clazz, method, listToString(contributions));
  return contributions;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:13,代码来源:Occasion.java

示例6: dboListToJsonArray

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
public static JsonArray dboListToJsonArray(List<DBObject> dboList) {
  String method = "dboListToJsonArray";
  logger.entering(clazz, method, dboList);

  JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
  for (Object dbo : ListUtils.emptyIfNull(dboList)) {
    JsonObject json = new Occasion((DBObject) dbo).toJson();
    arrayBuilder.add(json);
  }
  JsonArray returnArray = arrayBuilder.build();

  logger.exiting(clazz, method, returnArray);
  return returnArray;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:15,代码来源:Occasion.java

示例7: remove

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
@Override
public V remove(int index) {
    final List<V> list = ListUtils.emptyIfNull(getMapping());
    V value = list.remove(index);
    if (list.isEmpty()) {
        AbstractListValuedMap.this.remove(key);
    }
    return value;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:10,代码来源:AbstractListValuedMap.java

示例8: apply

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
@Override
public Object apply(List<Object> args, Context context) throws ParseException {
  SensorEnrichmentConfig config = getSensorEnrichmentConfig(args, 0);

  ThreatIntelConfig tiConfig = (ThreatIntelConfig) getConfig(config, EnrichmentConfigFunctions.Type.THREAT_INTEL);
  if(tiConfig == null) {
    return "";
  }
  org.apache.metron.common.configuration.enrichment.threatintel.ThreatTriageConfig triageConfig = tiConfig.getTriageConfig();
  if(triageConfig == null) {
    return "";
  }

  // print each rule
  List<RiskLevelRule> triageRules = ListUtils.emptyIfNull(triageConfig.getRiskLevelRules());
  String[] headers = new String[] {"Name", "Comment", "Triage Rule", "Score", "Reason"};
  String[][] data = new String[triageRules.size()][5];
  int i = 0;
  for(RiskLevelRule rule : triageRules) {
    double d = rule.getScore().doubleValue();
    String score = d == (long)d ? String.format("%d", (long)d) : String.format("%s", d);
    String name = Optional.ofNullable(rule.getName()).orElse("");
    String comment = Optional.ofNullable(rule.getComment()).orElse("");
    String reason = Optional.ofNullable(rule.getReason()).orElse("");
    data[i++]  = new String[] {name, comment, rule.getRule(), score, reason};
  }
  String ret = FlipTable.of(headers, data);

  // print the aggregation
  if(!triageRules.isEmpty()) {
    ret += "Aggregation: " + triageConfig.getAggregator().name();
  }
  return ret;
}
 
开发者ID:apache,项目名称:metron,代码行数:35,代码来源:ThreatTriageFunctions.java

示例9: validateInOutParams

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
private void validateInOutParams(Map<String, String> metadataInOutParams,
                                 List<? extends InOutParam> inOutParams, String errorMessagePrefix,
                                 Queue<RuntimeException> exceptions) {
    for (InOutParam inOutParam : ListUtils.emptyIfNull(inOutParams)) {
        if (MapUtils.isEmpty(metadataInOutParams)) {
            exceptions.add(new MetadataMissingException(errorMessagePrefix +
                    "s are missing description entirely."));
        } else if (metadataInOutParams.get(inOutParam.getName()) == null &&
                (!(inOutParam instanceof Input) || !((Input) inOutParam).isPrivateInput())) {
            exceptions.add(new MetadataMissingException(errorMessagePrefix + " '" + inOutParam.getName() +
                    "' is missing description."));
        }
    }
}
 
开发者ID:CloudSlang,项目名称:cloud-slang,代码行数:15,代码来源:StaticValidatorImpl.java

示例10: findClosestByBBOX

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
private OsmMosquePlace findClosestByBBOX(LinkedPlace place, double deltaLat, double deltaLon)
{
    OsmMosquePlace result = null;

    LOGGER.info("  Calculating distance for {} / {} / {} / {} / {}",
            place.getId(),
            place.getOsmId(),
            place.getDitibCode(),
            place.getLat(),
            place.getLon());

    List<OsmMosquePlace> osmPlaces = osmMosquePlaceRepository.findByBbox(
            place.getLon() - deltaLon, place.getLat() - deltaLat,
            place.getLon() + deltaLon, place.getLat() + deltaLat);

    osmPlaces = ListUtils.emptyIfNull(osmPlaces);

    double distance = 1000000000;
    for (OsmMosquePlace osmPlace : osmPlaces)
    {
        LOGGER.info("    calculating {}", osmPlace);
        double newDistance = GreatCircle.distanceInKm(place.getLat(), place.getLon(), osmPlace.getLat(), osmPlace.getLon());
        LOGGER.info("      distance is {}", distance);

        if (newDistance < distance)
        {
            distance = newDistance;
            result = osmPlace;
        }
    }

    return result;
}
 
开发者ID:osmmosques,项目名称:osm-mosques,代码行数:34,代码来源:QaDataRestHandler.java

示例11: subList

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
@Override
public List<V> subList(int fromIndex, int toIndex) {
    final List<V> list = ListUtils.emptyIfNull(getMapping());
    return list.subList(fromIndex, toIndex);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:6,代码来源:AbstractListValuedMap.java

示例12: set

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
@Override
public V set(int index, V value) {
    final List<V> list = ListUtils.emptyIfNull(getMapping());
    return list.set(index, value);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:6,代码来源:AbstractListValuedMap.java

示例13: get

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
@Override
public V get(int index) {
    final List<V> list = ListUtils.emptyIfNull(getMapping());
    return list.get(index);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:6,代码来源:AbstractListValuedMap.java

示例14: indexOf

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
@Override
public int indexOf(Object o) {
    final List<V> list = ListUtils.emptyIfNull(getMapping());
    return list.indexOf(o);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:6,代码来源:AbstractListValuedMap.java

示例15: ValuesListIterator

import org.apache.commons.collections4.ListUtils; //导入方法依赖的package包/类
public ValuesListIterator(final K key) {
    this.key = key;
    this.values = ListUtils.emptyIfNull(getMap().get(key));
    this.iterator = values.listIterator();
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:6,代码来源:AbstractListValuedMap.java


注:本文中的org.apache.commons.collections4.ListUtils.emptyIfNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。