Example usage for java.util Collections singleton

List of usage examples for java.util Collections singleton

Introduction

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

Prototype

public static <T> Set<T> singleton(T o) 

Source Link

Document

Returns an immutable set containing only the specified object.

Usage

From source file:org.apereo.services.persondir.support.StubPersonAttributeDao.java

@Override
public Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(final Map<String, List<Object>> query) {
    if (query == null) {
        throw new IllegalArgumentException("Illegal to invoke getPeople(Map) with a null argument.");
    }/*from w w w.  ja  v a 2 s  .  co  m*/

    if (this.backingPerson == null) {
        return null;
    }
    return Collections.singleton(this.backingPerson);
}

From source file:com.griddynamics.jagger.engine.e1.reporting.WorkloadProcessTimePlotsReporter.java

@Override
public JRDataSource getDataSource(String testId) {
    if (taskPlots == null) {
        taskPlots = createTaskPlots();/*  w w w.  j av a  2 s. c  o  m*/
    }

    return new JRBeanCollectionDataSource(Collections.singleton(taskPlots.get(testId)));
}

From source file:com.opengamma.financial.analytics.PositionScalingFunction.java

@Override
public Set<ValueRequirement> getRequirements(final FunctionCompilationContext context,
        final ComputationTarget target, final ValueRequirement desiredValue) {
    final Position position = target.getPosition();
    final Security security = position.getSecurity();
    final ValueRequirement requirement = new ValueRequirement(_requirementName, ComputationTargetType.SECURITY,
            security.getUniqueId(), desiredValue.getConstraints().withoutAny(ValuePropertyNames.FUNCTION));
    return Collections.singleton(requirement);
}

From source file:com.mirth.connect.server.api.servlets.EngineServlet.java

@Override
@CheckAuthorizedChannelId// w w  w.  j a  va 2  s.c  o  m
public void undeployChannel(String channelId, boolean returnErrors) {
    ErrorTaskHandler handler = new ErrorTaskHandler();
    engineController.undeployChannels(Collections.singleton(channelId), context, handler);
    if (returnErrors && handler.isErrored()) {
        throw new MirthApiException(handler.getError());
    }
}

From source file:edu.pitt.dbmi.ccd.db.service.DataFileService.java

public DataFile findByIdAndUserAccount(Long id, UserAccount userAccount) {
    return dataFileRepository.findByIdAndUserAccounts(id, Collections.singleton(userAccount));
}

From source file:com.devicehive.defects.Defect157CommandTest.java

@Before
public void prepareCommands() {
    DeviceClassEquipmentVO equipment = DeviceFixture.createEquipmentVO();
    DeviceClassUpdate deviceClass = DeviceFixture.createDeviceClass();
    deviceClass.setEquipment(Optional.of(Collections.singleton(equipment)));
    NetworkVO network = DeviceFixture.createNetwork();
    DeviceUpdate deviceUpdate = DeviceFixture.createDevice(guid);
    deviceUpdate.setDeviceClass(Optional.of(deviceClass));
    deviceUpdate.setNetwork(Optional.of(network));

    // register device
    Response response = performRequest("/device/" + guid, "PUT", emptyMap(),
            singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), deviceUpdate, NO_CONTENT,
            null);//ww w  .  j a  va  2  s .  co  m
    assertNotNull(response);

    {
        DeviceCommand command = createDeviceCommand("c1", "s2");
        command = performRequest("/device/" + guid + "/command", "POST", emptyMap(),
                singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), command, CREATED,
                DeviceCommand.class);

        assertNotNull(command.getId());
    }

    {
        DeviceCommand command = createDeviceCommand("c2", "s1");
        command = performRequest("/device/" + guid + "/command", "POST", emptyMap(),
                singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), command, CREATED,
                DeviceCommand.class);

        assertNotNull(command.getId());
    }

    {
        DeviceCommand command = createDeviceCommand("c3", "s3");
        command = performRequest("/device/" + guid + "/command", "POST", emptyMap(),
                singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), command, CREATED,
                DeviceCommand.class);

        assertNotNull(command.getId());
    }
}

From source file:com.github.sps.metrics.opentsdb.OpenTsdb.java

/**
 * Send a metric to opentsdb
 */
public void send(OpenTsdbMetric metric) {
    send(Collections.singleton(metric));
}

From source file:com.opengamma.financial.analytics.model.equity.indexoption.EquityIndexOptionDefaultPropertiesFunction.java

@Override
protected Set<String> getDefaultValue(FunctionCompilationContext context, ComputationTarget target,
        ValueRequirement desiredValue, String propertyName) {
    if (YieldCurveFunction.PROPERTY_FUNDING_CURVE.equals(propertyName)) {
        return Collections.singleton(_fundingCurveName);
    } else if (ValuePropertyNames.SURFACE.equals(propertyName)) {
        return Collections.singleton(_volSurfaceName);
    } else if (BlackVolatilitySurfacePropertyNamesAndValues.PROPERTY_SMILE_INTERPOLATOR.equals(propertyName)) {
        return Collections.singleton(_smileInterpolator);
    }/*  w  ww  . ja  v a 2  s. c  om*/
    return null;
}

From source file:pl.nask.hsn2.service.FailedRequestTest.java

@SuppressWarnings("unused")
private void defineTestsExpectations() throws Exception {
    final DataResponse dataResponse = new DataResponse(1L);
    final ObjectResponse saveObjectsResponse = new ObjectResponse(
            pl.nask.hsn2.bus.operations.ObjectResponse.ResponseType.SUCCESS_PUT);
    saveObjectsResponse.setObjects(Collections.singleton(1L));
    new NonStrictExpectations() {
        {//from  ww  w  . ja va2  s  .c  o m
            // Sends data to Data Store as a byte array.
            connector.sendDataStoreData(anyLong, withInstanceOf(byte[].class));
            result = dataResponse;

            // Sends data to Data Store as an input stream.
            connector.sendDataStoreData(anyLong, withInstanceOf(InputStream.class));
            result = dataResponse;

            // Updating job context with new attributes.
            connector.updateObject(anyLong, withInstanceOf(ObjectData.class));
            result = saveObjectsResponse;
            forEachInvocation = new Object() {
                void validate(long jobId, ObjectData data) {
                    MockTestsHelper.connectorUpdatesObject(data, updatedAttributes);
                }
            };
        }
    };

    new NonStrictExpectations() {
        final WebClientDataStoreHelper wcHelper = null;
        {
            // Get cookies from Data Store.
            WebClientDataStoreHelper.getCookiesFromDataStore(connector, anyLong, anyLong);
            result = COOKIE_WRAPPERS;
        }
    };
}

From source file:org.commonjava.maven.galley.transport.htcli.internal.AbstractHttpJob.java

protected AbstractHttpJob(final String url, final HttpLocation location, final Http http,
        final Integer... successStatuses) {
    this.url = url;
    this.location = location;
    this.http = http;

    if (successStatuses.length < 1) {
        this.successStatuses = Collections.singleton(HttpStatus.SC_OK);
    } else {/*from w  ww.j  a  v  a  2 s .  com*/
        this.successStatuses = Arrays.asList(successStatuses);
    }
}