0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【メモ】Javaのメソッドを共通化

Posted at

共通メソッド分割前

// 
Map<String, List<ContractSearchQueryResult>> contractCodeResultMap = 
	queryResults
		.stream()
		.collect(Colletors.groupingBy(ContractSearchQueryResult::getContractCode));

共通メソッド分割後

// 契約書ごとにグループ化する処理を共通化したメソッドをprivateで定義
private Map<String, List<ContractSearchQueryResult>> generateMapGroupedByContract(
List<ContractSearchQueryResult> queryResults) {
  return queryResults
		.stream()
		.collect(Collectors.groupingBy(ContractSearchQueryResult::getContractCode));
}

// 共通化メソッドを使用した処理
Map<String, List<ContractSearchQueryResult>> contractCodeResultMap = generateMapGroupedByContract(queryResults);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?