Merge pull request #5526 from khatwaniNikhil/BAEL-2215

Changes for BAEL-2215
This commit is contained in:
Loredana Crusoveanu 2018-10-24 19:43:29 +03:00 committed by GitHub
commit c26630f046
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
}
} }