Changes for BAEL-2215

This commit is contained in:
Nikhil Khatwani 2018-10-23 17:56:26 +05:30
parent 1bca2a8c54
commit 2809811d9f
2 changed files with 12 additions and 3 deletions

View File

@ -16,5 +16,6 @@ public class CollectionInjectionDemo {
collectionsBean.printNameSet(); collectionsBean.printNameSet();
collectionsBean.printNameMap(); collectionsBean.printNameMap();
collectionsBean.printBeanList(); collectionsBean.printBeanList();
collectionsBean.printNameListWithDefaults();
} }
} }

View File

@ -1,13 +1,14 @@
package com.baeldung.collection; package com.baeldung.collection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
/** /**
* Created by Gebruiker on 5/18/2018. * Created by Gebruiker on 5/18/2018.
*/ */
@ -24,6 +25,9 @@ public class CollectionsBean {
@Qualifier("CollectionsBean") @Qualifier("CollectionsBean")
private List<BaeldungBean> beanList = new ArrayList<>(); private List<BaeldungBean> beanList = new ArrayList<>();
@Value("${names.list:}#{T(java.util.Collections).emptyList()}")
private List<String> nameListWithDefaultValue;
public CollectionsBean() { public CollectionsBean() {
} }
@ -51,4 +55,8 @@ public class CollectionsBean {
public void printBeanList() { public void printBeanList() {
System.out.println(beanList); System.out.println(beanList);
} }
public void printNameListWithDefaults() {
System.out.println(nameListWithDefaultValue);
}
} }