스칼라 2.11.8을 사용하고 있습니다.반환 값을 보장하는 방법 StringList가 주문됩니다. 스칼라
내 속성 파일에서 쿼리를 읽으려고합니다. 각 쿼리 세트에는 여러 부분이 있습니다 (아래 설명 참조)
그리고 이러한 쿼리를 실행해야하는 특정 순서가 있습니다.
코드 :
import com.typesafe.config.ConfigFactory
object ReadProperty {
def main(args : Array[String]): Unit = {
val queryRead = ConfigFactory.load("testqueries.properties").getConfig("select").getStringList("caseInc").toArray()
val localRead = ConfigFactory.load("testqueries.properties").getConfig("select").getStringList("caseLocal").toArray.toSet
queryRead.foreach(println)
localRead.foreach(println)
}
}
PropertyFile 내용 :
select.caseInc.2 = Select emp_salary, emp_dept_id from employees
select.caseLocal.1 = select one
select.caseLocal.3 = select three
select.caseRemote.2 = Select e1.emp_name, d1.dept_name, e1.salary from emp_1 e1 join dept_1 d1 on(e1.emp_dept_id = d1.dept_id)
select.caseRemote.1 = Select * from departments
select.caseInc.1 = Select emp_id, emp_name from employees
select.caseLocal.2 = select two
select.caseLocal.4 = select four
출력 : 우리가 OUTP에서 볼 수 있듯이
Select emp_id, emp_name from employees
Select emp_salary, emp_dept_id from employees
select one
select two
select three
select four
결과는 이다.으로 분류된다. 속성에서 당신이 시퀀스에서 쿼리의 번호를 매기려고 시도했다면 (caseInc, caseLocal을 인수로 전달) 실행해야합니다.
getStringList()를 사용하면 항상 제공하는 시퀀스 번호에 따라 정렬 된 목록을 얻게됩니다.
toArray()를 사용하여 시도한 경우에도 & toArray(). toSet 정렬 된 출력을 가져오고 있습니다.
지금까지의 좋은
하지만 항상 내가 등록 정보 파일에 제공 한 정렬 된 순서로 반환됩니다 있는지 확인하는 방법에 대해 설명합니다. 어떻게 든 반환 된 List가 Sorted 될 것이라고 말하는 API를 찾을 수 없기 때문에 혼란 스럽습니다.