/** * Gets a Collection from <code>MultiValuedMap</code> in a null-safe manner. * * @param <K> the key type * @param <V> the value type * @param map the {@link MultiValuedMap} to use * @param key the key to look up * @return the Collection in the {@link MultiValuedMap}, or null if input map is null */ public static <K, V> Collection<V> getCollection(final MultiValuedMap<K, V> map, final K key) { if (map != null) { return map.get(key); } return null; }
/** * Gets a List from <code>MultiValuedMap</code> in a null-safe manner. * * @param <K> the key type * @param <V> the value type * @param map the {@link MultiValuedMap} to use * @param key the key to look up * @return the Collection in the {@link MultiValuedMap} as List, or null if input map is null */ public static <K, V> List<V> getValuesAsList(final MultiValuedMap<K, V> map, final K key) { if (map != null) { final Collection<V> col = map.get(key); if (col instanceof List) { return (List<V>) col; } return new ArrayList<>(col); } return null; }
/** * Gets a Set from <code>MultiValuedMap</code> in a null-safe manner. * * @param <K> the key type * @param <V> the value type * @param map the {@link MultiValuedMap} to use * @param key the key to look up * @return the Collection in the {@link MultiValuedMap} as Set, or null if input map is null */ public static <K, V> Set<V> getValuesAsSet(final MultiValuedMap<K, V> map, final K key) { if (map != null) { final Collection<V> col = map.get(key); if (col instanceof Set) { return (Set<V>) col; } return new HashSet<>(col); } return null; }
@Override public Collection<V> get(final K key) { return decorated().get(key); }
/** * Gets a Bag from <code>MultiValuedMap</code> in a null-safe manner. * * @param <K> the key type * @param <V> the value type * @param map the {@link MultiValuedMap} to use * @param key the key to look up * @return the Collection in the {@link MultiValuedMap} as Bag, or null if input map is null */ public static <K, V> Bag<V> getValuesAsBag(final MultiValuedMap<K, V> map, final K key) { if (map != null) { final Collection<V> col = map.get(key); if (col instanceof Bag) { return (Bag<V>) col; } return new HashBag<>(col); } return null; }
@Override public Collection<V> get(final K key) { return UnmodifiableCollection.unmodifiableCollection(decorated().get(key)); }
@Override public boolean putAll(final K key, final Iterable<? extends V> values) { if (values == null) { throw new NullPointerException("Values must not be null."); } final Iterable<V> transformedValues = FluentIterable.of(values).transform(valueTransformer); final Iterator<? extends V> it = transformedValues.iterator(); return it.hasNext() && CollectionUtils.addAll(decorated().get(transformKey(key)), it); }
public <A extends Annotation> Collection<LifeCycleHook> getTriggers(Class<A> annotationClass) { Collection<LifeCycleHook> methods = classToTriggers.get(annotationClass); return methods == null ? Collections.emptyList() : methods; }
public <A extends Annotation> Collection<LifeCycleHook> getTriggers(Class<A> annotationClass) { Collection<LifeCycleHook> methods = classToTriggers.get(annotationClass); return methods == null ? Collections.emptyList() : methods; }
public SortedSet<Card> diamonds() { return new TreeSet<>(this.cardsBySuit.get(Suit.DIAMONDS)); }
public SortedSet<Card> clubs() { return new TreeSet<>(this.cardsBySuit.get(Suit.CLUBS)); }
/** * Returns the set of bindings that provide at least one of the given properties */ private Set<VarBindingDef> getPropertyProviders( Set<String> properties) { Set<VarBindingDef> bindings = new HashSet<VarBindingDef>(); for( String property : properties) { bindings.addAll( propertyProviders_.get( property)); } return bindings; }
public <A extends Annotation> Collection<LifeCycleHook> getTriggers(Class<A> annotationClass, String fieldName) { Collection<LifeCycleHook> methods = fieldsToTriggers.get(Pair.of(annotationClass, fieldName)); return methods == null ? Collections.emptyList() : methods; }
public <A extends Annotation> Collection<LifeCycleHook> getTriggers(Class<A> annotationClass, String fieldName) { Collection<LifeCycleHook> methods = fieldsToTriggers.get(Pair.of(annotationClass, fieldName)); return methods == null ? Collections.emptyList() : methods; }
@Override public Object instantiate() { return constructorParameters.get(clazz) .stream() .map(this::createObjectUsingConstructorParameters) .filter(Objects::nonNull) .findAny() .orElseThrow(this::createObjectInstantiationException); }
public static Collection<RObjectType> getDescendantsForQName(QName typeName) { return descendants.get(ObjectTypes.getObjectTypeFromTypeQName(typeName)); } }
protected Object instantiateUsingUserParameters() { final Collection<ConstructorParameters> userConstructorParameters = constructorParameters.get(clazz); if (userDefinedOwnParametersForThisClass(userConstructorParameters)) { final Object result = tryToInstantiateUsing(userConstructorParameters); if (result != null) { return result; } LOGGER.warn("Could not instantiate class {} with user defined parameters. " + "Trying create instance finding best constructor", clazz); } return null; }
@Override public List<Recommender> getActiveRecommenders(User aUser, AnnotationLayer aLayer) { RecommendationState state = getState(aUser.getUsername(), aLayer.getProject()); synchronized (state) { MultiValuedMap<AnnotationLayer, Recommender> activeRecommenders = state.getActiveRecommenders(); return new ArrayList<>(activeRecommenders.get(aLayer)); } }
public static void startCallback(String desc) { if (recording()) { System.out.println("Starting execution: " + desc); currentRun = new RunInfo(); currentRun.name = desc; currentRun.index = CollectionUtils.emptyIfNull(runs.get(desc)).size(); } }