当前位置: 首页>>代码示例>>Java>>正文


Java Unchecked类代码示例

本文整理汇总了Java中org.jooq.lambda.Unchecked的典型用法代码示例。如果您正苦于以下问题:Java Unchecked类的具体用法?Java Unchecked怎么用?Java Unchecked使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Unchecked类属于org.jooq.lambda包,在下文中一共展示了Unchecked类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyAuthenticateSuccess

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
@Test
public void verifyAuthenticateSuccess() throws Exception {
    assertNotEquals(handler.size(), 0);
    getEntries().forEach(entry -> {
        final String username = entry.getAttribute("sAMAccountName").getStringValue();
        final String psw = entry.getAttribute("userPassword").getStringValue();

        this.handler.forEach(Unchecked.consumer(h -> {
            final HandlerResult result = h.authenticate(new UsernamePasswordCredential(username, psw));
            assertNotNull(result.getPrincipal());
            assertEquals(username, result.getPrincipal().getId());
            assertEquals(
                    entry.getAttribute("displayName").getStringValue(),
                    result.getPrincipal().getAttributes().get("displayName"));
            assertEquals(
                    entry.getAttribute("mail").getStringValue(),
                    result.getPrincipal().getAttributes().get("mail"));
        }));
    });
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:21,代码来源:LdapAuthenticationHandlerTests.java

示例2: jsonAttributeRepositories

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
@ConditionalOnMissingBean(name = "jsonAttributeRepositories")
@Bean
@RefreshScope
public List<IPersonAttributeDao> jsonAttributeRepositories() {
    final List<IPersonAttributeDao> list = new ArrayList<>();
    casProperties.getAuthn().getAttributeRepository().getJson().forEach(Unchecked.consumer(json -> {
        final Resource r = json.getConfig().getLocation();
        if (r != null) {
            final JsonBackedComplexStubPersonAttributeDao dao = new JsonBackedComplexStubPersonAttributeDao(r);
            dao.setOrder(json.getOrder());
            dao.init();
            LOGGER.debug("Configured JSON attribute sources from [{}]", r);
            list.add(dao);
        }
    }));
    return list;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:CasPersonDirectoryConfiguration.java

示例3: getUserByEmail

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
public User getUserByEmail(String email) {
    HttpUrl route = HttpUrl.parse(host + "/users")
                           .newBuilder()
                           .addPathSegment(email)
                           .build();
    Request request = new Request.Builder().url(route).get().build();
    return Unchecked.supplier(() -> {
        try (Response response = client.newCall(request).execute()) {
            // The user exists
            if (response.isSuccessful()) {
                User user = Json.serializer().fromInputStream(response.body().byteStream(), User.typeRef());
                return user;
            }

            /*
             *  404 Not Found - Either return null or throw your own exception.
             *  We prefer nulls.
             */
            if (response.code() == StatusCodes.NOT_FOUND) {
                return null;
            }
            throw HttpClient.unknownException(response);
        }
    }).get();
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:26,代码来源:RestClient.java

示例4: deleteUserByEmail

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
public boolean deleteUserByEmail(String email) {
    HttpUrl route = HttpUrl.parse(host + "/users")
                           .newBuilder()
                           .addPathSegment(email)
                           .build();
    Request request = new Request.Builder().url(route).delete().build();
    return Unchecked.booleanSupplier(() -> {
        try (Response response = client.newCall(request).execute()) {
            if (response.code() == StatusCodes.NO_CONTENT) {
                return true;
            }

            // Maybe you would throw an exception here? We don't feel the need to.
            if (response.code() == StatusCodes.NOT_FOUND) {
                return false;
            }
            throw HttpClient.unknownException(response);
        }
    }).getAsBoolean();
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:21,代码来源:RestClient.java

示例5: createUser

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
public User createUser(User inputUser) {
    HttpUrl route = HttpUrl.parse(host + "/users");
    Request request = new Request.Builder()
        .url(route)
        .post(RequestBodies.jsonObj(inputUser))
        .build();
    return Unchecked.supplier(() -> {
        try (Response response = client.newCall(request).execute()) {
            if (response.code() == StatusCodes.CREATED) {
                User user = Json.serializer().fromInputStream(response.body().byteStream(), User.typeRef());
                return user;
            }

            if (response.code() == StatusCodes.BAD_REQUEST) {
                return null;
            }
            throw HttpClient.unknownException(response);
        }
    }).get();
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:21,代码来源:RestClient.java

示例6: updateUser

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
public User updateUser(User inputUser) {
    HttpUrl route = HttpUrl.parse(host + "/users");
    Request request = new Request.Builder()
            .url(route)
            .put(RequestBodies.jsonObj(inputUser))
            .build();
    return Unchecked.supplier(() -> {
        try (Response response = client.newCall(request).execute()) {
            if (response.isSuccessful()) {
                User user = Json.serializer().fromInputStream(response.body().byteStream(), User.typeRef());
                return user;
            }

            if (response.code() == StatusCodes.NOT_FOUND) {
                return null;
            }
            throw HttpClient.unknownException(response);
        }
    }).get();
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:21,代码来源:RestClient.java

示例7: getSalonQuestions

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
static public List<SalonQuestion> getSalonQuestions(long docID, SalonDB salonDB) throws SQLException {
	String sql = "SELECT * from question where document_id = ?";
	try (PreparedStatement stmt = salonDB.prep(sql)) {
		stmt.setLong(1,  docID);
		
		Seq<SalonQuestion> docs =  SQL.seq(stmt,  Unchecked.function(rs -> {
			SalonQuestion salonq = new SalonQuestion();
			salonq.questionID = rs.getLong("question_id");
			salonq.assignmentID = rs.getLong("assignment_id");
			salonq.questionText = rs.getString("question_text");
			salonq.documentID = rs.getLong("document_id");
			salonq.questionTitle = rs.getString("question_title");
			salonq.createdDate = rs.getTimestamp("created_date");
			salonq.userID = rs.getLong("user_id");
			return salonq;
		  }
		));
		return docs.toList();
	}
}
 
开发者ID:DiscourseDB,项目名称:discoursedb-core,代码行数:21,代码来源:SalonQuestion.java

示例8: getSalonInfo

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
static public SalonInfo getSalonInfo(int salonID, SalonDB salonDB) throws SQLException {
	String sql = "SELECT * from salons where salon_id=?";
	SalonInfo salon = new SalonInfo();
	try (PreparedStatement stmt = salonDB.prep(sql)) {
		stmt.setLong(1, salonID); 
		
		SQL.seq(stmt,  Unchecked.function(rs -> {
			salon.name = rs.getString("salon_name");
			salon.salonID = salonID;
			salon.ownerID = rs.getInt("owner_id");
			salon.mode = rs.getString("salon_mode");
			salon.description = rs.getString("salon_description");
			salon.created = rs.getTimestamp("salon_created");
			salon.salonType = rs.getString("salon_type");
			return salon;
		  }
		));
	} catch (Exception e) {
		throw e;
	}
	return salon;
}
 
开发者ID:DiscourseDB,项目名称:discoursedb-core,代码行数:23,代码来源:SalonInfo.java

示例9: getProsoloFollowedEntity

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
/**
 * Returns a single ProsoloUser object
 * 
 * @param id the id of the followed entity
 * @return an optional ProsoloFollowedEntity that is empty if the id did not exist
 * @throws SQLException
 */
public Optional<ProsoloFollowedEntity> getProsoloFollowedEntity(Long id) throws SQLException {
	if(id==null){
		return Optional.empty();
	}
	Optional<ProsoloFollowedEntity> pFollowedEntity = null;
	try (Connection c = getConnection()) {
		String sql = "SELECT * from "+TableConstants.FOLLOWEDENTITY+" where id=?";
		try (PreparedStatement stmt = c.prepareStatement(sql)) {
			stmt.setLong(1, id); 
			pFollowedEntity = SQL.seq(stmt, Unchecked.function(rs -> new ProsoloFollowedEntity(
					rs.getString("dtype"),
					rs.getLong("id"),
					rs.getTimestamp("created"),
					rs.getBoolean("deleted"),
					rs.getString("dc_description"),
					rs.getString("title"),
					rs.getTimestamp("started_following"),
					rs.getLong("user"),
					rs.getLong("followed_node"),
					rs.getLong("followed_user")
	            ))).findFirst();
		}
	}
	return pFollowedEntity;
}
 
开发者ID:DiscourseDB,项目名称:discoursedb-core,代码行数:33,代码来源:ProsoloDB.java

示例10: mapProsoloUserIdToedXUsername

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
/**
 * Returns the edX username for a given ProSolo user id.
 * 
 * @param id the prosolo user id
 * @return an Optional containing the edX username of the prosolo user with the provided id, if a mapping exists
 * @throws SQLException
 */
public Optional<String> mapProsoloUserIdToedXUsername(Long id) throws SQLException {
	if(id==null){
		return Optional.empty();
	}
	Optional<String> edXid=null;
	try (Connection c = getConnection()) {
		String sql = "SELECT validated_id from "+TableConstants.OPENIDACCOUNT+" where user=? and validated_id is not null";
		try (PreparedStatement stmt = c.prepareStatement(sql)) {
			stmt.setLong(1, id); 
			edXid = SQL.seq(stmt, Unchecked.function(rs -> rs.getString("validated_id"))).findFirst();
		}
	}		
	if(!edXid.isPresent()){
		return edXid;
	}else{
		return Optional.of(edXid.get().substring(edXid.get().lastIndexOf("/")+1));							
	}
}
 
开发者ID:DiscourseDB,项目名称:discoursedb-core,代码行数:26,代码来源:ProsoloDB.java

示例11: write

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
/**
 * Saves a PreferenceData instance in two files for user and item preferences, respectively. The format of the user preferences stream consists on one list per line, starting with the identifier of the user followed by the identifiers of the items related to that. The item preferences stream follows the same format by swapping the roles of users and items.
 *
 * @param prefData preferences
 * @param uo stream of user preferences
 * @param io stream of user preferences
 */
public void write(FastPreferenceData<?, ?> prefData, OutputStream uo, OutputStream io) {
    BiConsumer<FastPreferenceData<?, ?>, OutputStream> saver = Unchecked.biConsumer((prefs, os) -> {
        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os))) {
            prefs.getUidxWithPreferences().forEach(Unchecked.intConsumer(uidx -> {
                String a = prefs.getUidxPreferences(uidx)
                        .mapToInt(IdxPref::v1)
                        .sorted()
                        .mapToObj(Integer::toString)
                        .collect(joining("\t"));

                writer.write(uidx + "\t" + a);
                writer.newLine();
            }));
        }
    });

    saver.accept(prefData, uo);
    saver.accept(new TransposedPreferenceData<>(prefData), io);
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:27,代码来源:CompressibleBinaryPreferencesFormat.java

示例12: write

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
/**
 * Saves a PreferenceData instance in two files for user and item preferences, respectively. The format of the user preferences stream consists on one list per line, starting with the identifier of the user followed by the identifier-rating pairs of the items related to that. The item preferences stream follows the same format by swapping the roles of users and items.
 *
 * @param prefData preferences
 * @param uo stream of user preferences
 * @param io stream of user preferences
 */
public void write(FastPreferenceData<?, ?> prefData, OutputStream uo, OutputStream io) {
    BiConsumer<FastPreferenceData<?, ?>, OutputStream> saver = Unchecked.biConsumer((prefs, os) -> {
        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os))) {
            prefs.getUidxWithPreferences().forEach(Unchecked.intConsumer(uidx -> {
                String a = prefs.getUidxPreferences(uidx)
                        .sorted((p1, p2) -> Integer.compare(p1.v1, p2.v1))
                        .map(p -> p.v1 + "\t" + (int) p.v2)
                        .collect(joining("\t"));

                writer.write(uidx + "\t" + a);
                writer.newLine();
            }));
        }
    });

    saver.accept(prefData, uo);
    saver.accept(new TransposedPreferenceData<>(prefData), io);
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:26,代码来源:CompressibleRatingPreferencesFormat.java

示例13: calculateStatsForAppIdSelector

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
private LogicalFlowStatistics calculateStatsForAppIdSelector(IdSelectionOptions options) {
    checkNotNull(options, "options cannot be null");

    Select<Record1<Long>> appIdSelector = appIdSelectorFactory.apply(options);

    Future<List<TallyPack<String>>> dataTypeCounts = dbExecutorPool.submit(() ->
            FunctionUtilities.time("DFS.dataTypes",
                () -> logicalFlowStatsDao.tallyDataTypesByAppIdSelector(appIdSelector)));

    Future<LogicalFlowMeasures> appCounts = dbExecutorPool.submit(() ->
            FunctionUtilities.time("DFS.appCounts",
                () -> logicalFlowStatsDao.countDistinctAppInvolvementByAppIdSelector(appIdSelector)));

    Future<LogicalFlowMeasures> flowCounts = dbExecutorPool.submit(() ->
            FunctionUtilities.time("DFS.flowCounts",
                () -> logicalFlowStatsDao.countDistinctFlowInvolvementByAppIdSelector(appIdSelector)));

    Supplier<ImmutableLogicalFlowStatistics> statSupplier = Unchecked.supplier(() -> ImmutableLogicalFlowStatistics.builder()
            .dataTypeCounts(dataTypeCounts.get())
            .appCounts(appCounts.get())
            .flowCounts(flowCounts.get())
            .build());

    return statSupplier.get();
}
 
开发者ID:khartec,项目名称:waltz,代码行数:26,代码来源:LogicalFlowService.java

示例14: generateWithNoRollup

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
public List<TallyPack<String>> generateWithNoRollup(Collection<Long> statisticIds,
                                                    EntityReference entityReference) {

    checkNotNull(statisticIds, "statisticIds cannot be null");
    checkNotNull(entityReference, "entityReference cannot be null");

    if (statisticIds.isEmpty()) {
        return Collections.emptyList();
    }

    List<Future<TallyPack<String>>> summaryFutures = statisticIds.stream()
            .map(statId -> dbExecutorPool.submit(() ->
                    generateWithNoRollup(statId, entityReference)))
            .collect(toList());

    return summaryFutures.stream()
            .map(f -> Unchecked.supplier(() -> f.get())
                    .get())
            .collect(toList());
}
 
开发者ID:khartec,项目名称:waltz,代码行数:21,代码来源:EntityStatisticSummaryDao.java

示例15: generateSummaries

import org.jooq.lambda.Unchecked; //导入依赖的package包/类
private <T> List<TallyPack<String>> generateSummaries(Collection<Long> statisticIds,
                                                      Select<Record1<Long>> appIdSelector,
                                                      Field<T> aggregateField,
                                                      Function<T, Double> toTally) {

    checkNotNull(statisticIds, "statisticIds cannot be null");
    checkNotNull(appIdSelector, "appIdSelector cannot be null");
    checkNotNull(aggregateField, "aggregateField cannot be null");
    checkNotNull(toTally, "toTally function cannot be null");

    if (statisticIds.isEmpty()) {
        return Collections.emptyList();
    }

    List<Future<TallyPack<String>>> summaryFutures = statisticIds.stream()
            .map(statId -> dbExecutorPool.submit(() ->
                    generateSummary(statId, appIdSelector, aggregateField, toTally)))
            .collect(toList());

    return summaryFutures.stream()
            .map(f -> Unchecked.supplier(() -> f.get())
                    .get())
            .collect(toList());
}
 
开发者ID:khartec,项目名称:waltz,代码行数:25,代码来源:EntityStatisticSummaryDao.java


注:本文中的org.jooq.lambda.Unchecked类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。