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:de.micromata.genome.gwiki.utils.html.Html2WikiFilter.java

public static String html2Wiki(String text) {
    Set<String> s = Collections.emptySet();
    return html2Wiki(text, s);
}

From source file:net.algart.simagis.live.json.minimal.SimagisLiveUtils.java

public static Set<String> getKeySet(JSONObject jsonObject) {
    if (jsonObject == null) {
        return Collections.emptySet();
    }// w  ww.j  ava2  s  . c  o m
    final TreeSet<String> result = new TreeSet<String>();
    final Iterator keys = jsonObject.keys();
    while (keys.hasNext()) {
        result.add((String) keys.next());
    }
    return Collections.unmodifiableSortedSet(result);
}

From source file:com.unboundid.scim2.server.utils.ResourcePreparer.java

/**
 * Private constructor used by unit-test.
 *
 * @param resourceType The resource type definition for resources to prepare.
 * @param attributesString The attributes query param.
 * @param excludedAttributesString The excludedAttributes query param.
 * @param baseUri The resource type base URI.
 *//*from  ww w  .j av a 2  s  . c  o  m*/
ResourcePreparer(final ResourceTypeDefinition resourceType, final String attributesString,
        final String excludedAttributesString, final URI baseUri) throws BadRequestException {
    if (attributesString != null && !attributesString.isEmpty()) {
        Set<String> attributeSet = StaticUtils
                .arrayToSet(StaticUtils.splitCommaSeparatedString(attributesString));
        this.queryAttributes = new LinkedHashSet<Path>(attributeSet.size());
        for (String attribute : attributeSet) {
            Path normalizedPath;
            try {
                normalizedPath = resourceType.normalizePath(Path.fromString(attribute)).withoutFilters();
            } catch (BadRequestException e) {
                throw BadRequestException.invalidValue("'" + attribute
                        + "' is not a valid value for the attributes parameter: " + e.getMessage());
            }
            this.queryAttributes.add(normalizedPath);

        }
        this.excluded = false;
    } else if (excludedAttributesString != null && !excludedAttributesString.isEmpty()) {
        Set<String> attributeSet = StaticUtils
                .arrayToSet(StaticUtils.splitCommaSeparatedString(excludedAttributesString));
        this.queryAttributes = new LinkedHashSet<Path>(attributeSet.size());
        for (String attribute : attributeSet) {
            Path normalizedPath;
            try {
                normalizedPath = resourceType.normalizePath(Path.fromString(attribute)).withoutFilters();
            } catch (BadRequestException e) {
                throw BadRequestException.invalidValue("'" + attribute
                        + "' is not a valid value for the excludedAttributes parameter: " + e.getMessage());
            }
            this.queryAttributes.add(normalizedPath);
        }
        this.excluded = true;
    } else {
        this.queryAttributes = Collections.emptySet();
        this.excluded = true;
    }
    this.resourceType = resourceType;
    this.baseUri = baseUri;
}

From source file:com.ocpsoft.pretty.faces.el.resolver.FacesConfigBeanNameResolver.java

/**
 * Returns a collection of faces configuration files mentioned via the
 * default <code>javax.faces.CONFIG_FILES</code> init parameter
 * /*from ww w . j  a v  a  2 s . c  o  m*/
 * @param servletContext
 *           The ServletContext
 * @return A collection of URLs (never null)
 */
private Collection<URL> getConfigFilesFromInitParameter(ServletContext servletContext) {

    // read init parameter
    String initParam = servletContext.getInitParameter(FacesServlet.CONFIG_FILES_ATTR);

    // empty? return empty set
    if (initParam == null || initParam.trim().length() == 0) {
        return Collections.emptySet();
    }

    // split string at each comma
    String[] files = initParam.split(",");

    // the result
    Set<URL> result = new HashSet<URL>();

    // process each single file
    for (String file : files) {

        // ignore empty entries
        if (file.trim().length() == 0) {
            continue;
        }

        try {
            // try get URL for this file
            URL url = servletContext.getResource(file.trim());

            // add it to the result, if it exists
            if (url != null) {
                result.add(url);
            }
        } catch (MalformedURLException e) {
            // log on debug level, because the JSF implementation should
            // handle such a case
            log.debug("Invalid entry in javax.faces.CONFIG_FILES init parameter: " + file);
        }

    }

    return result;
}

From source file:ee.ria.xroad.proxy.testsuite.MessageTestCase.java

/**
 * @param service the service ID/*from   w w  w .  j a va  2 s  . c  o  m*/
 * @return the security category IDs of the service with the given ID
 */
public Set<SecurityCategoryId> getRequiredCategories(ServiceId service) {
    return Collections.emptySet();
}

From source file:cz.cuni.mff.d3s.been.mapstore.mongodb.MongoMapStore.java

@Override
public Set loadAllKeys() {

    boolean loaded = false;
    ILock l = hazelcastInstance.getLock("LOADING_" + mapName);
    l.lock();/*from w w w .  ja v a  2 s  .c om*/

    IList loadedList = hazelcastInstance.getList(LOADED_LIST);
    if (loadedList.contains(mapName)) {
        loaded = true;
    }

    Set keyset = Collections.emptySet();

    if (!loaded) {
        try {
            keyset = new HashSet();
            BasicDBList dbo = new BasicDBList();
            dbo.add("_id");
            DBCursor cursor = coll.find(null, dbo);
            while (cursor.hasNext()) {
                keyset.add(cursor.next().get("_id"));
            }
            loadedList.add(mapName);
        } catch (Throwable t) {
            keyset = Collections.emptySet();
            log.warn("Cannot load keys from MongoDB", t);
        }
    }
    l.unlock();

    return keyset;
}

From source file:nu.yona.server.analysis.service.ActivityUpdateServiceTest.java

@Before
public void setUp() {
    setUpRepositoryMocks();/* ww w  . j ava 2  s .  com*/

    LocalDateTime yesterday = TimeUtil.utcNow().minusDays(1).withHour(0).withMinute(1).withSecond(0);
    gamblingGoal = BudgetGoal.createNoGoInstance(yesterday,
            ActivityCategory.createInstance(UUID.randomUUID(), usString("gambling"), false,
                    new HashSet<>(Arrays.asList("poker", "lotto")),
                    new HashSet<>(Arrays.asList("Poker App", "Lotto App")), usString("Descr")));
    newsGoal = BudgetGoal.createNoGoInstance(yesterday,
            ActivityCategory.createInstance(UUID.randomUUID(), usString("news"), false,
                    new HashSet<>(Arrays.asList("refdag", "bbc")), Collections.emptySet(), usString("Descr")));
    gamingGoal = BudgetGoal.createNoGoInstance(yesterday,
            ActivityCategory.createInstance(UUID.randomUUID(), usString("gaming"), false,
                    new HashSet<>(Arrays.asList("games")), Collections.emptySet(), usString("Descr")));
    socialGoal = TimeZoneGoal.createInstance(yesterday,
            ActivityCategory.createInstance(UUID.randomUUID(), usString("social"), false,
                    new HashSet<>(Arrays.asList("social")), Collections.emptySet(), usString("Descr")),
            Collections.emptyList());
    shoppingGoal = BudgetGoal
            .createInstance(yesterday,
                    ActivityCategory.createInstance(UUID.randomUUID(), usString("shopping"), false,
                            new HashSet<>(Arrays.asList("webshop")), Collections.emptySet(), usString("Descr")),
                    1);

    goalMap.put("gambling", gamblingGoal);
    goalMap.put("news", newsGoal);
    goalMap.put("gaming", gamingGoal);
    goalMap.put("social", socialGoal);
    goalMap.put("shopping", shoppingGoal);

    when(mockYonaProperties.getAnalysisService()).thenReturn(new AnalysisServiceProperties());

    // Set up UserAnonymized instance.
    MessageDestination anonMessageDestinationEntity = MessageDestination
            .createInstance(PublicKeyUtil.generateKeyPair().getPublic());
    Set<Goal> goals = new HashSet<>(Arrays.asList(gamblingGoal, gamingGoal, socialGoal, shoppingGoal));
    deviceAnonEntity = DeviceAnonymized.createInstance(0, OperatingSystem.IOS, "Unknown", 0, Optional.empty());
    deviceAnonId = deviceAnonEntity.getId();
    userAnonEntity = UserAnonymized.createInstance(anonMessageDestinationEntity, goals);
    userAnonEntity.addDeviceAnonymized(deviceAnonEntity);
    userAnonDto = UserAnonymizedDto.createInstance(userAnonEntity);
    deviceAnonDto = DeviceAnonymizedDto.createInstance(deviceAnonEntity);
    anonMessageDestination = userAnonDto.getAnonymousDestination();
    userAnonId = userAnonDto.getId();
    userAnonZoneId = userAnonDto.getTimeZone();

    // Stub the UserAnonymizedService to return our user.
    when(mockUserAnonymizedService.getUserAnonymized(userAnonId)).thenReturn(userAnonDto);
    when(mockUserAnonymizedService.getUserAnonymizedEntity(userAnonId)).thenReturn(userAnonEntity);

    // Stub the GoalService to return our goals.
    when(mockGoalService.getGoalEntityForUserAnonymizedId(userAnonId, gamblingGoal.getId()))
            .thenReturn(gamblingGoal);
    when(mockGoalService.getGoalEntityForUserAnonymizedId(userAnonId, gamingGoal.getId()))
            .thenReturn(gamingGoal);
    when(mockGoalService.getGoalEntityForUserAnonymizedId(userAnonId, socialGoal.getId()))
            .thenReturn(socialGoal);
    when(mockGoalService.getGoalEntityForUserAnonymizedId(userAnonId, shoppingGoal.getId()))
            .thenReturn(shoppingGoal);

    // Mock the week activity repository
    when(mockWeekActivityRepository.findOne(any(UUID.class), any(UUID.class), any(LocalDate.class)))
            .thenAnswer(new Answer<WeekActivity>() {
                @Override
                public WeekActivity answer(InvocationOnMock invocation) throws Throwable {
                    Optional<Goal> goal = goalMap.values().stream()
                            .filter(g -> g.getId() == invocation.getArgumentAt(1, UUID.class)).findAny();
                    if (!goal.isPresent()) {
                        return null;
                    }
                    return goal.get().getWeekActivities().stream().filter(
                            wa -> wa.getStartDate().equals(invocation.getArgumentAt(2, LocalDate.class)))
                            .findAny().orElse(null);
                }
            });

    // Mock device service and repo
    when(mockDeviceAnonymizedRepository.getOne(deviceAnonId)).thenReturn(deviceAnonEntity);
}

From source file:org.apache.tapestry5.internal.spring.SpringModuleDef.java

public SpringModuleDef(ServletContext servletContext) {
    this.servletContext = servletContext;

    compatibilityMode = Boolean/*from  www. j av a 2 s.com*/
            .parseBoolean(servletContext.getInitParameter(SpringConstants.USE_EXTERNAL_SPRING_CONTEXT));

    final ApplicationContext externalContext = compatibilityMode ? locateExternalContext() : null;

    if (compatibilityMode)
        addServiceDefsForSpringBeans(externalContext);

    ServiceDef applicationContextServiceDef = new ServiceDef() {
        @Override
        public ObjectCreator createServiceCreator(final ServiceBuilderResources resources) {
            if (compatibilityMode)
                return new StaticObjectCreator(externalContext,
                        "externally configured Spring ApplicationContext");

            ApplicationContextCustomizer customizer = resources.getService("ApplicationContextCustomizer",
                    ApplicationContextCustomizer.class);

            return constructObjectCreatorForApplicationContext(resources, customizer);
        }

        @Override
        public String getServiceId() {
            return SERVICE_ID;
        }

        @Override
        public Set<Class> getMarkers() {
            return Collections.emptySet();
        }

        @Override
        public Class getServiceInterface() {
            return compatibilityMode ? externalContext.getClass() : ConfigurableWebApplicationContext.class;
        }

        @Override
        public String getServiceScope() {
            return ScopeConstants.DEFAULT;
        }

        @Override
        public boolean isEagerLoad() {
            return false;
        }
    };

    services.put(SERVICE_ID, applicationContextServiceDef);
}

From source file:io.cloudslang.lang.systemtests.BindingScopeTest.java

@Test
public void testInputRequiredWithEmptyValue() throws Exception {
    URL resource = getClass().getResource("/yaml/check_weather_input_required.sl");
    final CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource.toURI()),
            new HashSet<SlangSource>());

    Map<String, Value> userInputs = new HashMap<>();
    userInputs.put("city", ValueFactory.create(""));
    Set<SystemProperty> systemProperties = Collections.emptySet();

    exception.expect(RuntimeException.class);

    exception.expectMessage(new BaseMatcher<String>() {
        public void describeTo(Description description) {
        }//from  w w w  .ja  va 2  s .  c  o  m

        public boolean matches(Object o) {
            String message = o.toString();
            return message.contains("Error running: 'check_weather_input_required'.")
                    && message.contains("Input with name: 'city' is Required, but value is empty");
        }
    });
    triggerWithData(compilationArtifact, userInputs, systemProperties);
}

From source file:hudson.plugins.ec2.SlaveTemplate.java

public Set<String> parseSecurityGroups() {
    if (securityGroups == null || "".equals(securityGroups.trim())) {
        return Collections.emptySet();
    } else {/*from   ww  w . j av  a  2s.  c o m*/
        return new HashSet<String>(Arrays.asList(securityGroups.split("\\s*,\\s*")));
    }
}