Example usage for java.util Collections emptySet

List of usage examples for java.util Collections emptySet

Introduction

In this page you can find the example usage for java.util Collections emptySet.

Prototype

@SuppressWarnings("unchecked")
public static final <T> Set<T> emptySet() 

Source Link

Document

Returns an empty set (immutable).

Usage

From source file:nl.surfnet.coin.api.service.JanusClientDetailsService.java

private Set<String> getCallbackUrlCollection(final EntityMetadata metadata) {
    final String callbackUrl = metadata.getOauthCallbackUrl();
    //sensible default
    Set<String> result = Collections.emptySet();
    if (callbackUrl != null) {
        if (callbackUrl.contains(",")) {
            //need to trim, therefore more code then calling StringUtils#commaDelimitedListToSet
            String[] callbacksArray = StringUtils.commaDelimitedListToStringArray(callbackUrl);
            result = new HashSet<String>();
            for (String callback : callbacksArray) {
                result.add(callback.trim());
            }/*ww w  . j  av a  2s .  co  m*/
        } else {
            result = Collections.singleton(callbackUrl.trim());
        }
    }
    return result;
}

From source file:se.uu.it.cs.recsys.constraint.solver.Solver.java

private Set<List<se.uu.it.cs.recsys.api.type.Course>> search(Store store, SetVar[] vars) {
    LOGGER.debug("Start searching solution ... ");

    Domain[][] solutions = doSearch(store, vars);

    if (solutions == null || solutions.length == 0) {
        LOGGER.debug("No solution found!");
        return Collections.emptySet();
    }//from  ww w. j a  v  a  2  s  . com

    Set<List<se.uu.it.cs.recsys.api.type.Course>> result = new HashSet<>();

    Arrays.stream(solutions).filter(solution -> {
        return solution != null && solution.length > 0;
    }).forEach(solution -> {
        result.add(this.resultConverter.convert(solution));
    });

    return result;

}

From source file:org.jasig.springframework.security.portlet.authentication.PortletXmlMappableAttributesRetrieverTest.java

@Test
public void testZeroNoAttributes() throws Exception {
    final PortletXmlMappableAttributesRetriever portletXmlMappableAttributesRetriever = new PortletXmlMappableAttributesRetriever();

    final ResourceLoader resourceLoader = mock(ResourceLoader.class);
    when(resourceLoader.getResource("/WEB-INF/portlet.xml")).thenReturn(new ClassPathResource(
            "/org/jasig/springframework/security/portlet/authentication/portlet_0_no_attributes.xml"));
    portletXmlMappableAttributesRetriever.setResourceLoader(resourceLoader);

    portletXmlMappableAttributesRetriever.afterPropertiesSet();

    final Set<String> mappableAttributes = portletXmlMappableAttributesRetriever.getMappableAttributes();

    assertEquals(Collections.emptySet(), mappableAttributes);
}

From source file:com.ctriposs.rest4j.common.testutils.DataAssert.java

/**
 * Asserts that two {@link DataMap}s are equal, subject to the {@code excludedProperties} and
 * {@code nullShouldEqualEmptyListOrMap} arguments.
 *
 * @param actualMap the {@link DataMap} we are checking
 * @param expectedMap the expected {@link DataMap}
 * @param excludedProperties the properties that will be ignored while checking the two DataMaps
 * @param nullShouldEqualEmptyListOrMap true if null should equal an empty {@link DataMap} or {@link DataList}
 *//*from  w ww  . j  a v a2  s. co  m*/
public static void assertDataMapsEqual(DataMap actualMap, DataMap expectedMap, Set<String> excludedProperties,
        boolean nullShouldEqualEmptyListOrMap) {
    if (excludedProperties == null) {
        excludedProperties = Collections.emptySet();
    }

    if (actualMap == null || expectedMap == null) {
        Assert.assertEquals(actualMap, expectedMap, "Only one of the data maps is null!");
        return;
    }

    Set<String> failKeys = new HashSet<String>();

    // Assert key by key so it's easy to debug on assertion failure
    Set<String> allKeys = new HashSet<String>(actualMap.keySet());
    allKeys.addAll(expectedMap.keySet());
    for (String key : allKeys) {
        if (excludedProperties.contains(key)) {
            continue;
        }

        Object actualObject = actualMap.get(key);
        Object expectedObject = expectedMap.get(key);
        if (actualObject == null) {
            if (nullShouldEqualEmptyListOrMap && isEmptyListOrMap(expectedObject)) {
                continue;
            }
            if (expectedObject != null) {
                failKeys.add(key);
            }
        } else if (!actualObject.equals(expectedObject)) {
            if (nullShouldEqualEmptyListOrMap && expectedObject == null && isEmptyListOrMap(actualObject)) {
                continue;
            }
            failKeys.add(key);
        }
    }

    if (!failKeys.isEmpty()) {
        List<String> errorMessages = new ArrayList<String>();
        errorMessages.add(failKeys.size() + " properties don't match:");
        for (String k : failKeys) {
            errorMessages.add("\tMismatch on property \"" + k + "\", expected:<" + expectedMap.get(k)
                    + "> but was:<" + actualMap.get(k) + ">");
        }
        Assert.fail(StringUtils.join(errorMessages, ERROR_MESSAGE_SEPARATOR));
    }
}

From source file:com.ikanow.aleph2.analytics.spark.services.SparkPyWrapperService.java

/** Get a named RDD
 *  (NOTE: will join RDDs of the same name together)
 * @param input_name// w w  w. j a  va 2  s .c o m
 * @return
 */
@SuppressWarnings("unchecked")
public JavaRDD<Map<String, Object>> getRddInput(final String input_name) {
    initializeRdd(Collections.emptySet());

    // (not sure why the cast is needed, eclipse happy but maven fails)
    return (JavaRDD<Map<String, Object>>) _rdd_set.get().get(input_name).stream()
            .reduce((acc1, acc2) -> acc1.union(acc2))
            .<JavaRDD<Map<String, Object>>>map(rdd -> rdd
                    .<Map<String, Object>>map(t2 -> _mapper.convertValue(t2._2()._2().getJson(), Map.class)))
            .orElse(null);
}

From source file:org.apache.tajo.validation.NetworkAddressValidator.java

@Override
protected Collection<Validator> getDependantValidators() {
    return Collections.emptySet();
}

From source file:com.civis.utils.opennlp.models.address.AddressFinderMe.java

/**
 * Default constructor to init train madel.
 *///from w ww.j  ava 2s.  c o m
public AddressFinderMe(TrainConfigData trainConfigData) {
    super(trainConfigData);
    this.csvAddressDataList = Collections.emptyList();
    this.countries = Collections.emptySet();
    setDefaultTrainingParametersIfNull();
}

From source file:com.pc.dailymile.domain.Entry.java

public Set<Comment> getComments() {
    if (comments == null) {
        return Collections.emptySet();
    }//from www .  j  a  va 2s .  c  om
    return new TreeSet<Comment>(comments);
}

From source file:com.orange.cloud.servicebroker.filter.core.filters.AbstractServiceBrokerFilterTest.java

private static Mono<Void> setEnvs(CloudFoundryOperations cloudFoundryOperations, String applicationName,
        Map<String, String> envs) {
    return Optional.ofNullable(envs).map(Map::entrySet).orElse(Collections.emptySet()).stream()
            .map(env -> setEnvironmentVariable(cloudFoundryOperations, applicationName, env.getKey(),
                    env.getValue()))/*from  w  w  w. j  a va2 s. com*/
            .reduce(Mono.empty().then(), (x, y) -> x.then(y));

}

From source file:mp.platform.cyclone.webservices.utils.server.FieldHelper.java

/**
 * Convert an array of FieldValue instances to a collection of CustomFieldValue
 *//*from  w  w  w.  ja v  a2 s  .  co  m*/
@SuppressWarnings("unchecked")
public <T extends CustomFieldValue> Collection<T> toValueCollection(
        final Collection<? extends CustomField> fields, final List<? extends FieldValueVO> fieldValues) {
    if (CollectionUtils.isEmpty(fields) || CollectionUtils.isEmpty(fieldValues)) {
        return Collections.emptySet();
    }
    final List<T> customValues = new ArrayList<T>();
    for (final FieldValueVO fieldValue : fieldValues) {
        final String key = fieldValue.getField();
        CustomField field;
        // Check if key is the id or internal name
        if (StringUtils.isNumeric(key)) {
            // By id
            field = CustomFieldHelper.findById(fields, Long.parseLong(key));
        } else {
            field = CustomFieldHelper.findByInternalName(fields, key);
        }
        if (field == null) {
            throw new IllegalArgumentException("Custom field " + key + " not found");
        }
        final T value = (T) ClassHelper.instantiate(field.getNature().getValueType());
        value.setField(field);
        value.setValue(fieldValue.getValue());
        if (StringUtils.isNotEmpty(field.getPattern())) {
            value.setValue(StringHelper.removeMask(field.getPattern(), value.getValue()));
        }
        if (fieldValue instanceof RegistrationFieldValueVO && value instanceof MemberCustomFieldValue) {
            final RegistrationFieldValueVO reg = (RegistrationFieldValueVO) fieldValue;
            final MemberCustomFieldValue memberValue = (MemberCustomFieldValue) value;
            memberValue.setHidden(reg.isHidden());
        }
        customValues.add(value);
    }
    return customValues;
}