Tabnine Logo
HashMap.getOrDefault
Code IndexAdd Tabnine to your IDE (free)

How to use
getOrDefault
method
in
java.util.HashMap

Best Java code snippets using java.util.HashMap.getOrDefault (Showing top 20 results out of 891)

origin: Netflix/zuul

public boolean isTrailingEquals(String key) {
  return trailingEquals.getOrDefault(key, false);
}
origin: org.apache.poi/poi-ooxml

private int getAndStoreIndex(String samePath,String withoutNamespace) {
  String withPath = samePath+"/"+withoutNamespace;
  return indexMap.getOrDefault(withPath, -1);
}
origin: Netflix/zuul

public boolean isTrailingEquals(String key) {
  return trailingEquals.getOrDefault(key, false);
}
origin: twosigma/beakerx

private static MIMEContainer IFrame(String srcTemplate, String id, HashMap params) {
 Object width = params.getOrDefault("width", DEFAULT_IFRAME_WIDTH);
 Integer height = Integer.parseInt(params.getOrDefault("height", DEFAULT_IFRAME_HEIGHT).toString());
 String src = String.format(srcTemplate, id, parseParams(params));
 return IFrame(src, width, height);
}
origin: jenkinsci/jenkins

@Restricted(NoExternalUse.class)
@VisibleForTesting
public static Set<String> getAutoCompletionCandidates(List<String> loggerNamesList) {
  Set<String> loggerNames = new HashSet<>(loggerNamesList);
  // now look for package prefixes that make sense to offer for autocompletion:
  // Only prefixes that match multiple loggers will be shown.
  // Example: 'org' will show 'org', because there's org.apache, org.jenkinsci, etc.
  // 'io' might only show 'io.jenkins.plugins' rather than 'io' if all loggers starting with 'io' start with 'io.jenkins.plugins'.
  HashMap<String, Integer> seenPrefixes = new HashMap<>();
  SortedSet<String> relevantPrefixes = new TreeSet<>();
  for (String loggerName : loggerNames) {
    String[] loggerNameParts = loggerName.split("[.]");
    String longerPrefix = null;
    for (int i = loggerNameParts.length; i > 0; i--) {
      String loggerNamePrefix = StringUtils.join(Arrays.copyOf(loggerNameParts, i), ".");
      seenPrefixes.put(loggerNamePrefix, seenPrefixes.getOrDefault(loggerNamePrefix, 0) + 1);
      if (longerPrefix == null) {
        relevantPrefixes.add(loggerNamePrefix); // actual logger name
        longerPrefix = loggerNamePrefix;
        continue;
      }
      if (seenPrefixes.get(loggerNamePrefix) > seenPrefixes.get(longerPrefix)) {
        relevantPrefixes.add(loggerNamePrefix);
      }
      longerPrefix = loggerNamePrefix;
    }
  }
  return relevantPrefixes;
}
origin: geoserver/geoserver

public Object getOrDefault(Object key, Object defaultValue) {
  return super.getOrDefault(upper(key), defaultValue);
}
origin: apache/kafka

@Override
public Map<Errors, Integer> errorCounts() {
  HashMap<Errors, Integer> counts = new HashMap<>();
  for (ReplicaElectionResult result : data.replicaElectionResults()) {
    for (PartitionResult partitionResult : result.partitionResult()) {
      Errors error = Errors.forCode(partitionResult.errorCode());
      counts.put(error, counts.getOrDefault(error, 0) + 1);
    }
  }
  return counts;
}
origin: opentripplanner/OpenTripPlanner

@POST
@Path("/graphql")
@Consumes(MediaType.APPLICATION_JSON)
public Response getGraphQL (HashMap<String, Object> queryParameters) {
  String query = (String) queryParameters.get("query");
  Object queryVariables = queryParameters.getOrDefault("variables", null);
  String operationName = (String) queryParameters.getOrDefault("operationName", null);
  Map<String, Object> variables;
  if (queryVariables instanceof Map) {
    variables = (Map) queryVariables;
  } else if (queryVariables instanceof String && !((String) queryVariables).isEmpty()) {
    try {
      variables = deserializer.readValue((String) queryVariables, Map.class);
    } catch (IOException e) {
      LOG.error("Variables must be a valid json object");
      return Response.status(Status.BAD_REQUEST).entity(MSG_400).build();
    }
  } else {
    variables = new HashMap<>();
  }
  return index.getGraphQLResponse(query, variables, operationName);
}
origin: uber/okbuck

private boolean isPrebuiltDependency(ExternalDependency dependency) {
 return !skipPrebuiltDependencyMap.getOrDefault(dependency.getVersionless(), false)
   && (dependency.getPackaging().equals(AAR) || dependency.getPackaging().equals(JAR));
}
origin: apache/hbase

protected void updateMethodCountAndSizeByQueue(BlockingQueue<Runnable> queue,
  HashMap<String, Long> methodCount, HashMap<String, Long> methodSize) {
 for (Runnable r : queue) {
  FifoCallRunner mcr = (FifoCallRunner) r;
  RpcCall rpcCall = mcr.getCallRunner().getRpcCall();
  String method = getCallMethod(mcr.getCallRunner());
  if (StringUtil.isNullOrEmpty(method)) {
   method = "Unknown";
  }
  long size = rpcCall.getSize();
  methodCount.put(method, 1 + methodCount.getOrDefault(method, 0L));
  methodSize.put(method, size + methodSize.getOrDefault(method, 0L));
 }
}
origin: apache/hbase

public Map<String, Long> getCallQueueCountsSummary() {
 HashMap<String, Long> callQueueMethodTotalCount = new HashMap<>();
 for(BlockingQueue<CallRunner> queue: queues) {
  for (CallRunner cr:queue) {
   RpcCall rpcCall = cr.getRpcCall();
   String method;
   if (null==rpcCall.getMethod() ||
      StringUtil.isNullOrEmpty(method = rpcCall.getMethod().getName())) {
    method = "Unknown";
   }
   callQueueMethodTotalCount.put(method, 1+callQueueMethodTotalCount.getOrDefault(method, 0L));
  }
 }
 return callQueueMethodTotalCount;
}
origin: apache/hbase

public Map<String, Long> getCallQueueSizeSummary() {
 HashMap<String, Long> callQueueMethodTotalSize = new HashMap<>();
 for(BlockingQueue<CallRunner> queue: queues) {
  for (CallRunner cr:queue) {
   RpcCall rpcCall = cr.getRpcCall();
   String method;
   if (null==rpcCall.getMethod() ||
    StringUtil.isNullOrEmpty(method = rpcCall.getMethod().getName())) {
    method = "Unknown";
   }
   long size = rpcCall.getSize();
   callQueueMethodTotalSize.put(method, size+callQueueMethodTotalSize.getOrDefault(method, 0L));
  }
 }
 return callQueueMethodTotalSize;
}
origin: loklak/loklak_server

boolean fetchAllClasses = call.get("all", false);
if (fetchAllClasses) {
  List<String> allClasses = classInformation.getOrDefault(classifier, new ArrayList<>());
  classes = allClasses.toArray(new String[classes.length]);
origin: com.typesafe.play/play_2.12

/**
 * @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases.
 */
@Deprecated
@Override
public String getOrDefault(Object key, String defaultValue) {
  return super.getOrDefault(key, defaultValue);
}
origin: com.typesafe.play/play_2.11

/**
 * @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases.
 */
@Deprecated
@Override
public String getOrDefault(Object key, String defaultValue) {
  return super.getOrDefault(key, defaultValue);
}
origin: com.typesafe.play/play

/**
 * @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases.
 */
@Deprecated
@Override
public String getOrDefault(Object key, String defaultValue) {
  return super.getOrDefault(key, defaultValue);
}
origin: com.typesafe.play/play_2.11

/**
 * @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases.
 */
@Deprecated
@Override
public String getOrDefault(Object key, String defaultValue) {
  return super.getOrDefault(key, defaultValue);
}
origin: com.typesafe.play/play

/**
 * @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases.
 */
@Deprecated
@Override
public String getOrDefault(Object key, String defaultValue) {
  return super.getOrDefault(key, defaultValue);
}
origin: magefree/mage

@Override
public void watch(GameEvent event, Game game) {
  if (event.getType() == EventType.BEGIN_COMBAT_STEP_PRE) {
    this.playersAttacked.clear();
  }
  else if (event.getType() == EventType.ATTACKER_DECLARED) {
    Set<UUID> attackedPlayers = this.playersAttacked.getOrDefault(event.getPlayerId(), new HashSet<>(1));
    attackedPlayers.add(event.getTargetId());
    this.playersAttacked.put(event.getPlayerId(), attackedPlayers);
  }
}
origin: magefree/mage

@Override
public void watch(GameEvent event, Game game) {
  if (event.getType() == EventType.BEGIN_COMBAT_STEP_PRE) {
    this.playersAttacked.clear();
  } else if (event.getType() == EventType.ATTACKER_DECLARED) {
    Set<UUID> attackedPlayers = this.playersAttacked.getOrDefault(event.getPlayerId(), new HashSet<>(1));
    attackedPlayers.add(event.getTargetId());
    this.playersAttacked.put(event.getPlayerId(), attackedPlayers);
  }
}
java.utilHashMapgetOrDefault

Popular methods of HashMap

  • <init>
    Constructs a new HashMap instance containing the mappings from the specified map.
  • put
    Maps the specified key to the specified value.
  • get
    Returns the value of the mapping with the specified key.
  • containsKey
    Returns whether this map contains the specified key.
  • keySet
    Returns a set of the keys contained in this map. The set is backed by this map so changes to one are
  • remove
  • entrySet
    Returns a set containing all of the mappings in this map. Each mapping is an instance of Map.Entry.
  • values
    Returns a collection of the values contained in this map. The collection is backed by this map so ch
  • size
    Returns the number of elements in this map.
  • clear
    Removes all mappings from this hash map, leaving it empty.
  • isEmpty
    Returns whether this map is empty.
  • putAll
    Copies all the mappings in the specified map to this map. These mappings will replace all mappings t
  • isEmpty,
  • putAll,
  • clone,
  • toString,
  • containsValue,
  • equals,
  • hashCode,
  • computeIfAbsent,
  • forEach

Popular in Java

  • Creating JSON documents from java classes using gson
  • getResourceAsStream (ClassLoader)
  • runOnUiThread (Activity)
  • addToBackStack (FragmentTransaction)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Collectors (java.util.stream)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now